如何使用密码在.net中创建PDF文件
问题描述:
我在pdf文件中返回创建代码。但它显示错误
我的代码:
hi here i return my code for creation on pdf file. but it is showing error
my code:
public void pdf()
{
int i = 0;
// r is for random file names...
Random r = new Random();
i = r.Next(1, 999999999);
string filename = i.ToString() + ".pdf";
//path where to save...
string path = "D:/Test/" + filename;
Document document = new Document();
PdfWriter writer;
writer = PdfWriter.GetInstance(document, new FileStream(path, System.IO.FileMode.Create));
// Set password ...replace mypass with your password .......
writer.SetEncryption(PdfWriter.STRENGTH128BITS, "mypass", null, PdfWriter.AllowCopy);
document.Open();
//document as many properties .. for time begin i am using only one ..
//document.add is to add contant to your file..
document.Add(new Paragraph("This document is Top Secret!"));
document.Close();
}
答
如果您使用外部库,至少告诉我们它是什么。您最好的选择是阅读文档并在论坛上询问您正在使用的产品,
If you use an external library, at least tell us what it is. Your best bet is to read the docs and ask on the forums for the product you;re using,