Skip to main content
mariusyk17
Participant
May 3, 2017
Question

Dynamic barcode generation

  • May 3, 2017
  • 1 reply
  • 1167 views

I need to generate a PDF417 barcode image as PDF, given a certain value from a textfield.

I followed this thread (Is there not a method to add a barcode field via Javascript? ) and successfully added an image on a button, but I have to generate another image and then load it again on that button. Is there any way to generate an image using Javascript, without browser support, just the Adobe API?

This topic has been closed for replies.

1 reply

Joel Geraci
Community Expert
Community Expert
May 3, 2017

Assuming you are trying o generate a barcode "image" dynamically...

First create a hidden field that contains the value you want the barcode to represent. Then create a barcode field and put it where you want it to go. In the value tab of the barcode field, add the hidden field to the list and uncheck "include field names". To update the barcode to represent a new value, just set the value of the hidden field through JavaScript.

That said, you can create images using pure JavaScript but you can only use them in dialog boxes or tool buttons, you can't... or at least I haven't found a way to... get them into the document from there.

mariusyk17
Participant
May 4, 2017

"Then create a barcode field" - how may I do that? I already tried the following:

var f = newDoc.addField("textBC", "text", 0, bcCoords);

f.cFieldType = "barcode";

and

var f = newDoc.addField("textBC", "barcode", 0, bcCoords);

The "newDoc" object is the document I want to generate the image.
The first creates a normal text field, while the second shows only a blank, gray, readonly textfield.

I'm on the right track?