'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.PdfImportsGrapeCity.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 SecurityHandlers sample, which shows'' how to examine restrictions in a loaded PDF.PublicClassDocumentRestrictionsFunctionCreatePDF(ByVal stream AsStream) AsInteger'' Create a New PDF document:Dim doc = NewGcPdfDocument()Dim rc = 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 = NewStandardSecurityHandlerRev4() 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 '' Add a text prompting the user to check out the source codeDim pg = doc.Pages.LastDim g = pg.GraphicsDim tl = g.CreateTextLayout() tl.AppendLine("See the source code of this demo for details on how to use a security handler to set PDF document restrictions.") tl.MaxWidth = pg.Bounds.Width - rc.X * 2 tl.MarginLeft = rc.X tl.MarginTop = rc.Bottom + 36 g.DrawTextLayout(tl, PointF.Empty) '' Done doc.Save(stream)Return doc.Pages.CountEndFunctionEndClass