Copy link to clipboard
Copied
I'd like to know how to detect and create barcode fields with JavaScript.
The documentation does not mention a "type" barcode:
Valid types are:
button
checkbox
combobox
listbox
radiobutton
signature
text
And using this script in the console returns: "text"
console.println(this.getField("Barcode1").type);
How to know if a field is a "barcode" field, and how to create one?
Thank you
Barcodes are one of those special (enterprise level) money makers for Adobe. If they really wanted to make a general purpose barcode field, they would have done just that, instead of perverting the text field and blocking use of it in Reader.
But, because barcodes require a special diversion of the text field to a different field handler, several of the standard text field properties are missing from barcode fields, such as "multiline" and "comb". You can use this to detect barcode fields, i.
...Copy link to clipboard
Copied
A barcode field *is* a text field. Its additional properties (e.g. PMD dictionary) are described in here: https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/adobe_supplement_iso32000.pdf
I rather doubt that JavaScript can see or change the PMD properties needed.
Copy link to clipboard
Copied
Barcodes are one of those special (enterprise level) money makers for Adobe. If they really wanted to make a general purpose barcode field, they would have done just that, instead of perverting the text field and blocking use of it in Reader.
But, because barcodes require a special diversion of the text field to a different field handler, several of the standard text field properties are missing from barcode fields, such as "multiline" and "comb". You can use this to detect barcode fields, i.e. a text field that throws an exception "InvalidGetError" for the "multiline" property.
Of course Adobe could change this at any time, so it is a rather tenous methodology, but so are most things in Acrobat JavaScript 😉
There is of course, no way to create barcode fields with JavaScript. All Adobe would have to do is add a new values to the style property for the type of barcode, and you could reliably create and detect text fields.
Copy link to clipboard
Copied
Just a small addendum: If the kind of barcode you want to use has a 1D symbology then you can easily do it with a "normal" text field. You just need to install a font that contains this symbology (like 3-of-9), and then set it as the field's font, and apply a value to it. The nice thing about these fields is that they can be easily edited in Reader, unlike the built-in "barcode" fields, which require a very special (read: expensive) right to become editable in Reader.
Copy link to clipboard
Copied
Detecting is not a real issue since I can read "barcode" or "codebarre" into field's name.
The main goal was to create a barcode field (QRcode). And so, too bad…
Many thanks to the 3T team (Test, Thom and Try67)
😉