Copy link to clipboard
Copied
Hi,
I am going to create a template where i need to have a barcode place holder and this place holder will be replaced with the actual value during the java program execution(Using PDFBOX ).But i am unable find how to place a barcode(code 128, code 93) place holders in adobe pro dc. Could you please help me how to achieve this functionality using pro dc?
Thanks
Venkata
Copy link to clipboard
Copied
Copy link to clipboard
Copied
moving to JavaScript
Copy link to clipboard
Copied
This information is about 2D barcodes - there is no support for 1D barcodes (which Code 93 and Code 128 are) built into Acrobat - and for a good reason: You just get the appropriate font and then create a normal text field that uses that font and assign a value to the text field - this will result in the barcode being displayed on your PDF page.
Copy link to clipboard
Copied
Hi All,
Thanks for your valuable information. I tried the way Karl suggested like creating a text field and adding font as code 128 to text field control.Finally reading the text field control from in java code like below, (I have already uploaded code 128 font into windows/fonts folder)
...
PDField mybarcodeField = form.getField("pobarcode");
mybarcodeField.setValue("123456");
fields.add(mybarcodeField);
It seems this approach is not working. Is there any other approach you can suggest me?
Copy link to clipboard
Copied
Can you please be more specific: What exactly is not working? What happens when you set the field's value? Do you see text? Do you see a barcode, but it's wrong? Does the field not change?
Copy link to clipboard
Copied
The "PDF barcode form fields" article is irrelevant for this issue here, because it covers only 2D-barcodes. And it also has nothing to do with JavaScript (but good for you, as JavaScript is one of the forums I follow).
1D barcodes can be represented with special fonts, and therefore, you would find a font for your symbology, set up a regular text field, specify the font, and then have your logic add the right string; depending on the symbology, you may have to do some fine-tuning.
Hope this can help.
Copy link to clipboard
Copied
It is showing the actual text value (123456 ) in the pdf. The text field is not showing the barcode.
Copy link to clipboard
Copied
You need to set the field's text font to the barcode font...
Copy link to clipboard
Copied
Yeah i already set the text field font as barcode font (Code 128)
Copy link to clipboard
Copied
You're saying you're using java. What exact library are you using to do this?
Does it work if you edit this field's value in Acrobat using JavaScript? If so, it might be that the "NeedsAppearances" flag needs to be set, to force the field's contents to be refreshed when the file is opened.
Copy link to clipboard
Copied
I am using PdfBox java library. I am not sure how to use javascript in the text field control. I tested initially without java program like this. But in that case also the text field is not showing the barcode. The steps are 1 . Created A pdf template 2. Click the tools section and intern clicked prepare form 3. Drag the text control. 4. Edit the text field and gave the General tab property name as 'pobarcode' 5.In appearance tab selected font as Code 128. 6. Options tab, given a default value for testing "123456".7. Saved the file.
Copy link to clipboard
Copied
This is not really the place to discuss PDFBox. I recommend StackOverflow or the PDFBox mailing-list (users@pdfbox.apache.org).
If the field didn't work in Acrobat, though, then there might be something wrong with the font you're using.
Copy link to clipboard
Copied
Yes. you are right. i was using corrupted code 128 font it seems. i have uploaded a new copy of code 128 font into the windows/fonts directory. Now i am able to see the barcode. Thanks for your help.
Copy link to clipboard
Copied
Hi,
I have created a barcode by setting text field and adding the font as code 128 to it (As mentioned earlier). The pdf is showing the barcode .But the problem is, the scanner unable to scan it. Could you please let me know is there any extra settings i need to set in text field control?
Copy link to clipboard
Copied
You will have to go through the literature to learn how the string for Code 128 has to be structured. Most likely, you will have to add a special character at the begin and the end of the string.
If the font came with documentation, have a closer look at it.
Copy link to clipboard
Copied
Code 128 has a mandatory checksum that must be calculated, then included in the string.
Copy link to clipboard
Copied
You can find out more about the start/stop characters, the checksum and the "quite zone" around the barcode on the Wikipedia page about Code 128: Code 128 - Wikipedia, the free encyclopedia
I've used that information in the past to create barcodes that were accepted by a number of different barcode readers.
Any time you are trying to create a barcode, you need to be familiar with all the requirements imposed by the code. Wikipedia is usually a good start to get an idea about what needs to be implemented. Sometimes you actually need to acquire the standards documents, or whatever official document describes the code. The Wikipedia article usually points to that document.