Print PDF Created using itextsharp

前端 未结 1 353
别跟我提以往
别跟我提以往 2020-12-20 07:36

My Goal is to print a RDLC report on the client machine without preview. I can not use the ReportViewer print button since it requires the installation of ActiveX object and

1条回答
  •  时光说笑
    2020-12-20 08:34

    Regarding your question about PdfStamper (in the comments). It should be as simple as this:

    string jsPrint = "var pp = this.getPrintParams();pp.interactive= pp.constants.interactionLevel.silent;this.print(pp);";
    PdfReader reader = new PdfReader(bytes);
    MemoryStream stream = new MemoryStream();
    PdfStamper stamper = new PdfStamper(pdfReader, stream);
    stamper.Writer.AddJavaScript(jsPrint);
    stamper.Close();
    reader.Close();
    

    Regarding your original question: automatic printing of PDF documents is considered being a security hazard: one could send a PDF to an end-user and that PDF would cause the printer to spew out pages. That used to be possible with (really) old PDF viewers, but modern viewers prevent this from happening.

    In other words: you may be trying to meet a requirement of the past. Today's PDF viewers always require an action from the end user to print a PDF document.

    0 讨论(0)
提交回复
热议问题