These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Duplicate Barcode

libraboy
Registered: Dec 14 2007
Posts: 94

Hi,

Is it possible to duplicate barcodes using javascript? Please let me know

thanks

My Product Information:
Acrobat Pro Extended 9.3.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Why yes it is. The value of a barcode field is text. All you have to do is transfer the text

this.getField("barcode1").value = this.getField("barcode2").value;

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Hi Thomp,

Thanks for your reply... I've tried your code and seems like it not working. I am using windows acrobat 9.0 profesional. Where I should put this code? I tried inserting this code everywhere and no luck.

this.getField("img_barcode").value = this.getField("img_barcode2").value;

Please advice...

P.S. By the way i am using fill able form.

Thanks,
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The problem with barcode field's is that they have some internal handling mechanism that wants to automatically set the value of the field. To set the field manually you have to either use this mechanism to your advantage or turn it off.

so there are 2 ways to copy the value from one barcode field to another.

1. Set the calculation script of the target field to this:

event.value = this.getField("img_barcode2").value;

This continously copies the value of "img_barcode2".

2. Set the calculation script of the target field to this:

event.rc = false;

This effectively turns off the automatic barcode handling mechanism so that it can now be set manually with this code:

this.getField("img_barcode").value = this.getField("img_barcode2").value;

The idea here is that you can set the barcode based on some trigger of your choosing. As opposed to the first method which copies the barcode continously. Where you put the code depends entirely on when you want the barcode value to be copied.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Hi Thomp,

I dont know for some reason the code still not working. I am a newbie about javascript can you be able to guide me?

thanks
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Lets do a test.

1. Create a new blank PDF. Add one text field and two barcode fields to it.
Lets call the first barcode field "Bcode1" and the second one "Bcode2".
2. In Bcode1 open the properties dialog and select the "Value" tab.
Pick the text field as the value for the barcode.
3. In Bcode2 open the properties dialog and select the "Value" tab.
Select the custom calculation script and then "Edit"
4. Delete everything in there and replace it with this single line of code

event.value = this.getField("Bcode1").value;

The name of the first barcode field must be "Bcode1"

5. Now anytime you enter data into the text field both barcode fields will show identical patterns.

Once you get this working, and not before, you are ready

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
https://acrobat.com/#d=WIN8HjNVo7flR3QeK6ADrA

https://acrobat.com/#d=seLF*cVG1IROEXBbAIfBxw

Hi Thomp,

Please see my samples. Still now working..

thanks
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The test file I asked you to create was done incorrectly. A barcode cannot use itself as in input. This creates an infinate loop, very bad. You also should not use other barcode fields as input. The instructions were to set it to use only the text field as input. Try this again.

The other file you send does not contain a single barcode field. They are plain text fields. The form stated that a barcode image in the document was created by some program. What program, and what does this have to do with barcode fields? The barcode on the document is content. It is not accessible through scripting.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Hi Thomp,

I got your instruction and working fine. Sorry to tell you this that's not what I want :( The text field was generate by our program when we printed invoice. We are using 3 part NCR right now and want to eliminate using NCR by using pdf. For that PDF I want to have Original, Copy and Customer Copy and I want that barcode generate by the program to be copied on COPY pdf. That's why I had two textfields on the other pdf called img_barcode and img_barcode2. Please advice if this is do able.

thanks
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So the barcode is content, i.e., the program that generates the PDF does not place the barcode in a field. If this is true then copying the PDF will copy the barcode because it's part of the page content.

I have to say that I dont' have a very clear idea of your process. Please provide some more explaination.

I think you have a good idea, but to get a handle on it you'll need to learn a bit more about how Acrobat and PDF work.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Hi Thomp,

Okay to make more easy, I have 1 PDF and two spawn templates.

Main PDF its called ORIGINAL and the other two are called Original Copy and Customer Copy. Now, in the ORIGINAL PDF we have a barcode generates by the program using textfield and I want to duplicate that barcode into Original Copy only.Is this all make sense? So, is that possible? Please advice

thanks,
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If the barcode is PDF content is, as in the sample you sent, then using a script to copy it to another PDF is possible, but not easy. If however the barcode really is on the text field, and the appearance is created using a barcode font. Then it is possible to copy using regular form field operations.
You can test to see whether the barcode is content or on the field by simply moving the text field. If the barcode moves then it's on the field, if it doesn't then it's content.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
I will try that on Monday Thomp. Thanks for your reply. If is not possible I have another idea don't know if is possible. I am thinking of use just one PDF but when I hit print it should print 3 copies with different title name like ORIGINAL, AG COPY and CUSTOMER COPY would it be possible? Is there any javascript that can do that? Please advice

Thanks,
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, you can use a form field to vary the title. This would be much, much easier than copying the barcode into different documents.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Can you please give me the code how to do that? I think I have to go with that option then. Please Thomp provide me some example or script how to do it.

thanks
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
One way to do it would be to place 3 radio buttons on the form. One for each Title. Set the options for these buttons so that they do not print. Use the "MouseUp" event in each to set the title:

this.getField("Title").value = "Copy";

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Hi Thomp,

Thanks for your reply I will going to try that script but how can I set print silent and print 3 copies without the dialog box?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Silent printing can only be done from an automation script. And, if you are going to go that route you should set the title in the automation script.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Hi Thomp,

The script is not working. I made 3 radio buttons and named them Original, AG Copy and Customer Copy by changing the title name with name above still doesn't work. Can you please be more clear when you give instructions? I am newbie with javascript.

thanks thomp!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
What exactly is not working? What are the details of how you implimented the script.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Like I explain to you in my previous email, I made 3 radio buttons but when I print 3 copies no title name is printing. Yes Thomp the barcode in the textfield is not movable. I guess printing the title name for the PDF is the only option right now. Can you be able to provide me some sample Thomp? Please
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So did you place any scripts in these radio buttons? On what event and what scripts?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Please Thomp see my sample https://acrobat.com/#d=w0FW-FSFqzbse8HRAXN7DQ

thanks,
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Looks like it works perfectly fine to me. Select a radio button and then print. If you want to print all 3 at once you'll need to write an automation script, as I explained earlier.

I won't be writing the code for, or even explaining how to write such a script. You'd need some Acrobat scripting experience to do this. I suggest you post a request on the job board.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

libraboy
Registered: Dec 14 2007
Posts: 94
Well I guess I would just say thank you then... I'm not gonna spend 10 or more hours just to search this forum. The reason I posted so someone can help me with my problem but it was all wasted.