next up previous contents index
Next: Index Up: cpdflibmanual Previous: Example Program in C#   Contents   Index

Example Program in VB.NET

This program loads a file from disk, adds page numbers, and then writes the file encrypted to disk.
Module Module1

    Sub Main()
        'Load the (unencrypted) input file
        Dim pdf As Pdf.pdfdoc = Cpdflib.FromFile("C:\\input.pdf")

        'Resolve any rotation of pages
        Cpdflib.Upright(pdf, Cpdflib.All(pdf))

        'Add page numbers
        Cpdflib.AddText _
          (pdf, Cpdflib.All(pdf), "Page %Page of %EndPage", _
          Cpdf.position.Top(20.0), 1.0, 0, _
          Pdftext.standard_font.TimesBold, _
          12.0, Cpdflib.Black, False)

        'Write to file, encrypted with AES encryption
        Dim permissions As Pdfcrypt.permission() = _
          {Pdfcrypt.permission.NoEdit, Pdfcrypt.permission.NoAssemble}
        Cpdflib.ToFileEncrypted _
          (pdf, _
           Pdfwrite.encryption_method.AES128bit(False), _
           permissions, "fred", "charles", _
           False, "C:\\output.pdf")
    End Sub

End Module



root 2008-12-01