摘选其中的报表到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