Search code examples
ruby-on-railsadobeqr-codepdftk

PDFTK - generate a QrCode using Adobe PDF barcode form field


I'm using pdftk for a while to fill form embedded in some Adobe PDF. For now the use of json data through fill_form method(of pdf-forms gem) was great.

A while ago I heard about Barcodes/QrCodes field in Adobe PDF forms. And that is a good idea but I didn't achieve to generate a Qrcode from a JSON data parameter.

Here are my tries :

  • giving a Base64 string to the field
  • giving a string to the field
  • giving a PNG file to the field
  • switching between Code with format and Script value parameter. (for each previous test)

Before you answer I prefer not to choose the solution to generate a separate PDF file with the generated QrCode and merge it on the right place on the right page of my final PDF.

Is someone succeeded to do this ?

Should I rather take the option of Image field ? If yes, could it be explained ?

Thanks a lot if you have an answer !!

Have a nice day


Solution

  • If you are referring to the kind of barcodes that are generated from data in other fields with JavaScript embedded in a PDF, it will not work because pdftk does not do JavaScript. Nor it does image fields. I am afraid that your choices are to look for another tool (iText, maybe?) or to go with the solution you dislike. Or maybe, if you are willing to use a different barcode format, then this question How can I inject a dynamically generated image (barcode, as it happens) into a PDF document (I'm in rails if that matters)? could help.