| 1: | using System; | |
| 2: | using System.IO; | |
| 3: | ||
| 4: | using iTextSharp.text; | |
| 5: | using iTextSharp.text.pdf; | |
| 6: | ||
| 7: | ||
| 8: | namespace iTextSharp.tutorial.Chap01 | |
| 9: | { | |
| 10: | /// <summary> | |
| 11: | /// Encryption | |
| 12: | /// </summary> | |
| 13: | public class Chap0109 | |
| 14: | { | |
| 15: | public Chap0109() | |
| 16: | { | |
| 17: | Console.WriteLine("Chapter 1 example 9: encryption 40 bits"); | |
| 18: | ||
| 19: | Document document = new Document(PageSize.A4, 50, 50, 50, 50); | |
| 20: | try | |
| 21: | { | |
| 22: | PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap0109.pdf", FileMode.Create)); | |
| 23: | writer.SetEncryption(PdfWriter.STRENGTH40BITS, null, null, PdfWriter.AllowCopy); | |
| 24: | document.Open(); | |
| 25: | document.Add(new Paragraph("This document is Top Secret!")); | |
| 26: | document.Close(); | |
| 27: | } | |
| 28: | catch (Exception de) | |
| 29: | { | |
| 30: | Console.WriteLine(de.StackTrace); | |
| 31: | } | |
| 32: | ||
| 33: | } | |
| 34: | } | |
| 35: | } |