I, trying to calculate all pagesizes of either
* a single multipage PDF
* a single onepage PDF
* a folder containing one or both of the above
then writing a log-file of all pages in ONE csv (using the job-folder name or in case of a single pdf just the nameproper of that pdf)
with only one single pdf it works using scripter, but only first page calculated:
Code: Select all
function jobArrived( s : Switch, job : Job )
{
var outPath = s.getPropertyValue("LogPath")+"/";
var jobName = job.getNameProper();
if(job.isType("pdf")) {
//Get NumberOfPages
pdfPages = job.getVariableAsNumber("[Stats.NumberOfPages]");
s.log(2, 'Pages: '+pdfPages);
//Get size of the pdf in mm
pdfWidth = job.getVariableAsNumber("[Stats.PageWidth]") * 0.352778;
pdfHeight = job.getVariableAsNumber("[Stats.PageHeight]") * 0.352778;
pdfSqm = pdfWidth * pdfHeight / 1000000;
s.log (2, 'Width: ' + pdfWidth);
s.log (2, 'Height: ' + pdfHeight);
}
var f = new File(outPath+jobName+".csv");
if (!f.exists && outPath != "") {
s.log(2,"Neues Logfile wird angelegt: "+f.fullName);
f.open(File.Append);
f.writeLine("Name;Seite;Breite;Höhe;qm");
f.close();
}
//Append to existing Logfile
if (f.exists) {
f.open(File.Append);
f.writeLine(jobName+";1;"+pdfWidth+";"+pdfHeight+";"+pdfSqm);
f.close();
s.log(2,"Log-File: "+ f.fullName + " ergänzt");
}
else {
s.log(2,"Datei existiert nicht: "+f.fullName);
}
job.sendToSingle(job.getPath()); // send to null
return;
}
Writing the original filename in hierarchie? or in private data?
Example:
incoming Folder with 2 PDF files:
Foldername: MyJob
1. File: Multipage.pdf
2. File: Single Page.pdf
Output should then be MyJob.csv with following content (like in the code from above):
Name;Page;Width;Heigth;sqm
Multipage.pdf;1;210;297;0.0623
Multipage.pdf;2;297;420;0.12474
Single Page.pdf;1;2000;1800;3.6
thx in advance for any help
Ralf.