chap0109.cs

来自「iTextSharp」· CS 代码 · 共 36 行

CS
36
字号
using System;
using System.IO;

using iTextSharp.text;
using iTextSharp.text.pdf;


namespace iTextSharp.tutorial.Chap01
{
	/// <summary>
	/// Chap0109 的摘要说明。
	/// </summary>
	public class Chap0109
	{
		public Chap0109()
		{
			Console.WriteLine("Chapter 1 example 9: encryption 40 bits");
        
			Document document = new Document(PageSize.A4, 50, 50, 50, 50);
			try 
			{
				PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap0109.pdf", FileMode.Create));
				writer.SetEncryption(PdfWriter.STRENGTH40BITS, null, null, PdfWriter.AllowCopy);
				document.Open();
				document.Add(new Paragraph("This document is Top Secret!"));
				document.Close();
			}
			catch (Exception de) 
			{
				Console.WriteLine(de.StackTrace);
			}

		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?