PHP 8.2.31
Preview: Permission.vb Size: 1.35 KB
/proc/thread-self/root/opt/alt/libharu/usr/share/libharu/bindings/vb.net/demo/Permission.vb

Imports HPdf

Module Permission

    Sub Main()
        Const owner_passwd As String = "owner"
        Const user_passwd As String = ""
        Const text As String = "User cannot print and copy this document."
        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion())

        Try
            Dim pdf As HPdfDoc = New HPdfDoc()

            ' create default-font 
            Dim font As HPdfFont = pdf.GetFont("Helvetica", Nothing)

            ' add a new page object. 
            Dim page As HPdfPage = pdf.AddPage()

            page.SetSize(HPdfPageSizes.HPDF_PAGE_SIZE_B5, HPdfPageDirection.HPDF_PAGE_LANDSCAPE)

            page.BeginText()
            page.SetFontAndSize(font, 20)
            Dim tw As Single = page.TextWidth(text)
            page.MoveTextPos((page.GetWidth() - tw) / 2, (page.GetHeight() - 20) / 2)
            page.ShowText(text)
            page.EndText()

            pdf.SetPassword(owner_passwd, user_passwd)
            pdf.SetPermission(HPdfDoc.HPDF_ENABLE_READ)

            ' use 128 bit revision 3 encryption
            pdf.SetEncryptionMode(HPdfEncryptMode.HPDF_ENCRYPT_R3, 16)

            ' save the document to a file
            pdf.SaveToFile("Permission.pdf")

        Catch ex As Exception
            Console.Error.WriteLine(ex.Message)
        End Try
    End Sub
End Module

Directory Contents

Dirs: 0 × Files: 9

Name Size Perms Modified Actions
1.17 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download
2.75 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download
5.03 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download
8.86 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download
2.45 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download
1.35 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download
2.92 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download
5.13 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download
9.46 KB lrw-r--r-- 2025-03-11 14:13:06
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).