'' This code is part of GrapeCity Documents for PDF samples.
'' Copyright (c) GrapeCity, Inc. All rights reserved.
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Pdf.Security

'' This sample shows how to set restrictions on a PDF,
'' e.g. restricting the ability to print Or copy content
'' from the document.
'' See also the DocumentPermissions sample, which shows
'' how to examine restrictions in a loaded PDF.
Public Class DocumentRestrictions
    Function CreatePDF(ByVal stream As Stream) As Integer
        '' Create a New PDF document:
        Dim doc = New GcPdfDocument()
        Util.AddNote("This document has the following restrictions:" + vbLf +
            "  - printing is not allowed;" + vbLf +
            "  - content copying is not allowed;" + vbLf +
            "  - document assembly is not allowed.", doc.NewPage())

        '' Create a Rev4 security handler And specify some restrictions:
        Dim ssh4 = New StandardSecurityHandlerRev4() With
            .PrintingPermissions = PrintingPermissions.Disabled,
            .CopyContent = False,
            .EditingPermissions = EditingPermissions.Disabled

        '' Assign the handler we created to the document so that it Is used when saving the PDF
        doc.Security.EncryptHandler = ssh4

        '' Done
        Return doc.Pages.Count
    End Function
End Class