//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System.IO;
using GrapeCity.Documents.Word;
using GrapeCity.Documents.Word.Layout;
namespace DsWordWeb.Demos
{
// This example shows how to password protect the PDF document
// when using GrapeCity.Documents.Word.Layout (GcWordLayout) to
// save a DOCX as PDF.
public class PasswordProtectPdf
{
public GcWordDocument CreateDocx()
{
GcWordDocument doc = new GcWordDocument();
doc.Load(Path.Combine("Resources", "WordDocs", "ProcurementLetter.docx"));
return doc;
}
// Optional static method. If it is defined on a sample class,
// these options are used when saving the document to PDF.
public static PdfOutputSettings GetPdfOutputSettings()
{
var settings = new PdfOutputSettings();
// This creates a security handler with both owner and user passwords
// set to the passed string ("password" in this example):
var sh = settings.CreateSecurityHandler("password");
// Other SecurityHandler properties can be used to customize PDF protection,
// e.g. here we protect the PDF content from copying, printing and editing:
sh.CopyContent = false;
sh.PrintingPermissions = GrapeCity.Documents.Pdf.Security.PrintingPermissions.Disabled;
sh.EditingPermissions = GrapeCity.Documents.Pdf.Security.EditingPermissions.Disabled;
return settings;
}
}
}