Click here to Skip to main content
15,883,925 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I would like to print a pdf that I created using MemoryStream Memory = new System.IO.MemoryStream(); and this is my code:
C#
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;
          }

      }

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.
Posted
Updated 9-Oct-11 7:52am
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900