我有一个我希望克隆的主文档,然后在克隆的pdf中的各个书签上添加其他各种pdf。
我已经搜索了所有iText文档以及在此处的StackOverflow,但现在开始怀疑是否可以在书签中插入页面,或者我应该考虑使用其他方法吗?
如果可以做到,我需要一个指针来创建返回书签(PdfOutline)页码的递归函数,以便希望在那一点插入?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Read Master and create copy as Output
Dim pdfDocOutput As PdfDocument = New PdfDocument(New PdfReader("c:\temp\Test Master Document.pdf"), New PdfWriter("c:\temp\Test Document.pdf"))
Dim documentOutput As Document = New Document(pdfDocOutput)
' get all the bookmarks in the Output
Dim outlines As PdfOutline = pdfDocOutput.GetOutlines(False)
Dim bookmarks As List(Of PdfOutline) = outlines.GetAllChildren
' declare bookmarks to process
Dim bmList As New Dictionary(Of String, String)
bmList.Add("Section1", "c:\temp\Section1.pdf") ' 1 page Landscape
bmList.Add("Section2", "c:\temp\Section2.pdf") ' 19 page scanned
bmList.Add("Section3", "c:\temp\Section3.pdf") ' 22 page mix Portrait/Landscape
' look for each bookmark and insert associated pdf at that page num
Dim bmKeyValue As KeyValuePair(Of String, String)
For Each bmKeyValue In bmList
' call recursive function to find bookmark
Dim bm As PdfOutline
' bm = findBookmark(outlines, bmKeyValue.Key, bmKeyValue.Value)
' insert pdf at the found bookmarks page num
Next
' write and close output
documentOutput.Close()
pdfDocOutput.Close()
MsgBox("Finsished")
End Sub