0

I am using the following code to print a PDF document, in my print button I'm using this code:

  Panel1.Controls.Add(new LiteralControl(" <object id = 'Object1' name='Pdf2' type='application/pdf' width='1' height='1' ><param name='SRC'  value='PrintPDFFile.aspx' /></object> "));
  ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language=JavaScript>document.Pdf2.printWithDialog();</script>");

and in the 'PrintPDFFile.aspx' page , I am creating the PDF

    Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
    pdfDoc.Open();
    pdfDoc.Add(new Paragraph("TEST"));       
    pdfDoc.Close();
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "inline;" + "filename=sample.pdf");
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Write(pdfDoc);
    Response.End();

This code works fine with IE browser but doesn't work with other browsers such as FF, how it can be modified to work fine with other browsers?

user1947393
  • 153
  • 4
  • 18
  • Unrelated to your problem but remove the the line `Response.Write(pdfDoc);` because it doesn't do what you think it does. – Chris Haas Mar 10 '16 at 14:34
  • Back to your problem, your iTextSharp code is otherwise correct, your actual problem is with Firefox's rendering of inline PDFs. [See this thread for a discussion](http://stackoverflow.com/q/22534282/231316). – Chris Haas Mar 10 '16 at 14:37
  • when I add data tag, it throws an error – user1947393 Mar 14 '16 at 08:26
  • By "throws an error" do you mean that an error is logged to the console? Are you able to provide this error? – Chris Haas Mar 14 '16 at 13:31

0 Answers0