0

How can I add PDF417 2-D barcode (as an image) to a Acroform PDF?

  • I have a process in place where I populate a PDF "templates" with data using a XFDF file that I build server side. Staying in the same workflow, I'd like to either use XFDF or FDF files to add a barcode to the PDF.

  • I'm using full-stack JavaScript environment, where the Nodejs environment runs server side. I'm using PDFTK Server (JavaScript on the server calling out to a PDFTK.exe).

  • I can use any tool/technique within my technology stack (Nodejs/Javascript). Also, this solution must work server side only.

  • The PDF "template" currently uses a Adobe Lifecycle "Paper Forms Barcode" control for the barcode. When we fill this PDF form out with data manually, the XFA script embedded within the PDF automatically populates the "Paper Forms Barcode" control with the PDF417 barcode.

  • When I run PDFTK Server's form fill command to populate the PDF with the XFDF data I build server side, I believe the XFA (and hence any intelligence behind the "Paper Forms Barcode" control) is automatically removed from the resulting output PDF.

  • I can optionally remove the "Paper Forms Barcode" control and use any other control available.

  • pdf417-js seems to get my close to building a PDF417 barcode, but it's client side. And also, I can't see a way to build an image output.

  • From my research it seems I might need to remove the existing "Paper Forms Barcode" control and add an image somehow to the PDF. Then possibly use PDFTK to somehow merge a PDF that I have filled with data from my existing process with another PDF that simply has the barcode.

  • I never seen an example of XFDF or FDF inserting an image into the PDF. I've read where one can dynamically add an image (icon) to a button control via FDF (I've found no hard example of this), but haven't been able to get anything working.

Aaron
  • 3,068
  • 2
  • 21
  • 44

2 Answers2

1

FDF does support inserting images as icons into Button fields. I am, however, not sure whether XFDF does it. You may have to convert the image into PDF format.

For an industrial-strength use, you might consider dedicated tools, such as FDFMerge by Appligent (which would also allow to selectively flatten the barcode field (and others too)).

Max Wyss
  • 3,549
  • 2
  • 20
  • 26
  • I tested this with a Acroform PDF. I placed a button on one of the forms we use and set the attribute layout "icon only", and chose an icon (test.jpg) from my filesystem. I saved and did an export to both XFDF and FDF. The button was not in the output of either file. – Aaron Apr 30 '16 at 22:32
  • will you kindly remove your answer because I'd like to delete my question as I have received multiple negative reviews of it. – Aaron May 01 '16 at 04:22
  • The image is not exported; you'd have to look at the FDF specification (which is part of the PDF specification) for the complete set of commands. – Max Wyss May 01 '16 at 08:20
  • Don't bother about some downvotes. There are a bunch of ignorant idiots hanging around here downvoting any question concerning PDF/Acrobat and JavaScript. I can't name them, but I find many such questions downvoted. Otherwise, it would be a moderator who could delete the whole question at your request. – Max Wyss May 01 '16 at 08:21
  • So the path to putting an image into a pdf via FDF is not through somehow populating an image control, but through a icon on a button? – Aaron May 04 '16 at 20:46
  • 1
    @Aaron: this is correct. PDF forms do not know about an image control. There is a possibility to insert images, using libraries, but in this case, the image has to be completely rendered before it can be inserted. – Max Wyss May 04 '16 at 21:21
  • Thanks @MaxWyss, but do you have an example, I can't get it working properly? – Aaron May 10 '16 at 18:46
  • You're welcome, @Aaron, unfortunately, I don't have anything at hand just so. – Max Wyss May 11 '16 at 00:15
1

Both FDF and XFDF support adding images to PDF pages. Some background first, Adobe Acrobat and Reader can submit form data as well as comment annotations. It can also import form data as well as comment annotations. Therefore, FDF and XFDF can represent both form data and comment annotations.

Images can be added to a PDF via FDF or XFDF by representing them as a stamp annotation. Acrobat can certainly import these but most server tools don't know about the <annots> element of the XFDF and even if they did, they generally can't create an annotation appearance based on the annotation properties. One can; the Datalogics PDF Java Toolkit is capable of importing XFDF with stamp annotations.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
joelgeraci
  • 4,606
  • 1
  • 12
  • 19