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

Please I need help to generate new serial numbers on a form during each print

Explorer ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Please and please i need help getting my following attached adobe form on my PC to generate new sequential serial numbers on the specified "Ticket Number" field on the form during each print. I print lots of copies of this template, during the production, i want the form to be able to generate serial numbers on the specific field just like the illustration attached. say i send 1,000 copies of the form to print, the numbers should be generated accordingly till the last copy.

Please i will appreciate any support to this request. Thanks

ticket_printing.jpg

TOPICS
Acrobat SDK and JavaScript

Views

3.0K

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 ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Doing that requires using a script, and you can't use the Copies field in the Print dialog because that only prints identical copies of the file, so each print needs to be in a separate command.

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
Explorer ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Ok, thank you try67,

are you saying it can only work like the following?

ticket_printing_1.jpg

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 ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

It can work either way.

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
Explorer ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Ok try67, thank you very much for the response, please what do i do, what I really want to achieve is this: 

ticket_printing.jpg

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 ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

You'll need a script, to repeatedly set the numbers, then perform the print.

Do you want to write this yourself?  Start with the script that sets the numbers. 

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
Explorer ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Ok Thom_Parker, thank you very much,

yes, I want to write it myself please with some assistance:

The script in-quote, should this serve:

var f = this.getField("Ticket_No_1");
if (f.value=="") f.value = "0001";
else f.value = util.printf("%04d", (Number(f.value)+1));

 

etc.?

 

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 ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Yes, pretty much. Now just put it inside a loop from 1 to 1000 and add a print command after it.

You should read the documentation of this command so you can do it silently (otherwise you'll need to click OK 1000 times in the Print dialog)...

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
Explorer ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Ok, thank you so much try67, please, which particular command documentation are you referring and where can I get it. thanks.

 

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 ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

There is a "Doc.print()" function. It uses the PrintParams Object. You can read about it and see sample code here:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

You'll probably want to break the number filling and printing into chunks, so the print job isn't too huge. For example, 10 pages of tickets, send the print job, then refill the 10 pages and re-print, etc.

 

 

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
Explorer ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Thanks, Thom_Parker, i have been going through the documentation, but the whole thing is still not clear to me as to how i can implement the instructions to get specifically what I want. Please, if i can get a much plainer example, I will be very grateful, I really need to do this. Once again, thank you so much for your time. It really meant so much to me right now.

 

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
Explorer ,
May 10, 2020 May 10, 2020

Copy link to clipboard

Copied

Hello, guys am still not sure of how to go about this, I am confused, please i help here. can someone please help me out, i really need this now, this is what i did, 

Capture6.JPG

and i did it with this scripts:

var f = this.getField("Ticket_No_1");
if (f.value=="") f.value = "0001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_2");
if (f.value=="") f.value = "0001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_3");
if (f.value=="") f.value = "1001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_4");
if (f.value=="") f.value = "1001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_5");
if (f.value=="") f.value = "2001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_6");
if (f.value=="") f.value = "2001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_7");
if (f.value=="") f.value = "3001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_8");
if (f.value=="") f.value = "3001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_9");
if (f.value=="") f.value = "4001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_10");
if (f.value=="") f.value = "4001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_11");
if (f.value=="") f.value = "5001";
else f.value = util.printf("%04d", (Number(f.value)+1));

var f = this.getField("Ticket_No_12");
if (f.value=="") f.value = "5001";
else f.value = util.printf("%04d", (Number(f.value)+1));

 

but when i send to print, like i sent print 10 copies of this very page from the same acrobat page, it all came back the same, all 10 copies the same, not changing the numbers serially as i expected,

 

while in the real sense, what i want to achieve is to be able to send this singular page to print:Forms_Print0.jpg

and it will print the first page as above and subsequent page with the increasing numbers until the end of the sent number of copies like the following:

Forms_print.jpg

please i need help to get this done, i will really appreciate help here, thanks.

 

 

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 ,
May 10, 2020 May 10, 2020

Copy link to clipboard

Copied

Again, you can't us the Copies field of the Print dialog to do it. You need to do it using a script that both sets the fields and prints the file in a loop.

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
Explorer ,
May 10, 2020 May 10, 2020

Copy link to clipboard

Copied

Thank you so much try67 for writing me back, like i said in my other post, i have decided to unify the values per page, in the following manner:

 

Forms_Mo_A.jpg

so that when it prints it give output the pages in the same following incrementing orders:

 

Forms_Mo_B.jpg

Now, this is what i have been able to come up with, i just want you to help me check possible what is wrong here with my code.

 

var start = 1;
var doc = this.getPrintParams();
var total = 10;
var printed = 1;
doc.interactive = doc.constants.interactionLevel.silent;
doc.printerName = "hp officejet d series";

var tokets = [
[
this.getField("Ticket_No_1"),
this.getField("Ticket_No_2"),
this.getField("Ticket_No_3"),
this.getField("Ticket_No_4"),
this.getField("Ticket_No_5"),
this.getField("Ticket_No_6"),
this.getField("Ticket_No_7"),
this.getField("Ticket_No_8"),
this.getField("Ticket_No_9"),
this.getField("Ticket_No_10"),
this.getField("Ticket_No_11"),
this.getField("Ticket_No_12")
]
];

while(printed <= total ){

for (var i = 0; i<tokets.length; i++){
for(k in tokets[i] ){
tokets[i][k].value = util.printf("%04d", start);
}
start++;
}
this.print(doc);
printed++;
}

 

Thank you.

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 ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

Not bad,  here's a correction

 

var start = 1;
var doc = this.getPrintParams();
doc.interactive = doc.constants.interactionLevel.silent;
doc.printerName = "hp officejet d series";

for(var nSheets = 0;nSheets<10;nSheets++)

{

   for(var i=1;i<=12;i++)

      this.getField("Ticket_No_" + i).value = util.printf("%04d", start++);

 

   this.print(doc);

}

 

you could even make it simpler by using group field naming.  

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
Explorer ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied

Thank you so much Thom_Parker, but the guide above you provided numbers every Ticket No field in the page differently, the 12 fields were numbered from 1-12, giving the following output:

send 5.JPG

while what i actually want is uniform numbers per page but increasing in value per print copy, which will give me this: 

Forms_Mo_A.jpg

Forms_Mo_B.jpg

this very following scripts has achieved that for me on my small printer:

 

var start = 1;
var doc = this.getPrintParams();
var total = 100;
var printed = 1;
doc.interactive = doc.constants.interactionLevel.silent;
doc.printerName = "Brother MFC-9140CDN Printer";

var tokets = [
[
this.getField("Ticket_No_1"),
this.getField("Ticket_No_2"),
this.getField("Ticket_No_3"),
this.getField("Ticket_No_4"),
this.getField("Ticket_No_5"),
this.getField("Ticket_No_6"),
this.getField("Ticket_No_7"),
this.getField("Ticket_No_8"),
this.getField("Ticket_No_9"),
this.getField("Ticket_No_10"),
this.getField("Ticket_No_11"),
this.getField("Ticket_No_12")
]
];

while(printed <= total ){

for (var i = 0; i<tokets.length; i++){
for(k in tokets[i] ){
tokets[i][k].value = util.printf("%04d", start);
}
start++;
}
this.print(doc);
printed++;
}

 

But then i met another challenge, given that because of the large quantities of the tickets involved, the tickets will be produced with a larger industrial Digital Printer, like Konica Menolta, these printers come with a print-request-processing-screen with them, now while my above scripts were targeted at printing directly from my computer to the printer without further processing. when this print request is sent from the computer to this industrial printer, instead of printing them directly, as it did with my small office printer, it will collect the print request page after page and you will be required to authorize the printing of each page. this whole process greatly slows down the printing speed and engages lots of supervisions and instead of like 60sec. each print request will take between 15mins - 30min to print.

 

My current challenge is this, is there a way, since i can connect a pen-drive directly to the printer-screen and print from the screen without opening the document, is there an instruction i can embed on the Adobe Acrobat document on the pen_drive to print using above script and achieving the above result and all that will be done by authorizing the printing from the screen without opening the document, as the printer's-screen does not have the option to view the document on the screen before printing 

 

Please i will appreciate any support in getting this done.

 

Thanks

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 ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied

First, there is no reason for the double loop in your code. The code I provided only needs a small adjustment to accommodate the increment per print. 

 

As for the Minolta printer issue. This is outside of Acrobat, so no, the script won't work. However, you many have another option. commercial printers like this one often allow for print control and postscript injection through an API.  Or the have full postscript processors. If this is the case then you can inject postscript that will produce the auto increments on a single print with multiple copies. To do this you'll need access to a programmer that has intimate knowledge of your particular printer. Try contacting Minolta and their forums. 

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
New Here ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied

Deoptic,
Maybe you could print locally first by selecting a pdf printer (such as doc.printerName = "Adobe PDF"), which quickly generates a pdf for you. Then print this pdf (flat) on the industrial printer. Printing on paper should be fast.

Tip: rearrange your code with Thomp's correction.

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 ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied

Not that quickly, as you'll need to manually enter the name for each file...

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
New Here ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied


hi try67,
but I understand that you can send silently to the printer to avoid asking for the file name.
Returning to the Thomp correction:
var start = 1;
var doc = this.getPrintParams ();
doc.interactive = doc.constants.interactionLevel.silent;
doc.printerName = "Adobe PDF";
doc.bUI = false;
doc.bSilent = true;

for (var nSheets = 0; nSheets <10; nSheets ++)
{
   for (var i = 1; i <= 12; i ++)
      this.getField ("Ticket_No_" + i) .value = util.printf ("% 04d", start ++);
      this.print (doc);
}

Before, "Adobe PDF" printer can be configured to indicate the path and not open the printed pdf.
With several printed pdfs you can use binder.

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 ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied

No, you can't do that.

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
Explorer ,
May 17, 2020 May 17, 2020

Copy link to clipboard

Copied

LATEST

Am so sorry, i have been away for some time, thank you so much for all the responses i got from those posts, i so much appreciate everyone that tried to help me figure out how to go about those challenges i pointed out up there. Thanks a million, times.

I actually have not been able to figure out how to print my adobe acrobat pdf file from my pen-drive without opening the file, as the need with my last post demands, however, i am currently trying to work out a way to still print my file with the industrial printer, but getting the printer to auto-execute those printing without waiting for my authorization. If i can get that done when i resume work tomorrow, i will just have to deal with the slow process, for now, hopefully, in the future, i will be able to get a way to print the document without opening the file. 

Once again, thank you, everyone, for all the assistance you provided me.

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