Skip to main content
Adobe Employee
April 11, 2016
Question

Programmatically populate image

  • April 11, 2016
  • 2 replies
  • 1338 views

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!

This topic has been closed for replies.

2 replies

Inspiring
April 12, 2016

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.

NKOWA555
Inspiring
April 12, 2016

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:

https://www.google.com/search?q=FDFSetAP

NKOWA555
Inspiring
April 11, 2016

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