I'm trying to generate some editable PDF using Java. For that I'm using the Aspose.PDF library (Aspose.PDF Java), which exposes some nice methods, which allow me to generate a document, like the one below, but only at runtime.
I need to know if there is a way to add (or edit) a TextBoxField barcode when the user fills the given text fields with data. I would like to use the text field validation event and regenerate the barcode, just like in the workflow described below.
Any suggestion would be appreciated!
Asked
Active
Viewed 763 times
0

Marius Cirstea
- 123
- 1
- 5
-
Dynamic barcodes in PDF are actually calculated text fields with special appearances. In order to give you an answer, I'll need to know if you want the text value of the barcode to be tab delimited or XML and if you want the field names to be included. – joelgeraci Apr 23 '17 at 19:04
-
Hei Joel, I don't need the text value to be displayed under the barcode. Can you provide me some hints for both situations (tab delimited/xml)? Also, it would be nice to include field names into generated barcode information. Thank you – Marius Cirstea Apr 23 '17 at 19:22
-
In order to accomplish this requirement, you can get user input, pass this information to Aspose.Barcode for Java to generate barcode image and then add this image to PDF file using Aspose.Pdf for Java. Please check https://docs.aspose.com/display/barcodejava/Set+Code+Text+for+Barcode and https://docs.aspose.com/display/pdfjava/Add%2C+Delete+and+Extract+Images+from+the+PDF+file#Add,DeleteandExtractImagesfromthePDFfile-AddImagetoExistingPDFFile – codewarior Apr 25 '17 at 19:20
-
Thank you for your reply @codewarior, but I need to trigger the generate and regenerate barcode events from Javascript. After the PDF document was generated with Aspose (PDF+Barcode), I won't be able to "touch" it. any idea? – Marius Cirstea Apr 26 '17 at 06:04
-
As per my understanding, you need to generate Barcode through JavaScript trigger/event ? Therefore you need the API to work with JavaScript. Please share the details, so I can comment further. – codewarior Apr 27 '17 at 04:33
-
Hello again, @codewarior. I went a little further and found a solution to generate a barcode as a byte array in Javascript. Now, I need to "draw" that byte array on the pdf dynamically (triggered by Javascript validation event). On the other hand I found out that I can't use trusted functions inside document JS. You can see that at [link](http://imgur.com/a/08g1F) – Marius Cirstea Apr 27 '17 at 07:09
-
Hi Marius, In order to add BarCode image to PDF file, first you need to save it in Image format and then use following code to add the image to PDF file using Aspose.Pdf for Java [Java] Document doc = new Document(); Page page = doc.getPages().add(); Image image = new Image(); image.getMargin().setLeft(100); image.setFile("c:/input.PNG"); page.getParagraphs().add(image); doc.save("c:/sample.pdf"); – codewarior Apr 28 '17 at 13:23
-
Hello again @codewarior, I need you to tell me if there is a way to generate a PDF417 barcode using the Javascript API provided by Adobe. I successfully managed to generate PDF417 barcode using Aspose.Barcode and then import the resulting image on a button field added dynamically with JS. Below is the workflow I want to achieve: I have a textfield A, a button B and another button BC. When I press the B button, I want to get A's value and then generate an image with a coresponding PDF417 barcode value, which I will then set as buttonIcon for the BC button. Thank you for your patience, Marius – Marius Cirstea May 03 '17 at 16:23
-
Hi Marius, as per my understanding, you have managed to accomplish the requirement of PDF417 Barcode generation using Aspose.Barcode and have been able to place the image as icon over button and now you are looking for same functionality using API provided by Adobe ? – codewarior May 04 '17 at 12:49
-
Exactly. Is anything I can do to generate the barcode with Java, when I click a button from Pdf (Javascript). Or is there a way to generate a barcode field directly from Javascript? I tried adding a field as text and then set it's cFieldType to "barcode", but nothing happened. Thanks – Marius Cirstea May 04 '17 at 13:41
-
Hi Marius, I am afraid Aspose.BarCode does not provide the feature requested above. But you can explore the Aspose,BarCode REST API and it can be useful. https://www.aspose.com/products/barcode/cloud – codewarior May 05 '17 at 20:42
-
Hi all, do you know any method of adding a PDF417 barcode into a form programmatically, using only Javascript? I tried the following https://jsfiddle.net/5wjdqL2t/ , but I only get a gray rectangle, saying "Barcode Render Error". Using the Prepare Form, I am able to insert a valid barcode and work with it, but I need to do that programmatically. Thanks – Marius Cirstea May 07 '17 at 10:03
-
Hi, If you consider using Aspose.Barcode, you can generate Barcode image and then add it to PDF file using Aspose.Pdf for Cloud API. Example code is shared over https://gist.github.com/aspose-pdf/12c062ac4f2dfa4cd833a5227405bb99#file-examples-dotnet-csharp-form-fields-updateformfield-1-cs – codewarior May 08 '17 at 20:53