如何将2个pdf文件数据合并到vb.net中的其他pdf文件中,或者如何在vb.net中的列表框或richtextbox中显示PDF文件

问题描述:

你好
我想将2个PDF文件数据合并到其他pdf文件中

如何在列表框或RichTextBox中显示PDF文件
希望有人帮助我...

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...

嗨ram,
使用此代码,
在您的winapplication中添加pdfshart dll,

导入PdfSharp.Pdf.IO
导入PdfSharp.Pdf


班级计划
''整个程序中使用的静态变量
"我们将要保存到的文件夹
共享的工作文件夹为字符串= Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
共享文件路径为String ="F:\"
''我们将创建并使用的示例图像
共享的pdffile1为String = Path.Combine(filepath,"pdf1.pdf")
共享的pdffile2为字符串= Path.Combine(filepath,"pdf2.pdf")
''这两个数组仅用于创建我们的示例图像
''静态Color [] colors = new Color [] {Color.RED,Color.BLUE};
共享文件为String()= New String(){pdffile1,pdffile2}
''我们的主要出口文件
共享的MergedFileresultspath作为字符串= Path.Combine(WorkingFolder,"Mergedresults.pdf")


私有共享子主目录(args作为String())
昏暗的字符串为String()= {pdffile1,pdffile2}
MergeMultiplePDFIntoSinglePDF(MergedFileresultspath,字符串)
''MergeDocuments();
结束子

私有共享子MergeMultiplePDFIntoSinglePDF(outputFilePath作为String,pdfFiles作为String())
Console.WriteLine(合并已开始.....")
将outputPDFDocument调暗为新的PdfDocument()

对于每个pdfFile作为pdfFiles中的字符串
将inputPDFDocument调暗为PdfDocument = PdfReader.Open(pdfFile,PdfDocumentOpenMode.Import)
outputPDFDocument.Version = inputPDFDocument.Version
对于每个页面作为inputPDFDocument.Pages中的PdfPage
outputPDFDocument.AddPage(page)
下一个
下一个
outputPDFDocument.Save(outputFilePath)
Console.WriteLine(成功完成pdf文档")
Console.WriteLine(文件路径为{0}",MergedFileresultspath)
Process.Start(MergedFileresultspath)
Console.ReadLine()
结束子

结束类
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