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

Using VBscript to print pdf-files

koen.daamen
Registered: Feb 4 2010
Posts: 5

L.S.

I work for a large primairy school. Every week we publish a newsletter, which we only give to the eldest-of-kin for environment reasons (as well as reducing printing costs.) Since every class has a different number of children, I wrote a visual basic script to check a CSV file for the number of copies per class to print.

Now I could print like:

for x=1 to NumberOfChildrenInThisClass
print "Path\Document.pdf"
next

but then my printer buffer would be swamped. (We have more than 850 children.) Is there a way to print multiple copies of a pdf file in order to do it "right"? I.E.:

print "Path\Document.pdf", NumberOfCopies

Does anyone know how to do this (in either VBscript, javascript or PHP)?

I have a working program to print .doc files (see excerpt below), but I also want to be able to print PDFs.

Thank you for much in advance for any advice you can offer, Koen

_______

set oWord = createobject("word.application")
set oDoc = oWord.documents.open("c:\PrintFolder\FileToPrint.docx")
oDoc.printout ,,,,,,,NumberOfCopies
oDoc.close
set oDoc = nothing
oWord.quit
set oWord = nothing

My Product Information:
Reader 9.2, Windows
JohnnyRiv
Registered: Dec 2 2008
Posts: 9
Koen, I was wondering, is the newsletter generated from Microsoft Word? If so, maybe you can perform a mail merge?

Then from the mail merged PDFs you can print or email them.

Johnny

Acrobat 5, 6 Pro, 7 Pro, 8 Pro, 9 Pro Extended, LC 7, 8 & LC ES 8.2

koen.daamen
Registered: Feb 4 2010
Posts: 5
Hi JohnnyRiv,

Thank you for your reply.

No, the newsletter is not generated from Microsoft. But it might be an option to use that function. ... Googling --- Testing --- ...

Alas, a mailmerge merges all the prints in 1 Document. So, as an example, the whole lot of 15 sets of a 3 page document is stapled together as 1 (consisting of page 1,2,3,1,2,3,etc to 15x).

Thank you for the idea, at least!

Perhaps there are other methods of print job handling? At least to print pdfs?

Thanks again, Koen
JohnnyRiv
Registered: Dec 2 2008
Posts: 9
Hi Koen,

If you generate a single PDF from the merge & need to break it apart into separate PDFs you can try using the following JavaScript batch sequence to extract the sets./* Extract Pages to Folder */
var re = /.*\/|\.pdf$/ig;

// filename is the base name of the file Acrobat is working on

var filename = this.path.replace(re,"");
var pgNum = app.response({ cQuestion: 'Enter the number of pages in resulting pdf files', cTitle: 'Number of Pages'});

try {
for ( var i = 0; i < this.numPages; i+=pgNum)
this.extractPages
({
nStart: i,
nEnd: i+pgNum-1,
cPath: "/C/data/temp/"+filename+"_" + ((i/pgNum)+1) +".pdf"
});
} catch (e) { console.println("Aborted: " + e) }

Hope this is helpful.

Johnny

Acrobat 5, 6 Pro, 7 Pro, 8 Pro, 9 Pro Extended, LC 7, 8 & LC ES 8.2

koen.daamen
Registered: Feb 4 2010
Posts: 5
Hi Johnny,

I'd like to apologise to you, for not replying to you sooner. My work hours are very erratic, resulting in irregular visits to this site. Thank you for taking the time to help me with my problem.

The script looks very nifty (I'm bound to use this trick one day for some other problem) but wouldn't it result in 850 separate pdfs? (Assuming that I need to print a newsletter for 850 children?) Therefor swamping the printer-buffer --- which I intent to prevent?

And how can I print a pdf using javascript, VBscript, php, or any other scriptlanguage?

Perhaps it's best to rephrase my original problem: I need to print a pdf-file and bundle them in sets of varying numbers, depending on the classroom-size. (Classroom A has 21 children, B has 18, etc.) Is there a way to use a scriptlanguage (whichever) to print a single pdf-file (which may consist of any number of pages) a couple of specified times (stored in a csv-file) without resorting to a for-print file-next-loop? I.E.: print "file.pdf", numberOfTimes.

Thank you for any advise or help you can offer me, Koen

PS I found a link which might be interresting for people who would like to mail merge to separate files:
http://www.gmayor.com/individual_merge_letters.htm
JohnnyRiv
Registered: Dec 2 2008
Posts: 9
Hi Koen,

I guess I am confused. Are you trying to print to paper or to PDF? I don't understand the bundle you speak of?

Johnny

Acrobat 5, 6 Pro, 7 Pro, 8 Pro, 9 Pro Extended, LC 7, 8 & LC ES 8.2

koen.daamen
Registered: Feb 4 2010
Posts: 5
Hi Johnny,

Oops ... I meant printing a pdf-file to paper. The bundling is done by the machine (it's an industrial copier with printing function.)

The end result will be something like:

1) script reads csv file with the number of classrooms and number of children in each classroom
2) script prints a seperate blue sheet with classroom identifier (classroom A, classroom B, etc)
3) script prints a pdf-file X times according to the amount of children in the current classroom
4) repeat steps 2+3 till all number of classrooms are done
5) printer does its job, bundling each stack of paper, so that when I return to the printer, all I need do is pick up all separate bundles and distribute them

(So in the copier I will find X stacks of paper (for each classroom a stack), each seperated by a blue sheet with the classroom identifier printed on it.)

My problem is: how do I achieve step 3, using a script-language (either javascript, vbscript, perl, php, or any other)

Kind regards, Koen