how to create a page index for a PDF document using iTextSharp with c# or vb.net code

The name of the picture


how to create a page index for a PDF document using iTextSharp with c# or vb.net code



I use iTextSharp dll and merge of multiple pdf documents.It's work very well but i can't create a index page on the first page of document (with reference at the page).can you help me with a simple code?
This is my function for merge pdf files:



Function CombineMultiplePDFs(ByVal fileNames As List(Of String), ByVal outFile As String, ByVal pathCartella As String) As String


Dim document As Document = New Document()
Dim writer As PdfCopy = New PdfCopy(document, New FileStream(outFile, FileMode.Create))

If writer Is Nothing Then
Return String.Empty
End If

document.Open()


For Each fileName As String In fileNames


Dim reader As PdfReader = New PdfReader(Path.Combine(outFile, fileName)) 'va nella cartella documenti anzichè nella cartella documentimerge
reader.ConsolidateNamedDestinations()

For i As Integer = 1 To reader.NumberOfPages
Dim page As PdfImportedPage = writer.GetImportedPage(reader, i)
writer.AddPage(page)

Next

Dim form As PRAcroForm = reader.AcroForm

If form IsNot Nothing Then
writer.CopyAcroForm(reader)
End If

reader.Close()
Next

writer.Close()
document.Close()

Return Path.Combine(pathCartella, Path.GetFileName(outFile))
End Function









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP