Hello !
I'm still suffering a lot with form field replacement & QuickPDF (see my other postings).
I have a PDF template, which is a PDF with empty form fields and I "stuff" content into those fields grabbing this content from a database.
So far, simple.
What happens is that SOMETIMES, a damaged PDF is generated.
I replaced QuickPDF inside my application by PDFTK, as Chicks suggested some time ago.
When using PDFTK, under the SAME CIRCUMSTANCES, I get a perfectly fine PDF.
As a matter of fact my application generates 2 PDFs : one via QuickPDF and now another one, via PDFTK, simultaneosly. That is, it generates two output files, one from each tool.
I have supplied a kit :
http://www.DES.online.unimep.br/au/pub/kitpdftk.zip
There inside :
- AG284D.PDF is the template itself.
- LOG.TXT is a log file where I transcript the field names and values that I'm supposed to replace, from bottom up.
- QPDF.PDF is the PDF generated via QuicPDF.
- PDFTK.FDF is the FDF file that I build on my own.
- PDFTK.BAT is the batch file I use to run PDFTK.
- PDFTK.PDF is the PDF generated by PDFTK.
The circumstances (EXEcutable, DATA, machine) and everything else are the SAME but QuickPDF generates a wrong PDF and PDFTK generates a OK one.
My conclusion is that there's a bug on QuickPDF field replacement or flattening.
Someone can help me ?
I see no other alternative but to replace QuickPDF by PDFTK, what I TOTALLY dislike....
My logic to replace fields on QUICKPDF is like this :
LNT:=LOQPDF:FORMFIELDCOUNT() FOR LNI:=LNT TO 1 STEP -1 LCFNAME:=LOQPDF:GETFORMFIELDTITLE(LNI) IF EMPTY(LCFNAME) // SHOUT 'EMPTY FORM FIELD NAME' AND GET OUT END IF // SEARCHES FOR THIS FORM FIELD (LCFNAME) VALUE AND IF NOT FOUND, GET OUT IF (LNF:=ASCAN(LAPAGES[LNIPAGE,2],{|E,I| LCFNAME == E[1]})) == 0 // SHOUT 'FORM FIELD VALUE NOT FOUND' // GET OUT END IF LCFVALUE:=LAPAGES[LNIPAGE,2,LNF,2] IF LCFVALUE == NIL // SHOULD I HAVE A NULL FIELD VALUE, EMPTIES IT LCFVALUE := "" END IF IF NOT (LXRESULT:=LOQPDF:SETFORMFIELDVALUE(LNI,LCFVALUE)) == 1 // COULD NOT SET FORM FIELD VALUE // GET OUT END IF IF NOT (LXRESULT:=LOQPDF:FLATTENFORMFIELD(LNI)) == 1 // COULD NOT FLATTEN FORM FIELD // GET OUT END IF // BUILDS FDF FILE... LCFDF+="<<" + CRLF + ; "/T (■" + CHR(255) + CHARMIX(REPLICATE(CHR(0),LEN(LCFNAME)),LCFNAME) + ")" + CRLF + ; "/V (■" + CHR(255) + CHARMIX(REPLICATE(CHR(0),LEN(LCFVALUE)),LCFVALUE) + ")" + CRLF + ; ">>" + CRLF M->PCOLOG+=STRTRIM(PROCLINE()) + " CAMPO # " + STRTRIM(LNI) + " : " + LCFNAME + " / " + LCFVALUE + CRLF // BUILDS THE LOG FILE NEXT
|