How to generate secure(restricted) PDF using ItextSharp

Script that currently  i used to secure the PDF file, so user when download it the PDF they will not able to Copy and  modify the content for that PDF itself.

Here as below the script :

using (var stamper = new PdfStamper(pdfReader, ms))
{

System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
stamper.SetEncryption(null, encoding.GetBytes(“12345678”), ~(PdfWriter.AllowCopy |  PdfWriter.ALLOW_MODIFY_CONTENTS), PdfWriter.STRENGTH40BITS);

}

 

You can also set as many PDF Restriction they have, here are the list below :

PdfWriter.ALLOW_PRINTING

PdfWriter.ALLOW_MODIFY_CONTENTS

PdfWriter.ALLOW_COPY

PdfWriter.ALLOW_MODIFY_ANNOTATIONS

PdfWriter.ALLOW_FILL_IN

PdfWriter.ALLOW_SCREENREADERS

PdfWriter.ALLOW_ASSEMBLY

PdfWriter.ALLOW_DEGRADED_PRINTING

 

Happy Sharepoint-Ing

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.