打印使用MemoryStream创建的pdf [英] printing a pdf created using MemoryStream
本文介绍了打印使用MemoryStream创建的pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我想打印我使用MemoryStream创建的pdf内存= new System.IO.MemoryStream();这是我的代码:
Hi
I would like to print a pdf that I created using MemoryStream Memory = new System.IO.MemoryStream(); and this is my code:
var doc = new Document();
System.IO.MemoryStream Memory = new System.IO.MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(doc, Memory);
try
{
doc.Open();
Paragraph pp = new Paragraph("Collage of Management, Computer and Secretarial Training\n 353 West Street Salisbury Centre,\n Tower C,6th Floor Durban 4000,\nTel:Fax:031-305-2086");
pp.Alignment = Element.ALIGN_RIGHT;
Paragraph paragraph1 = new Paragraph("\n\n\nDear " + ap.Fname + " " + ap.LastName);
Paragraph paragragh2 = new Paragraph("\n\nThank you for applying for " + Course_Name(Convert.ToInt32(ap.CourseApplied)) + " at our collage.");
Phrase pharse = new Phrase("\nWe are glad to inform you that your application has been accepted. We would like you to come with a copy of your id document, the admission number which is " + Request["AppID"] + " and metric certificate as well as your CV on the following date " + txtDateOfRegistration.Text + " for registration at our collage thank you");
Chunk footer1 = new Chunk("\n\n\nSincerely");
Chunk footer2 = new Chunk("\nMr. Vela Langa");
doc.Add(pp);
doc.Add(paragraph1);
doc.Add(paragragh2);
doc.Add(pharse);
doc.Add(footer1);
doc.Add(footer2);
}
catch (DocumentException dex)
{
}
catch (System.IO.IOException ioex)
{
}
catch (Exception ex)
{
//Handle Other Exception
}
finally
{
writer.CloseStream = false;
doc.Close(); //Close document
Memory.Position = 0;
CollegeConnection.Utilities.Send_EmailwithAttachment(txtSubject.Text, txtBody.Text, txtTo.Text, Memory);
CollegeClass.Applicants.UpdateApplicantStatus(int.Parse(Request["AppID"]));
Response.Redirect("ManManageApplications.aspx?Gritter=1");
}
}
else
{
lblError.Visible = true;
}
}
我可以通过电子邮件发送该pdf文件,但我也希望能够打印它,我需要完整的代码来搜索最近的打印机并打印此文档,请提供帮助.
I can email this pdf but I want to be able to print it as well, I need the whole code for searching for a nearest printer and printing this document please help.
推荐答案
看看
http://stackoverflow.com/questions/1392852/how-do-i-send-a-pdf-in-a-memorystream-to-the-printer-in-net [
Have a look at
http://stackoverflow.com/questions/1392852/how-do-i-send-a-pdf-in-a-memorystream-to-the-printer-in-net[^]
这篇关于打印使用MemoryStream创建的pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文