返回首页

您好,这里我返回我的代码,用于创建PDF文件。但它显示错误

我的代码:

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();

        }

回答

评论会员:基督教Graus 时间:2012/02/04
如果你使用的外部库,至少告诉我们它是什么。最好的办法是阅读文档,并要求对你的产品的论坛;重新使用,| leyou240
评论会员:游客 时间:2012/02/04
我recommed您使用Spire.Pdf/Spire.Doc这样做。此外,它很容易使用,并支持DOC,XLS,HTML,XML等转换到PDF。imgsrc=