Am 17.08.2015 um 20:16 schrieb Keith Price:
I'm using the MergeUtility in a Javascript and when I have many single page
PDFs to merge, I get a timeout error.
The MergeUtility in PDFBox is not in Javascript, nor does it have a timeout.
????
Tilman
I have not yet identified the number of PDFs that triggers the timeout.
Is there a way of either increasing the timeout limit or maybe breaking up
large merges into multiples?
Like if I have 1000 PDFs, maybe I merge 5 sets of 200 files and then merge
those 5 into a single PDF.
Would something like that allow me to avoid the timeout? And, what would
the script look like?
Here's my current script:
// Only run if the Cert checkbox is not checked
if (fields.CERTIFICATE.value){
// Get the file paths
//--------------------
var sp = FileServices.getSeparator();
var rootPath = FileServices.getWebAppRootFilePath() + sp;
var sourcePath = "shared/GradeCerts" + sp
var destPath = sourcePath + "Merged" + sp
// Loop the table to get the PDFs
// -------------------------------
var pdfs = [];
var rows = tables.GRADES.getRows();
while (rows.next())
{
// Only include applicable rows
if (isOkayToDownload()){
var fileName = tables.GRADES.GRADECERTFILE.value;
log("Adding to Array: " + fileName);
pdfs.push(fileName);
}
}
// Sort by name
log("Sorting Array");
pdfs.sort();
// MERGE the files
// ----------------
var merger = new PDFMergerUtility();
var arrayLength = pdfs.length;
for (var i = 0; i < arrayLength; i++) {
log("Adding PDF Source: " + pdfs[i]);
merger.addSource(rootPath + sourcePath + pdfs[i]);
}
var fileName = makeFilename();
var mergedFile = rootPath + destPath + fileName;
merger.setDestinationFileName(mergedFile);
log("--- MERGING ---");
merger.mergeDocuments();
log("=== MERGED ===");
if (pdfs.length > 0){
// DOWNLOAD IT //
controls.PNL_DLLINK.show();
controls.HYPERLINKPDF.show();
controls.HYPERLINKPDF.setHref(destPath + fileName);
}else{
controls.HYPERLINKPDF.hide();
}
}
-Keith
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]