Hi, I am trying to concatenate 100 1 page documents together but I am recieving an out of memory exception. I found a different way around it but getting the pages of each document and adding them to the pages collection of a new pdf I created but it is pretty slow. Is there another way around the out of memory exception?
Hi John,
Thanks for your interest in our products.
Can you please share some details regarding the template PDF documents and code snippet you are using. This will help us to figure out the issue and reply back to you soon.
We apologize for your inconvenience.
Thanks & Regards,
I looked into it a little more deeply and found out that the test I wrote was using a 1 page pdf that included a high res photo on the first page. When using the following code to concatenate the pdf 100 times it would through an out of memory exception once the process consumed right around 1500mb. Below is the method that I am using to concatenate them together, and when the Concatenate is called the LastException property will hold the value of “Exception of type ‘System.OutOfMemoryException’ was thrown.”
public void Stitch(string outputFile, params string[] inputDocumentPaths){var editor = new PdfFileEditor();editor.CloseConcatenatedStreams = true;var result = editor.Concatenate(inputDocumentPaths, outputFile);if (!result){throw new ApplicationException(editor.LastException.Message, editor.LastException.InnerException);}}
public void Stitch(string outputFile, params string[] inputDocumentPaths){Pdf pdf = new Pdf();pdf.Save(outputFile);</b>var outputStream = new FileStream(outputFile, FileMode.OpenOrCreate);foreach (var documentPath in inputDocumentPaths){var outputDocument = new Document(outputStream);var document = new Document(documentPath);outputDocument.Pages.Add(document.Pages);document.Dispose();outputDocument.Save();}outputStream.Close();}
Hi John,
I apologize for the delay in the response.
I have tested the scenerio and able to notice the same problem when concatinating PDF document 100 times, however this is working when we trying to concate the PDF document 85 times, in this case, the resultant PDF size is 1.27 GB. The problem may occur due to large file size and rendering time is slow because PDF document has high resolution image.
I am afraid 3D PDF document feature is not supported at the moment. We will investigate, if we can support the feature in our future version.
We apologize for your inconvenience.
Thanks & Regards,