[VB.NET/C#] Merging 2 PDF using incremental saving

Example requests & Code samples for GdPicture Toolkits.
Post Reply
User avatar
Loïc
Site Admin
Posts: 5575
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

[VB.NET/C#] Merging 2 PDF using incremental saving

Post by Loïc » Wed Dec 12, 2012 12:31 pm

Hello,

Here is a way to quickly merge 2 PDF using incremental saving that is provided in GdPicture.
This way helps to reduce memory usage and dramatically increase performance during the merging process.

Using VB.NET

Code: Select all

 
Dim oSrcPDF As New GdPicturePDF
Dim oDstPDF As New GdPicturePDF

oDstPDF.LoadFromFileEx("c:\doc1.pdf", True)
oSrcPDF.LoadFromFile("c:\doc2.pdf", False)

Dim srcPageCount As Integer = oSrcPDF.GetPageCount()

For i As Integer = 1 To srcPageCount
   oDstPDF.ClonePage(oSrcPDF, i)
Next

oDstPDF.SaveToFileInc("c:\doc1.pdf")

oDstPDF.Dispose()
oSrcPDF.Dispose()
Or using C#

Code: Select all

GdPicturePDF oSrcPDF = new GdPicturePDF();
GdPicturePDF oDstPDF = new GdPicturePDF();

oDstPDF.LoadFromFileEx("c:\\doc1.pdf", true);
oSrcPDF.LoadFromFile("c:\\doc2.pdf", false);

int srcPageCount = oSrcPDF.GetPageCount();

for (int i = 1; i <= srcPageCount; i++) {
	oDstPDF.ClonePage(oSrcPDF, i);
}

oDstPDF.SaveToFileInc("c:\\doc1.pdf");

oDstPDF.Dispose();
oSrcPDF.Dispose();

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests