Copy link to clipboard
Copied
Hi
I need to generate a pdf with some text fields and image that will be assigned values programmatically on the server. While I can use an open source software to generate the fdf for text fields, how do I assign an image to a form field? I believe I can have a button with Icon only, but what's the fdf format for setting a new image on this button?
Help much appreciated!
Thanks!
Copy link to clipboard
Copied
Acrobat forms can't import images using the FDF format; but, LiveCycle XFA PDFs can import images using XDP form data format.
To manipulate and generate XDP files you can use FDFToolkit.net for ASP.net 2.0+.
www.fdftoolkit.net
Copy link to clipboard
Copied
It is possible to set button icons via FDF, but it's not all that easy. The (unsupported but still available) FDF Toolkit includes to methods for doing so: FDFSetAP and FDFSetAPRef
The first included all of the icon data in the FDF given a page from a PDF as a source. The other method is simpler, but again uses a page from a PDF as the source that must also be a page template. For the latter, the PDF that contains the template has to be accessible to the user since only a reference to it is included in the FDF. In the case of JPEG images, it's not too difficult to programmatically generate a valid FDF that sets a button icon to the image. Other formats require more work and it would be a benefit to use a PDF library to help out. The PDF Specification is a good place to begin learning about button appearances (aka icons) and the FDF Toolkit is still useful for generating valid FDFs that you can learn from.
Copy link to clipboard
Copied
Thank you for the insight! It seems you are correct, there may be a way to change a button's icon using Adobe's FDF Toolkit:
Here's some sample code I found online for FDFSetAP:
http://forum.planetpdf.com/wb/default.asp?action=9&read=61484&fid=5
Dim objFDFApp As FDFACXLib.FdfAppClass
Dim objFDFDoc As FDFACXLib.FdfDoc
objFDFApp = New FDFACXLib.FdfAppClass()
objFDFDoc = objFDFApp.FDFCreate
objFDFDoc.FDFSetFile("http://testsite/PDF/form.pdf")
Const FDFNormalAP As Integer = 0
objFDFDoc.FDFSetAP("icon1",FDFNormalAP, "F:\Icon\icon.pdf", 1)
Response.ContentType = "application/vnd.fdf"
Response.BinaryWrite(objFDFDoc.FDFSaveToBuf())
Visit the following website for more information on FDFSetAP:
Copy link to clipboard
Copied
Here's a classic ASP example using Adobe's FDFToolkit:
Note: The code executed correctly when testing the script and outputted the FDF, but I couldn't get the FDF to load the PDF correctly in Adobe Reader; so I don't know if it 100% works:
Note: Adobe's FDFToolkit requires special server setup and installation, and you may need to login as an Admin to your server to modify the registry and register the DLLs; so it may not work on 3rd party hosted websites.
<%@ Language=VBSCRIPT %>
<% Option Explicit %>
<%
On error resume next
Dim FDFAcx, FDFout
Response.Clear
Response.ContentType = "application/vnd.fdf"
Set FdfAcx = Server.CreateObject("FdfApp.FdfApp")
Set FDFout = FdfAcx.FDFCreate
FDFout.FDFSetFile "http://localhost:5551/pdf.pdf"
FDFout.FDFSetValue "TextboxField_BD7", "FDFToolkitTest"
'icon1 = name of button with icon only set
'"D:\Data\submit.pdf" = path to icon that populates icon1 button
FDFout.FDFSetAP "icon1", 0, "D:\Data\submit.pdf", 1
FDFout.FDFSetStatus "Icon loaded"
Response.BinaryWrite FDFout.FDFSaveToBuf
FdfAcx.Close
Respone.End
%>
Find more inspiration, events, and resources on the new Adobe Community
Explore Now