I just started playing with Telerik Reporting. I'm hoping to migrate a simple single page report I currently do in .net using PDFGenerator.
With PDFGenerator you can embed javascript. In my case I add the following line:
MyDocument.JavaScripts.Add(New DocumentJavaScript("print", "this.print({bUI: false, bSilent: true, bShrinkToFit: true});"))
Which results in the PDF file going straight to the printer.
I created the following code in a new .aspx file using sample code I found in the docs.
This code generates a PDF directly just like my PDFGenerator code.
How do I embed javascript directly in the PDF generated by the Telerik Reporting control?
With PDFGenerator you can embed javascript. In my case I add the following line:
MyDocument.JavaScripts.Add(New DocumentJavaScript("print", "this.print({bUI: false, bSilent: true, bShrinkToFit: true});"))
Which results in the PDF file going straight to the printer.
I created the following code in a new .aspx file using sample code I found in the docs.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
Dim report As New Telerik.Reporting.Report() |
Dim detail As New Telerik.Reporting.DetailSection() |
Dim textBox2 As New Telerik.Reporting.TextBox() |
textBox2.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch)) |
textBox2.Value = "Hello World!" |
textBox2.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(1.25, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch)) |
textBox2.Size = New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(4.75, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0.25, Telerik.Reporting.Drawing.UnitType.Inch)) |
detail.Items.AddRange(New Telerik.Reporting.ReportItemBase() {textBox2}) |
detail.Height = New Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch) |
report.Items.Add(DirectCast(detail, Telerik.Reporting.ReportItemBase)) |
ExportToPDF("Test", report) |
End Sub |
Sub ExportToPDF(ByVal reportName As String, ByVal reportToExport As Telerik.Reporting.Report) |
Dim mimeType As StringString = String.Empty |
Dim ext As StringString = String.Empty |
Dim encoding As EncodingEncoding = Encoding.[Default] |
Dim reportBytes As Byte() = ReportProcessor.Render("PDF", reportToExport, Nothing, mimeType, ext, encoding) |
Dim fileName As String = reportName + ".pdf" |
Response.Clear() |
Response.ContentType = mimeType |
Response.Cache.SetCacheability(HttpCacheability.[Private]) |
Response.Expires = -1 |
Response.Buffer = False |
Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", fileName)) |
Response.OutputStream.Write(reportBytes, 0, reportBytes.Length) |
Response.[End]() |
End Sub |
This code generates a PDF directly just like my PDFGenerator code.
How do I embed javascript directly in the PDF generated by the Telerik Reporting control?