Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Empty form field on a PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Empty form field on a PDF

 Post Reply Post Reply
Author
Message
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Topic: Empty form field on a PDF
    Posted: 26 Nov 07 at 1:56PM
I have a PDF template , which is a PDF with empty form fields.

This PDF template was designed using Open Office Writer.

I suspect this PDF template has some problem, that is, there's a bug on Open Office Writer OR there's some problem with the FlattenFormField function.....


Please take a look at the VBScript below. It loops across the PDF template form fields and flattens them all.

Get the PDF template to use on this VBScript code from here :

http://www.DES.online.unimep.br/au/pub/ag284d.pdf

Follows the source code :

=====================
OPTION EXPLICIT

DIM OBJARGS
DIM OBJQPDF
DIM ARQPDF
DIM LNI
DIM LNT
DIM FORMFIELDNAME

SET OBJARGS=WScript.Arguments

ARQPDF=OBJARGS(0)

SET OBJQPDF=WSCRIPT.CREATEOBJECT("ISED.QUICKPDF")

IF  NOT OBJQPDF.UNLOCKKEY("yourkeyhere") = 1 THEN
    WSCRIPT.ECHO "COULD NOT UNLOCKKEY"
    WSCRIPT.QUIT(1)
END IF

IF  OBJQPDF.LOADFROMFILE(ARQPDF) = 0 THEN
    WSCRIPT.ECHO "COULD NOT LOAD TEMPLATE"
    WSCRIPT.QUIT(1)
END IF

LNT=OBJQPDF.FORMFIELDCOUNT()

FOR LNI=1 TO LNT
  FORMFIELDNAME=OBJQPDF.GETFORMFIELDTITLE(LNI)
  IF  NOT OBJQPDF.FLATTENFORMFIELD(LNI) = 1 THEN
      WSCRIPT.ECHO "ERROR WHILE FLATTENING THIS FORM FIELD '" + FORMFIELDNAME + "' ON " + ARQPDF,LNI
      WSCRIPT.QUIT(1)
  END IF
NEXT

================


Finally, questions are :

Is this PDF template (http://www.DES.online.unimep.br/au/pub/ag284d.pdf) wrong or, is there some problem on FlattenFormField function ?

Where does that empty form field comes from ? Cause it doesnt appear when I open the template using Acrobat Reader....

For those skilled with Adobe PROfessional, are there any tools on it that we can use to find out WHERE is the empty field on this PDF ?

Thanks in advance 4 your support !
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 07 at 2:20PM
This is the classic changing reference issue. As you flatten the fields, the internal reference numbers of form fields changes. What was FF1 no longer exists, so what was FF2 is now FF1, etc.

Simple solution is to FlattenFormField(1), instead of LNI. Another is to flatten in reverse order, from LNT to 1 step -1

Try this:


Option Explicit

Dim ObjArgs
Dim ObjQpdf
Dim ArQpdf
Dim Lni
Dim Lnt
Dim FormFieldName

Set ObjArgs=Wscript.Arguments

ArQpdf=ObjArgs(0)

Set ObjQpdf=Wscript.CreateObject("ised.quickpdf")

If Not Objqpdf.UnlockKey("MY_KEY") = 1 Then
    Wscript.Echo "could Not Unlockkey"
    Wscript.Quit(1)
End If

If ObjQpdf.LoadFromFile(ArQpdf) = 0 Then
    Wscript.Echo "could Not Load Template"
    Wscript.Quit(1)
End If

Lnt=ObjQpdf.FormFieldCount()

WScript.Echo Lnt & " fields found"

For Lni=lnt To 1 Step -1
FormFieldName=ObjQpdf.GetFormFieldTitle(Lni)
WScript.Echo Lni & Chr(9) & FormFieldName
If Not ObjQpdf.FlattenFormField(lni) = 1 Then
      Wscript.Echo "error While Flattening This Form Field '" & FormFieldName & "' On " & Arqpdf,lni
      Wscript.Quit(1)
End If
Next



Edited by chicks - 26 Nov 07 at 3:13PM
Back to Top
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Posted: 27 Nov 07 at 5:15AM
Thanks for your usual help Chicks.

I'm aware of the reference problem and on the REAL , PROduction server side code, it's done in reverse order.

However, back to this topic here, I'm curious about this :

Try to make the loop this way :

FOR LNI=1 TO LNT
  FORMFIELDNAME=OBJQPDF.GETFORMFIELDTITLE(LNI)
  WSCRIPT.ECHO "FIELD #",LNI,": '" + FORMFIELDNAME + "'"
  IF  NOT OBJQPDF.FLATTENFORMFIELD(1) = 1 THEN
      MSGBOX "ERROR WHILE FLATTENING THIS FORM FIELD '" + FORMFIELDNAME + "' ON " + ARQPDF
      WSCRIPT.QUIT(1)
  END IF
NEXT

It looks like after a while, all of the form fields will have a blank name.

Is it supposed to be like that ?

I'm doing it all cause I'm "lost" with a problem posted on another topic, where a damaged PDF is generated, that is, a PDF with wrong field contents....

Thanks again !
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 27 Nov 07 at 10:59AM
This is exactly the same issue. You are trying to get the name of fields that don't exist. After half the fields have been flattened, LNI will be greater than the number of remaining fields, so GetFormFieldTitle(LNI) will return null.

Try ObjQpdf.GetFormFieldTitle(1), which should work fine.
Back to Top
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Posted: 29 Nov 07 at 5:32AM
One more question 4 you Chicks :

You said you never had a problem with forms processing.

How do you design your templates ? Do you draw them in Word and convert them using Adobe PRO or do you use something else to design these templates ?
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 29 Nov 07 at 11:36AM
I've used FormMax for years with good results. Also use NitroPDF if needing to add form fields to an existing PDF.

BTW, AcroSoftware also has a form filling ActiveX component, but I haven't tried it.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store