Print Page | Close Window

Damaged PDF generated (Chapter II)...

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=840
Printed Date: 11 May 24 at 7:59PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Damaged PDF generated (Chapter II)...
Posted By: jabaltie
Subject: Damaged PDF generated (Chapter II)...
Date Posted: 12 Dec 07 at 10:13AM
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







Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk