VB.NET 拆分、合并PDF工具(PDF批量打印)
有粉丝后台留言想要拆分PDF文档的工具,那么他来了.....
上两期原文
本期只做上期VB.NET 合并PDF工具(PDF批量打印)的补充,这次新增了批量拆分PDF文档操作,下面看演示
核心代码
Sub Split_all_pdf(datapath As String, outpath As String)
Try
Dim input_doc As PdfDocument = PdfReader.Open(datapath, PdfDocumentOpenMode.Import)
Dim name As String = System.IO.Path.GetFileNameWithoutExtension(datapath)
Dim idx As Integer = 0
While idx < input_doc.PageCount
Dim out_doc As New PdfDocument With {
.Version = input_doc.Version
}
out_doc.Info.Title = String.Format($'{input_doc.Info.Title}_页面{idx + 1}')
out_doc.Info.Creator = input_doc.Info.Creator
out_doc.AddPage(input_doc.Pages(idx))
out_doc.Save($'{outpath}\{name}_第{idx + 1}页.pdf')
idx += 1
End While
Catch ex As Exception
Debug.WriteLine(datapath)
End Try
End Sub
新工具下载地址:
https://vbee.lanzous.com/i7pDvl9b15c
赞 (0)