pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brzrk One <brz...@gmail.com>
Subject Re: Timeouts on large Merges
Date Mon, 17 Aug 2015 21:16:41 GMT
This example includes UI controls.
Perhaps the UI is timing out on a selection event?
Maybe a smaller example without UI would isolate the issue...

On Mon, Aug 17, 2015 at 3:26 PM, Tilman Hausherr <THausherr@t-online.de>
wrote:

> 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: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message