我使用以下代码打印PDF文档,在我的打印按钮中使用此代码:
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>");
并在&#39; PrintPDFFile.aspx&#39;页面,我正在创建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();
此代码适用于IE浏览器,但不能与其他浏览器(如FF)一起使用,如何修改它以便与其他浏览器一起使用?