Merging pdf documents

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  Merging pdf documents

DynamicPDF CoreSuite for .NET (v10) Forum

 Jul 18 2020 6:26 PM
We are using DynamicPdf library 10x version for creating pdf's and merging them into one pdf document.  We are having  1 million pdf documents which are having 1 page each. We need to merge them into 10 pdf files with 100k pages in each document. I am using MergeDocument.append() method to create merge document and it is hitting the performance like anything.  It is taking around 15 mins to create 5000 pages document. Is there any better approach which solve the performance for merging the pdf documents ?
 Jul 20 2020 11:00 AM
Posted by a ceTe Software moderator
Hello,

The time taken to merge the PDFs is dependent on the contents included in the PDF. Our products are designed keeping performance in mind however, PDFs with a complex structure will take longer than PDFs with a simple structure. A complex logical structure is the most likely cause for this.

Please try using the MergeOptions class and set the LogicalStructure boolean property of it to false. Specify this Object while merging or appending the PDF to MergeDocument object and see it works for you. Below is a code sample.

            PdfDocument pdf = new PdfDocument(@"Input PDF file path or byte array");
            MergeOptions options = new MergeOptions();
            options.LogicalStructure = false;
            MergeDocument mergeDoc = new MergeDocument();
            mergeDoc.Append(pdf, options);
            mergeDoc.Draw(@"Output PDF file path");

If the pages contain images or are large, you could also be using a lot of memory and may want to consider using disk buffering. Here is a topic showing have to enable that:  Disk Buffering

If you continue facing any issues then please send over the following information to support@dynamicpdf.com so we can look into it further.

1.        Code sample used for merging.
2.        Some sample PDFs using which we can recreate the behavior.
3.        Time taken to merge the sample PDFs.
4.        Exact version and build number of the DynamicPDF DLL file used in your application. You can find this information in DLL references properties (Version and Description fields) in Visual Studio.

Thanks,
ceTe Software Support Team
 Jul 20 2020 1:41 PM
Hello,
Thank you for the quick response. I added suggested changes but still the performance is same and no improvement and still memory is increasing after enabling the disk buffer options. It is taking 30 mins to create 10000 pages merged document. Below is the code snippet. Please let me now where I am doing wrong.

MergeDocument mergePdf = new MergeDocument();
            MergeOptions mergeOptions = new MergeOptions();
            mergeOptions.LogicalStructure = false;
            DiskBufferingOptions diskOptions = new DiskBufferingOptions();
            diskOptions.Enabled = true;
            diskOptions.Location = pdfTemplateLocation;
            mergePdf.DiskBuffering = diskOptions;
 PdfDocument pdfDocument = new PdfDocument(@"LocationOfPdfDocument");
                            mergePdf.Append(pdfDocument, mergeOptions);
mergePdf.Draw(@"OutputLocation");
 Jul 20 2020 3:11 PM
Posted by a ceTe Software moderator
Hi,

Your code looks correct. Please send some example PDFs that you are using so we can evaluation what the issue further. You can send them to support@dynamicpdf.com.

Thanks,
ceTe Software Support Team
 Jul 20 2020 3:28 PM
Hello,
I can't share the pdf documents. I am creating form based pdf's from a template of 1 page and it is having size of 100kb after populating the form data on template. I am using 10000 such files and merging them into 1 mergedDocument.
 Jul 24 2020 1:10 PM
Posted by a ceTe Software moderator
Hello,

We did some testing based on your description but are unable to recreate the behavior on our end. Please send the following information to support@dynamicpdf.com so we can look into it further.

1.        Simple console application which uses static data to recreate the behavior.
2.        Sample source PDF(s) you are using to recreate the issue.
3.        Exact version and build number of the DynamicPDF DLL file used in the application. You can get this information in DLL references properties (Version and Description fields) in Visual Studio.

Please note that, it is difficult to troubleshoot the behavior without recreating it on our end.

Thanks,
ceTe Software Support Team
 Jul 24 2020 2:35 PM
Hello,
I have sent the requested information to mentioned email address. Please check and let us know asap.

Thank you
 Aug 03 2020 9:06 AM
Posted by a ceTe Software moderator
Hello,

Thanks for sharing the requested information. We will be looking into it further and post an update on the forum once we are done with our analysis.

Thanks,
ceTe Software Support Team
 Sep 11 2020 1:23 PM
Posted by a ceTe Software moderator
Hello,

We have a new build that includes optimizations to the merging and form flattening process. This feature is available in the latest release, DynamicPDF Core Suite for .NET (v10.35). You can download the latest from Nuget (Package ID: ceTe.DynamicPDF.CoreSuite.NET) or from our website here.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 6:00 PM.