[英]Printing PDF automatically from c# code
我正在嘗試使用下面的c#和iTextSharp代碼進行打印,有人可以幫助我。 它不會被打印。
var document = new iTextSharp.text.Document();
PdfWriter writer = PdfWriter.GetInstance(document, memStream);
document.Open();
var reader = new PdfReader("C:\\test1.pdf");
PdfContentByte content = writer.DirectContent;
Int32 i;
int pageCount = 1;
for (i = 0; i <= pageCount - 1; i++)
{
document.NewPage();
PdfImportedPage page = writer.GetImportedPage(reader, i + 1);
content.AddTemplate(page, 0, 0);
}
writer.SetOpenAction(new PdfAction(PdfAction.PRINTDIALOG));
document.Close();
您可以使用Ghostscript庫打印pdf文件。
如果您需要.NET的Ghostscript包裝器,則可以查看Ghostscript.NET庫。
通過Ghostscript.NET的打印示例可以在以下位置找到: https : //ghostscriptnet.codeplex.com/discussions/470946
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.