如何将2个pdf文件数据合并到vb.net中的其他pdf文件中,或者如何在vb.net中的列表框或richtextbox中显示PDF文件 [英] how to merge 2 pdf file data into other pdf file in vb.net OR how to display PDF file in listbox or richtextbox in vb.net

查看:89
本文介绍了如何将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


这篇关于如何将2个pdf文件数据合并到vb.net中的其他pdf文件中,或者如何在vb.net中的列表框或richtextbox中显示PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆