Adding a page footer to a PDF file

Posted in: General vb.NET
By dePoPo
Nov 9, 2009 - 1:16:42 PM

This code sample processes an existing PDF file, and adds a page footer to each page. Optionaly you can add page numbering.

This code sample requires a reference to the toolbox to work.

        Dim mydemo As New ToolBox.PDFTools.PDFFooterWriter(My.Computer.FileSystem.SpecialDirectories.Desktop & "\output.pdf")
        mydemo.inputfile = My.Computer.FileSystem.SpecialDirectories.Desktop & "\sourcefile.pdf"
        mydemo.footertext = "Page: "        ' --- Footer text
        mydemo.append_pagenumber = True     ' --- We want a page number added in the footer
        mydemo.centerfooter = True          ' --- Center the footer on the page
        mydemo.disableborder = True         ' --- Disable the line at the top and bottom of the footer
        mydemo.startpagenumber = 2          ' --- Start page numbering at 2 (optional)

        Try
            mydemo.SetFooter()              ' --- Process the document and add the page numbers
        Catch ex As Exception
            MsgBox("oops, error: " & ex.ToString)
        End Try

        MsgBox("Done!")


Visitor Comments