我从 itextsharp 开始,我已经设法回答了我所有的问题,但一个:如何设置书签以打开 fitpage 缩放/视图?
如果这已经在其他地方得到回答,我深表歉意。如果有帮助,这是我的代码。
//编辑:下面是我的工作代码。它已使用 Bruno 的示例进行了修改。
Public Sub MergePDFFiles(FileList As System.Collections.Generic.List(Of ModifiedItemForList), pdfName As String, pageCount As Integer)
Dim reader As PdfReader
Dim mergedPdf As Byte() = Nothing
Dim n As Integer
Dim page As Integer
Dim par As Paragraph
Dim pageMode As Integer
Dim pageLayout As Integer
Dim pageZoom As PdfDestination
Dim outlineZoom As PdfDestination
Dim pdfAction As PdfAction
Dim root As PdfOutline
Dim pdfOutline As PdfOutline
Using ms As New MemoryStream()
Using document As New Document()
Using copy As New PdfCopy(document, ms)
'Dim copy As New PdfCopy(document, ms)
document.Open()
root = copy.RootOutline
pageMode = copy.PageModeUseOutlines
pageLayout = copy.PageLayoutSinglePage
pageZoom = New PdfDestination(PdfDestination.FIT)
copy.ViewerPreferences = pageMode
pdfAction = pdfAction.GotoLocalPage(1, pageZoom, copy)
copy.SetOpenAction(pdfAction)
' For Each FilePath As KeyValuePair(Of String, String) In FileList ' .Count - 1
For i As Integer = 0 To pageCount - 1
' FilePath As KeyValuePair(Of String, String)
If File.Exists(FileList.Item(i).Value) Then
reader = New PdfReader(FileList.Item(i).Value)
' loop over the pages in that document
n = reader.NumberOfPages
page = 0
par = New Paragraph(FileList.Item(i).Key)
Debug.Print("FileList.Item(i).Key = " & FileList.Item(i).Key)
outlineZoom = New PdfDestination(PdfDestination.FIT)
pdfOutline = New PdfOutline(root, outlineZoom, par)
While page < n
copy.AddPage(copy.GetImportedPage(reader, System.Threading.Interlocked.Increment(page)))
End While
End If
Next
End Using
End Using
mergedPdf = ms.ToArray()
End Using
File.WriteAllBytes(pdfName, mergedPdf)
End Sub
您的意见将不胜感激,Corbin de Bruin