简体   繁体   English

SharpPDF在Serverside asp .Net C#中创建PDF

[英]SharpPDF create PDF in Serverside asp .Net C#

I have samples to create PDF, however for the server side creation of PDF there is no documentation about SharpPDF. 我有样本来创建PDF,但是对于服务器端创建PDF,没有关于SharpPDF的文档。 I think it is about stream concept, which I have no information about it. 我认为这是关于流概念,我没有关于它的信息。

pdfDocument myDoc = new pdfDocument("TUTORIAL", "ME");
pdfPage myPage = myDoc.addPage();

myPage.addText("Hello World!", 200, 450, sharpPDF.Enumerators.predefinedFont.csHelvetica, 12);
myDoc.createPDF(@"c:\test.pdf");
myDoc.
myPage = null;
myDoc = null; 

There is an overload for createPDF that takes a Stream . createPDF有一个带有Stream的重载。 You can use this to create the PDF in memory on the server and then stream it back to the client. 您可以使用它在服务器上的内存中创建PDF,然后将其流回客户端。

Here is an example (tried with ShartPDF version 1.3.1): 这是一个例子(尝试使用ShartPDF版本1.3.1):

PdfDocument myDoc = new pdfDocument("TUTORIAL", "ME");
pdfPage myPage = myDoc.addPage();
myPage.addText("Hello World!", 200, 450, predefinedFont.csHelvetica, 12);

Response.ContentType = "application/pdf";
myDoc.createPDF(Response.OutputStream);
Response.Flush();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM