This is a migrated thread and some comments may be shown as answers.

Acrobat Event DidPrint in ReportRender

3 Answers 132 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yassir
Top achievements
Rank 1
Yassir asked on 26 Oct 2015, 11:18 AM

Greetings,

 

I need your help with the below issue.

 

I'm streaming an exported PDF from a telerik report and I need to insert JavaScript to be executed after acrobat event 'DidPrint' which I want to execute to close the PDF file after the filed being printed.

 Below is how I render the report as PDF and print it sielently.

 

       deviceInfo["JavaScript"] = "this.print({bUI: false, bSilent: false, bShrinkToFit: true});";
            var reportProcessor = new ReportProcessor();
            var reportSource = new Telerik.Reporting.InstanceReportSource();
            Report1 report = new Report1();
            report.ReportParameters["ID"].Value = "10";
            reportSource.ReportDocument = report;
            var renderingResult = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

3 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 29 Oct 2015, 08:50 AM
Hello Yassir,

The provided code snippet will export a report in PDF and most probably the result bytes are sent to the client's browser (means the browser's PDF plugin will handle the preview) or as a file where the client machine must have a PDF reader.
We provide setting for adding Adobe Javascript in files which is executed by the PDF plugin/reader and closing the print dialog that will be raised by the used PDF reader/plugin for previewing is out of the scope of the reporting engine.

If you are downloading the PDF as an attachment the following Adobe Javascript will cause the PDF reader to show its Print dialog first and then close the document:
var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
               var typeReportSource = new Telerik.Reporting.UriReportSource { Uri = Server.MapPath("~/Barcodes Report.trdx") };
               // set any deviceInfo settings if necessary
               var deviceInfo = new System.Collections.Hashtable();
               deviceInfo.Add("JavaScript", "this.print({bUI: true, bSilent: false, bShrinkToFit: true});this.closeDoc(true);");
               var result = reportProcessor.RenderReport("PDF", typeReportSource, deviceInfo);
 
               this.Response.Clear();
               this.Response.ContentType = result.MimeType;
               this.Response.Cache.SetCacheability(HttpCacheability.Private);
               this.Response.Expires = -1;
               this.Response.Buffer = true;
 
               /* Uncomment to handle the file as attachment*/
                Response.AddHeader("Content-Disposition",
                               string.Format("{0};FileName=\"{1}\"",
                                               "attachment",
                                               "test.pdf"));
                 
 
               this.Response.BinaryWrite(result.DocumentBytes);
               this.Response.End();
The above will not close a browser's window. More suggestions can be searched in Adobe Forums and
JavaScript™ for Acrobat® API Reference.


Silent printing can be done on the server through a printer connected to the server, where you will need to provide valid printer settings on calling ReportProcessor.PrintReport.


I hope this information is helpful.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Yassir
Top achievements
Rank 1
answered on 01 Nov 2015, 04:51 AM

Thanks Stef for the reply.

 

However, what I need to accomplish is printing the report only (if possible using a web service without showing the report). The how could be different. Using adobe JavaScript was an idea to utilize adobe plugin. If Telerik reporting can print the report directly to the client even without exporting to PDF that would be great. Please advise if that is ​feasible or not.

0
Stef
Telerik team
answered on 04 Nov 2015, 01:00 PM
Hi Yassir,

Reports are not printed directly at the client. The provided web viewers print operation is actually an export in PDF format with the additional Adobe Javascript settings forcing the PDF reader/plugin to display its Print dialog. Thus if a browser has a valid Adobe PDF plugin, the Print dialog appears on screen, where the PDF is loaded in a hidden frame.
If the browser does not have such PDF plugin, the PDF file is downloaded at the client and on preview the PDF reader shows its Print dialog.

Since technologically there is no access to the client's machine from browser, you can print reports silently on the server through a printer connected to the server. For the purpose you will have to provide valid PrinterSettings to avoid popping modal dialog on the server.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Yassir
Top achievements
Rank 1
Answers by
Stef
Telerik team
Yassir
Top achievements
Rank 1
Share this question
or