• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Detect and create barcode fields with JavaScript

Community Expert ,
Nov 08, 2019 Nov 08, 2019

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

TOPICS
Acrobat SDK and JavaScript

Views

856

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 08, 2019 Nov 08, 2019

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.

...

Votes

Translate

Translate
LEGEND ,
Nov 08, 2019 Nov 08, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2019 Nov 08, 2019

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.  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2019 Nov 08, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 09, 2019 Nov 09, 2019

Copy link to clipboard

Copied

LATEST

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)

😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines