Click here to Skip to main content
15,914,500 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
i want to merge 2 PDF file data into other pdf file
or
how to display PDF file in listbox or richtextbox
i hope , someone help me...
Posted

1 solution

hi ram,
use this code,
add pdfshart dll in your winapplication,

Imports PdfSharp.Pdf.IO
Imports PdfSharp.Pdf


Class Program
'Static variables used throughout the program
'The folder that we'll be saving things to
Shared WorkingFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Shared filepath As String = "F:\"
'The samples images that we'll create and work with
Shared pdffile1 As String = Path.Combine(filepath, "pdf1.pdf")
Shared pdffile2 As String = Path.Combine(filepath, "pdf2.pdf")
'These two arrays are just used to create our sample images
'static Color[] colors = new Color[] { Color.RED, Color.BLUE };
Shared files As String() = New String() {pdffile1, pdffile2}
'Our main export file
Shared MergedFileresultspath As String = Path.Combine(WorkingFolder, "Mergedresults.pdf")


Private Shared Sub Main(args As String())
Dim strings As String() = {pdffile1, pdffile2}
MergeMultiplePDFIntoSinglePDF(MergedFileresultspath, strings)
'MergeDocuments ( );
End Sub

Private Shared Sub MergeMultiplePDFIntoSinglePDF(outputFilePath As String, pdfFiles As String())
Console.WriteLine("Merging started.....")
Dim outputPDFDocument As New PdfDocument()

For Each pdfFile As String In pdfFiles
Dim inputPDFDocument As PdfDocument = PdfReader.Open(pdfFile, PdfDocumentOpenMode.Import)
outputPDFDocument.Version = inputPDFDocument.Version
For Each page As PdfPage In inputPDFDocument.Pages
outputPDFDocument.AddPage(page)
Next
Next
outputPDFDocument.Save(outputFilePath)
Console.WriteLine("Successfully Completed the pdf documents")
Console.WriteLine("File path is: {0}", MergedFileresultspath)
Process.Start(MergedFileresultspath)
Console.ReadLine()
End Sub

End Class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900