Sunday, 25 August 2013

C# Windows Application: Print Multiple forms to one PDF file

C# Windows Application: Print Multiple forms to one PDF file

I am working on one Windows Application(C#). and here requirement is, to
queue all the print commands in one PDF file and on Final Print, print
them all together. So that it can use Paging Space properly. They don't
want to waste paper, because there are few forms of very small size.
I checked below link for iTextSharp.
http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images
Below is the code to generate one pdf file using this code -
string pdfpath = Server.MapPath("PDFs");
string imagepath = Server.MapPath("Images");
Document doc = new Document();
try
{
PdfWriter.GetInstance(doc, new FileStream(pdfpath + "/Images.pdf",
FileMode.Create));
doc.Open();
doc.Add(new Paragraph("GIF"));
Image gif = Image.GetInstance(imagepath + "/mikesdotnetting.gif");
doc.Add(gif);
}
catch (Exception ex)
{
//Log error;
}
finally
{
doc.Close();
}
Question - how to merge all pdf files in one pdf file(with proper
pagination to save papers) and print them all together?
Is there any idea on this?
Thank you.

No comments:

Post a Comment