To export a report to PDF

Parent Previous Next

 

Report Application Server .NET SDK Developer Guide

To export a report to PDF


 







  1. Set the export format type to PDF and use the PrintOutputController object to export the report to a ByteArray object.

Visual Basic

Dim rasPrintOutputController As PrintOutputController
Dim rasReportExportFormat As CrReportExportFormatEnum
rasReportExportFormat = CrReportExportFormatEnum.crReportExportFormatPDF
rasPrintOutputController = rcd.PrintOutputController
Dim tempByteArray As ByteArray = rasPrintOutputController.Export(rasReportExportFormat, 0)
Dim byteStreamOutput As Byte() = tempByteArray.ByteArray

C#

PrintOutputController rasPrintOutputController;
CrReportExportFormatEnum rasReportExportFormat;
rasReportExportFormat = CrReportExportFormatEnum.crReportExportFormatPDF;
rasPrintOutputController = rcd.PrintOutputController;
ByteArray tempByteArray = rasPrintOutputController.Export(rasReportExportFormat, 0);
Byte[] byteStreamOutput = tempByteArray.ByteArray;

  1. Clear the Response object and stream the file using the BinaryWrite method.

Visual Basic

Response.Clear()
Response.AddHeader("content-disposition", "inline;filename=untitled.pdf")
Response.ContentType = "application/pdf"
Response.BinaryWrite(byteStreamOutput)
Response.[End]()

C#

Response.Clear();
Response.AddHeader("content-disposition", "inline;filename=untitled.pdf");
Response.ContentType = "application/pdf";
Response.BinaryWrite(byteStreamOutput);
Response.End();

Visual Basic

Private Sub ExportReportToPDF(ByVal rcd As ISCDReportClientDocument)
 Dim rasPrintOutputController As PrintOutputController
 Dim rasReportExportFormat As CrReportExportFormatEnum
 rasReportExportFormat = CrReportExportFormatEnum.crReportExportFormatPDF
 rasPrintOutputController = rcd.PrintOutputController
 Dim tempByteArray As ByteArray = rasPrintOutputController.Export(rasReportExportFormat, 0)
 Dim byteStreamOutput As Byte() = tempByteArray.ByteArray
 Response.Clear()
 Response.AddHeader("content-disposition", "inline;filename=untitled.pdf")
 Response.ContentType = "application/pdf"
 Response.BinaryWrite(byteStreamOutput)
 Response.[End]()
End Sub

C#

private void ExportReportToPDF(ISCDReportClientDocument rcd)
{
 PrintOutputController rasPrintOutputController;
 CrReportExportFormatEnum rasReportExportFormat;
 rasReportExportFormat = CrReportExportFormatEnum.crReportExportFormatPDF;
 rasPrintOutputController = rcd.PrintOutputController;
 ByteArray tempByteArray = rasPrintOutputController.Export(rasReportExportFormat, 0);
 Byte[] byteStreamOutput = tempByteArray.ByteArray;
 Response.Clear();
 Response.AddHeader("content-disposition", "inline;filename=untitled.pdf");
 Response.ContentType = "application/pdf";
 Response.BinaryWrite(byteStreamOutput);
 Response.End();
}

This list includes the namespaces used by the sample code:

© 2021 SAP AG. All rights reserved.

http://www.sap.com/sapbusinessobjects/

Support services

http://service.sap.com/bosap-support/

Created with the Personal Edition of HelpNDoc: Generate EPub eBooks with ease