注册 登录
编程论坛 VFP论坛

报表输出至pdf,html,xml

sam_jiang 发布于 2023-08-27 21:42, 892 次点击
上次说自己写个pdf解析器,哈哈,一直没有时间。

不过今天查看过去下载的文件,发现电脑里还有vfp前辈们写的现成的类,分享给大家。记得之前还下载了个foxypreviewer,非常实用,现在找不到了。。。

下载包:
只有本站会员才能查看附件,请 登录


输出表单截图:
只有本站会员才能查看附件,请 登录

10 回复
#2
sam_jiang2023-08-27 21:44
摘选其中的报表到pdf的核心代码:

DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER nWinHandle,STRING cOperation,STRING cFileName,STRING cParameters,STRING cDirectory,INTEGER nShowWindow
LOCAL lcFile,loCol,lcField,lcField2,lnField,lnField2,laField[1],lni,lcS,cCursor,lnPagNo,lnPagNoCur,lnLeng[10],lnRowCur,lnLengField,lnFieldV,laFieldV[1],lnHeadV,laHeadV[1],lnj
IF VARTYPE(This.grid)="O" AND !ISNULL(This.grid)
  IF LOWER(This.grid.baseclass)!="grid"
    RETURN
  ENDIF
  lcFile=PUTFILE("Alegeti fisierul",IIF(VARTYPE(This.label)="O" AND !ISNULL(This.label),This.label.caption+"_","")+TTOC(DATETIME(),1)+".pdf","PDF")
  cCursor=This.grid.RecordSource
  IF !EMPTY(lcFile) AND USED(This.grid.RecordSource)
    lnPagNo=CEILING((1+RECCOUNT(cCursor))/60)
    DIMENSION lnLeng[7+3*lnPagNo]
    lcS=[%PDF-1.2]+CHR(13)+[%]+CHR(226)+CHR(227)+CHR(207)+CHR(211)+CHR(13)
    lnLeng[1]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[1 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Author ]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/CreationDate ]+CHR(40)+[D:]+TTOC(DATETIME(),1)+CHR(41)+CHR(13)
    lcS=lcS+[/Creator]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/Producer]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/Title]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[/Subject]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[/Keywords]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[4]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[4 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Font]+CHR(13)
    lcS=lcS+[/Subtype /Font1]+CHR(13)
    lcS=lcS+[/Name /F1]+CHR(13)
    lcS=lcS+[/Encoding 5 0 R]+CHR(13)
    lcS=lcS+[/BaseFont /Courier]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[5]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[5 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Encoding]+CHR(13)
    lcS=lcS+[/BaseEncoding /WinAnsiEncoding]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[6]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[6 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[  /Font << /F1 4 0 R >>]+CHR(13)
    lcS=lcS+"  /ProcSet [ /PDF /Text ]"+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    *
    lnPagNoCur=1
    *
    lnLeng[6+3*(lnPagNoCur-1)+1]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+1))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Page]+CHR(13)
    lcS=lcS+[/Parent 3 0 R]+CHR(13)
    lcS=lcS+[/Resources 6 0 R]+CHR(13)
    lcS=lcS+[/Contents ]+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 R]+CHR(13)
    lcS=lcS+[/Rotate 0]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[6+3*(lnPagNoCur-1)+2]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Length ]+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[stream]+CHR(13)
    lcS=lcS+[BT]+CHR(13)
    lnLeng1=LEN(lcS)
    lcS=lcS+[/F1 10 Tf]+CHR(13)
    lcS=lcS+[1 0 0 1 50 752 Tm]+CHR(13)
    lcS=lcS+[12 TL]+CHR(13)
    lcS=lcS+[T* ]+CHR(40)
    lnField2=AFIELDS(laField,cCursor)
    lnField=0
    FOR EACH loCol IN This.grid.Columns
      IF !loCol.Visible
        LOOP
      ENDIF
      lcField=loCol.ControlSource
      lcField2=IIF(RAT(".",lcField)=0,lcField,SUBSTR(lcField,RAT(".",lcField)+1))
      lni=ASCAN(laField,lcField2,-1,-1,1,1+6+8)
      IF lni>0
        lnLengField=MAX(laField[lni,3],LEN(laField[lni,1]))+1
        IF laField[lni,2]="C"
          lcS=lcS+SPACE(1)+PADR(PROPER(laField[lni,1]),lnLengField-1)
        ELSE
          lcS=lcS+PADL(PROPER(laField[lni,1]),lnLengField-1)+SPACE(1)
        ENDIF
      ELSE
        lnLengField=254
        IF VARTYPE(&lcField)="C"
          lcS=lcS+SPACE(1)+PADR(PROPER(lcField2),lnLengField-1)
        ELSE
          lcS=lcS+PADL(PROPER(lcField2),lnLengField-1)+SPACE(1)
        ENDIF
      ENDIF
      lnField=lnField+1
    NEXT
    lcS=lcS+CHR(13)+CHR(10)+CHR(41)+[ Tj]+CHR(13)
    lnRowCur=0
    SELECT (cCursor)
    SCAN
      lnRowCur=lnRowCur+1
      IF MOD(lnRowCur,60)=0
        lcS=lcS+[1 0 0 1 504 25 Tm]+CHR(13)
        lcS=lcS+CHR(40)+ALLTRIM(STR(lnPagNoCur))+CHR(41)+[ Tj]+CHR(13)
        lcS=lcS+[/F1 10 Tf]+CHR(13)
        lnLeng2=LEN(lcS)
        lcS=lcS+[ET]+CHR(13)
        lcS=lcS+[endstream]+CHR(13)
        lcS=lcS+[endobj]+CHR(13)
        lnLeng[6+3*lnPagNoCur]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 obj]+CHR(13)
        lcS=lcS+ALLTRIM(STR(lnLeng2-lnLeng1))+CHR(13)
        lcS=lcS+[endobj]+CHR(13)
        lnPagNoCur=lnPagNoCur+1
        *
        lnLeng[6+3*(lnPagNoCur-1)+1]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+1))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
        lcS=lcS+[/Type /Page]+CHR(13)
        lcS=lcS+[/Parent 3 0 R]+CHR(13)
        lcS=lcS+[/Resources 6 0 R]+CHR(13)
        lcS=lcS+[/Contents ]+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 R]+CHR(13)
        lcS=lcS+[/Rotate 0]+CHR(13)
        lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
        lnLeng[6+3*(lnPagNoCur-1)+2]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
        lcS=lcS+[/Length ]+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 R]+CHR(13)
        lcS=lcS+[>>]+CHR(13)+[stream]+CHR(13)
        lcS=lcS+[BT]+CHR(13)
        lnLeng1=LEN(lcS)
        lcS=lcS+[/F1 10 Tf]+CHR(13)
        lcS=lcS+[1 0 0 1 50 752 Tm]+CHR(13)
        lcS=lcS+[12 TL]+CHR(13)
      ENDIF
      lcS=lcS+[T* ]+CHR(40)
    lnField2=AFIELDS(laField,cCursor)
    lnField=0
    FOR EACH loCol IN This.grid.Columns
      IF !loCol.Visible
        LOOP
      ENDIF
      lcField=loCol.ControlSource
      lcField2=IIF(RAT(".",lcField)=0,lcField,SUBSTR(lcField,RAT(".",lcField)+1))
      lni=ASCAN(laField,lcField2,-1,-1,1,1+6+8)
      IF lni>0
        lnLengField=MAX(laField[lni,3],LEN(laField[lni,1]))+1
        lcField=laField[lni,1]
        DO CASE
        CASE laField[lni,2]="C"
          lcS=lcS+SPACE(1)+PADR(ALLTRIM(&lcField),lnLengField-1)
        CASE laField[lni,2]="N"
          lcS=lcS+PADL(ALLTRIM(STR(&lcField,laField[lni,3],laField[lni,4])),lnLengField-1)+SPACE(1)
        CASE laField[lni,2]="I"
          lcS=lcS+PADL(ALLTRIM(STR(&lcField)),lnLengField-1)+SPACE(1)
        CASE laField[lni,2]="D"
          lcS=lcS+PADL(DTOC(&lcField),lnLengField-1)+SPACE(1)
        CASE laField[lni,2]="T"
          lcS=lcS+PADL(DTOC(TTOD(&lcField))+" "+TTOC(&lcField,2),lnLengField-1)+SPACE(1)
        CASE laField[lni,2]="L"
          lcS=lcS+PADL(IIF(&lcField,"X","-"),lnLengField-1)+SPACE(1)
        ENDCASE  
      ELSE
        DO CASE
        CASE VARTYPE(&lcField)="C"
          lnLengField=254
          lcS=lcS+SPACE(1)+PADR(ALLTRIM(&lcField),lnLengField-1)
        CASE VARTYPE(&lcField)="N"
          lcS=lcS+PADL(ALLTRIM(STR(&lcField,30,3)),30-1)+SPACE(1)
        CASE VARTYPE(&lcField)="I"
          lcS=lcS+PADL(ALLTRIM(STR(&lcField)),30-1)+SPACE(1)
        CASE VARTYPE(&lcField)="D"
          lcS=lcS+PADL(DTOC(&lcField),12-1)+SPACE(1)
        CASE VARTYPE(&lcField)="T"
          lcS=lcS+PADL(DTOC(TTOD(&lcField))+" "+TTOC(&lcField,2),22-1)+SPACE(1)
        CASE VARTYPE(&lcField)="L"
          lcS=lcS+PADL(IIF(&lcField,"X","-"),3-1)+SPACE(1)
        ENDCASE  
      ENDIF
      lnField=lnField+1
    NEXT
      lcS=lcS+CHR(13)+CHR(10)+CHR(41)+[ Tj]+CHR(13)
      SELECT (cCursor)
    ENDSCAN
    lcS=lcS+[1 0 0 1 504 25 Tm]+CHR(13)
    lcS=lcS+CHR(40)+ALLTRIM(STR(lnPagNoCur))+CHR(41)+[ Tj]+CHR(13)
    lcS=lcS+[/F1 10 Tf]+CHR(13)
    lnLeng2=LEN(lcS)
    lcS=lcS+[ET]+CHR(13)
    lcS=lcS+[endstream]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[6+3*lnPagNoCur]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 obj]+CHR(13)
    lcS=lcS+ALLTRIM(STR(lnLeng2-lnLeng1))+CHR(13)
    lcS=lcS+[endobj]+CHR(13)

    lnLeng[2]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[2 0 obj]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Type /Catalog]+CHR(13)
    lcS=lcS+[/Pages 3 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[3]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[3 0 obj]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Type /Pages]+CHR(13)
    lcS=lcS+[/Count ]+ALLTRIM(STR(lnPagNo))+CHR(13)
    lcS=lcS+"/MediaBox [ 0 0 1008 792 ]"+CHR(13)
    lcS=lcS+"/Kids [ "
    FOR lni=1 TO lnPagNo
      lcS=lcS+ALLTRIM(STR(6+3*(lni-1)+1))+" 0 R "
    NEXT
    lcS=lcS+"]"+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[7+3*lnPagNo]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[0 ]+ALLTRIM(STR(7+3*lnPagNo))+CHR(13)
    lcS=lcS+[0000000000 65535 f]+CHR(13)
    FOR lni=1 TO 7+3*lnPagNo
      lcS=lcS+PADL(ALLTRIM(STR(lnLeng[lni])),10,"0")+[ 00000 n]+CHR(13)
    NEXT
    lcS=lcS+[trailer]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Size ]+ALLTRIM(STR(7+3*lnPagNo))+CHR(13)
    lcS=lcS+[/Root 2 0 R]+CHR(13)
    lcS=lcS+[/Info 1 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[startxref]+CHR(13)
    lcS=lcS+ALLTRIM(STR(lnLeng[7+3*lnPagNo]))+CHR(13)
    lcS=lcS+[%%EOF]+CHR(13)
    STRTOFILE(lcS,lcFile)
    ShellExecute(0,"Open",lcFile,"","",1)
  ENDIF
ENDIF

IF VARTYPE(This.grid)="C" AND !EMPTY(This.grid)
  lcFile=PUTFILE("Alegeti fisierul",IIF(VARTYPE(This.label)="O" AND !ISNULL(This.label),This.label.caption+"_","")+TTOC(DATETIME(),1)+".pdf","PDF")
  cCursor=This.grid
  IF !EMPTY(lcFile) AND USED(This.grid)
    STORE 0 TO lnHeadV,lnFieldV
    IF !EMPTY(This.cHeaders)
      lnHeadV=ALINES(laHeadV,This.cHeaders,.T.,",")
    ENDIF
    IF !EMPTY(This.cFields)
      lnFieldV=ALINES(laFieldV,This.cFields,.T.,",")
    ENDIF

    lnPagNo=CEILING((1+RECCOUNT(cCursor))/60)
    DIMENSION lnLeng[7+3*lnPagNo]
    lcS=[%PDF-1.2]+CHR(13)+[%]+CHR(226)+CHR(227)+CHR(207)+CHR(211)+CHR(13)
    lnLeng[1]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[1 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Author ]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/CreationDate ]+CHR(40)+[D:]+TTOC(DATETIME(),1)+CHR(41)+CHR(13)
    lcS=lcS+[/Creator]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/Producer]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/Title]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[/Subject]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[/Keywords]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[4]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[4 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Font]+CHR(13)
    lcS=lcS+[/Subtype /Font1]+CHR(13)
    lcS=lcS+[/Name /F1]+CHR(13)
    lcS=lcS+[/Encoding 5 0 R]+CHR(13)
    lcS=lcS+[/BaseFont /Courier]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[5]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[5 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Encoding]+CHR(13)
    lcS=lcS+[/BaseEncoding /WinAnsiEncoding]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[6]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[6 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[  /Font << /F1 4 0 R >>]+CHR(13)
    lcS=lcS+"  /ProcSet [ /PDF /Text ]"+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    *
    lnPagNoCur=1
    *
    lnLeng[6+3*(lnPagNoCur-1)+1]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+1))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Page]+CHR(13)
    lcS=lcS+[/Parent 3 0 R]+CHR(13)
    lcS=lcS+[/Resources 6 0 R]+CHR(13)
    lcS=lcS+[/Contents ]+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 R]+CHR(13)
    lcS=lcS+[/Rotate 0]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[6+3*(lnPagNoCur-1)+2]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Length ]+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[stream]+CHR(13)
    lcS=lcS+[BT]+CHR(13)
    lnLeng1=LEN(lcS)
    lcS=lcS+[/F1 10 Tf]+CHR(13)
    lcS=lcS+[1 0 0 1 50 752 Tm]+CHR(13)
    lcS=lcS+[12 TL]+CHR(13)
    lcS=lcS+[T* ]+CHR(40)
    lnField=AFIELDS(laField,cCursor)
    lcField=""
    IF lnFieldV=0
      FOR lni=1 TO lnField
        lnLengField=MAX(laField[lni,3],LEN(laField[lni,1]))+1
        IF laField[lni,2]="C"
          lcS=lcS+SPACE(1)+PADR(PROPER(laField[lni,1]),lnLengField-1)
        ELSE
          lcS=lcS+PADL(PROPER(laField[lni,1]),lnLengField-1)+SPACE(1)
        ENDIF
      NEXT
    ELSE
      FOR lnj=1 TO lnFieldV
        lcField=laFieldV[lnj]
        lcField2=IIF(RAT(".",lcField)=0,lcField,SUBSTR(lcField,RAT(".",lcField)+1))
        lni=ASCAN(laField,lcField2,-1,-1,1,1+6+8)
        IF lni>0
          lnLengField=MAX(laField[lni,3],LEN(IIF(lnHeadV=lnFieldV,laHeadV[lnj],laField[lni,1])))+1
          IF laField[lni,2]="C"
            lcS=lcS+SPACE(1)+PADR(IIF(lnHeadV=lnFieldV,laHeadV[lnj],PROPER(laField[lni,1])),lnLengField-1)
          ELSE
            lcS=lcS+PADL(IIF(lnHeadV=lnFieldV,laHeadV[lnj],PROPER(laField[lni,1])),lnLengField-1)+SPACE(1)
          ENDIF
        ELSE
          lnLengField=254
          IF VARTYPE(&lcField)="C"
            lcS=lcS+SPACE(1)+PADR(PROPER(lcField2),lnLengField-1)
          ELSE
            lcS=lcS+PADL(PROPER(lcField2),lnLengField-1)+SPACE(1)
          ENDIF
        ENDIF
      NEXT
    ENDIF
    lcS=lcS+CHR(13)+CHR(10)+CHR(41)+[ Tj]+CHR(13)
    lnRowCur=0
    SELECT (cCursor)
    SCAN
      lnRowCur=lnRowCur+1
      IF MOD(lnRowCur,60)=0
        lcS=lcS+[1 0 0 1 504 25 Tm]+CHR(13)
        lcS=lcS+CHR(40)+ALLTRIM(STR(lnPagNoCur))+CHR(41)+[ Tj]+CHR(13)
        lcS=lcS+[/F1 10 Tf]+CHR(13)
        lnLeng2=LEN(lcS)
        lcS=lcS+[ET]+CHR(13)
        lcS=lcS+[endstream]+CHR(13)
        lcS=lcS+[endobj]+CHR(13)
        lnLeng[6+3*lnPagNoCur]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 obj]+CHR(13)
        lcS=lcS+ALLTRIM(STR(lnLeng2-lnLeng1))+CHR(13)
        lcS=lcS+[endobj]+CHR(13)
        lnPagNoCur=lnPagNoCur+1
        *
        lnLeng[6+3*(lnPagNoCur-1)+1]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+1))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
        lcS=lcS+[/Type /Page]+CHR(13)
        lcS=lcS+[/Parent 3 0 R]+CHR(13)
        lcS=lcS+[/Resources 6 0 R]+CHR(13)
        lcS=lcS+[/Contents ]+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 R]+CHR(13)
        lcS=lcS+[/Rotate 0]+CHR(13)
        lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
        lnLeng[6+3*(lnPagNoCur-1)+2]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
        lcS=lcS+[/Length ]+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 R]+CHR(13)
        lcS=lcS+[>>]+CHR(13)+[stream]+CHR(13)
        lcS=lcS+[BT]+CHR(13) && begin text
        lnLeng1=LEN(lcS)
        lcS=lcS+[/F1 10 Tf]+CHR(13)
        lcS=lcS+[1 0 0 1 50 752 Tm]+CHR(13)
        lcS=lcS+[12 TL]+CHR(13)
      ENDIF
      lcS=lcS+[T* ]+CHR(40)
      IF lnFieldV=0
        FOR lni=1 TO lnField
          lnLengField=MAX(laField[lni,3],LEN(laField[lni,1]))+1
          lcField=laField[lni,1]
          DO CASE
          CASE laField[lni,2]="C"
            lcS=lcS+SPACE(1)+PADR(ALLTRIM(&lcField),lnLengField-1)
          CASE laField[lni,2]="N"
            lcS=lcS+PADL(ALLTRIM(STR(&lcField,laField[lni,3],laField[lni,4])),lnLengField-1)+SPACE(1)
          CASE laField[lni,2]="I"
            lcS=lcS+PADL(ALLTRIM(STR(&lcField)),lnLengField-1)+SPACE(1)
          CASE laField[lni,2]="D"
            IF EMPTY(&lcField)
              lcS=lcS+PADL("",lnLengField-1)+SPACE(1)
            ELSE
              lcS=lcS+PADL(DTOC(&lcField),lnLengField-1)+SPACE(1)
            ENDIF
          CASE laField[lni,2]="T"
            lcS=lcS+PADL(DTOC(TTOD(&lcField))+" "+TTOC(&lcField,2),lnLengField-1)+SPACE(1)
          CASE laField[lni,2]="L"
            lcS=lcS+PADL(IIF(&lcField,"X","-"),lnLengField-1)+SPACE(1)
          ENDCASE  
        NEXT
      ELSE
        FOR lnj=1 TO lnFieldV
          lcField=laFieldV[lnj]
          lcField2=IIF(RAT(".",lcField)=0,lcField,SUBSTR(lcField,RAT(".",lcField)+1))
          lni=ASCAN(laField,lcField2,-1,-1,1,1+6+8)
          IF lni>0
            lnLengField=MAX(laField[lni,3],LEN(IIF(lnHeadV=lnFieldV,laHeadV[lnj],laField[lni,1])))+1
          ELSE
            lnLengField=254
          ENDIF
          DO CASE
          CASE VARTYPE(&lcField)="C"
            lcS=lcS+SPACE(1)+PADR(ALLTRIM(&lcField),lnLengField-1)
          CASE VARTYPE(&lcField)="N"
            IF lni>0
              DO CASE
              CASE laField[lni,2]="N"
                lcS=lcS+PADL(ALLTRIM(STR(&lcField,laField[lni,3],laField[lni,4])),lnLengField-1)+SPACE(1)
              CASE laField[lni,2]="I"
                lcS=lcS+PADL(ALLTRIM(STR(&lcField)),lnLengField-1)+SPACE(1)
              OTHERWISE
                lcS=lcS+PADL(ALLTRIM(STR(&lcField,30,3)),lnLengField-1)+SPACE(1)
              ENDCASE
            ELSE
              lcS=lcS+PADL(ALLTRIM(STR(&lcField,30,3)),lnLengField-1)+SPACE(1)
            ENDIF
          CASE VARTYPE(&lcField)="D"
            IF EMPTY(&lcField)
              lcS=lcS+PADL("",lnLengField-1)+SPACE(1)
            ELSE
              lcS=lcS+PADL(DTOC(&lcField),lnLengField-1)+SPACE(1)
            ENDIF
          CASE VARTYPE(&lcField)="T"
            lcS=lcS+PADL(DTOC(TTOD(&lcField))+" "+TTOC(&lcField,2),lnLengField-1)+SPACE(1)
          CASE VARTYPE(&lcField)="L"
            lcS=lcS+PADL(IIF(&lcField,"X","-"),lnLengField-1)+SPACE(1)
          ENDCASE  
        NEXT
      ENDIF
      lcS=lcS+CHR(13)+CHR(10)+CHR(41)+[ Tj]+CHR(13)
      SELECT (cCursor)
    ENDSCAN
    lcS=lcS+[1 0 0 1 504 25 Tm]+CHR(13)
    lcS=lcS+CHR(40)+ALLTRIM(STR(lnPagNoCur))+CHR(41)+[ Tj]+CHR(13)
    lcS=lcS+[/F1 10 Tf]+CHR(13)
    lnLeng2=LEN(lcS)
    lcS=lcS+[ET]+CHR(13) && end text
    lcS=lcS+[endstream]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[6+3*lnPagNoCur]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 obj]+CHR(13)
    lcS=lcS+ALLTRIM(STR(lnLeng2-lnLeng1))+CHR(13)
    lcS=lcS+[endobj]+CHR(13)

    lnLeng[2]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[2 0 obj]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Type /Catalog]+CHR(13)
    lcS=lcS+[/Pages 3 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[3]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[3 0 obj]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Type /Pages]+CHR(13)
    lcS=lcS+[/Count ]+ALLTRIM(STR(lnPagNo))+CHR(13)
    lcS=lcS+"/MediaBox [ 0 0 1008 792 ]"+CHR(13)
    lcS=lcS+"/Kids [ "
    FOR lni=1 TO lnPagNo
      lcS=lcS+ALLTRIM(STR(6+3*(lni-1)+1))+" 0 R "
    NEXT
    lcS=lcS+"]"+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[7+3*lnPagNo]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[0 ]+ALLTRIM(STR(7+3*lnPagNo))+CHR(13)
    lcS=lcS+[0000000000 65535 f]+CHR(13)
    FOR lni=1 TO 7+3*lnPagNo
      lcS=lcS+PADL(ALLTRIM(STR(lnLeng[lni])),10,"0")+[ 00000 n]+CHR(13)
    NEXT
    lcS=lcS+[trailer]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Size ]+ALLTRIM(STR(7+3*lnPagNo))+CHR(13)
    lcS=lcS+[/Root 2 0 R]+CHR(13)
    lcS=lcS+[/Info 1 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[startxref]+CHR(13)
    lcS=lcS+ALLTRIM(STR(lnLeng[7+3*lnPagNo]))+CHR(13)
    lcS=lcS+[%%EOF]+CHR(13)
    STRTOFILE(lcS,lcFile)
    ShellExecute(0,"Open",lcFile,"","",1)
  ENDIF
ENDIF
#3
xinjie2023-08-28 05:05
#4
gxouyuan2023-08-28 08:13
感谢大佬们分享
#5
schtg2023-08-28 08:58
谢谢分享!
#6
easyppt2023-08-28 11:38
LZ, 是  FRX 直接到  PDF 吗,支持自定义字体吗
#7
sam_jiang2023-08-28 12:24
回复 6楼 easyppt
可以自己设置。
#8
老去的流星雨2023-09-09 18:00
到PDF可以用WINDOWS自身的Microsoft Print to PDF虚拟打印机,完美转换,以下是关键代码
APRINTERS(prt)
        lcPrintName = ""
        FOR i = 1 TO ALEN(prt,1)
            IF 'PDF'$prt(i,1)
                lcPrintName = prt(i,1)
            ENDIF
        ENDFOR
        SET PRINTER TO NAME (lcPrintName)
REPORT FORM (lcFrxName) NOWAIT
#9
sam_jiang2023-09-09 20:16
回复 8楼 老去的流星雨
我的windows怎么没有自带啊?
#10
老去的流星雨2023-09-10 10:30
回复 9楼 sam_jiang
可以安装一下
#11
wxzd1232023-09-10 11:00
回复 10楼 老去的流星雨
您好,能否给点示例代码,原来还特意安装Bullzip打印机,谢谢
1