SDK sample to retrieve (PDF,CSV) report results using the SDK.
When calling the execute method using the Cognos SDK if you are trying to retrieve output formats other than (HTML, HTMLFragment, XML) I.E (CSV or PDF) the results must be Base64 decoded.
Java and C#
Resolving the problem
After the execute/run method is called determine what format the execute method was called with. If the execute method was called with CSV or PDF then the result will be base64 encoded.
The following sample code is what has been added to the code to base64 encode the results of the CSV or PDF report.
Base64 b64 = new Base64(); // needed to convert PDF or CSV output to binary.
byte binaryOutput = null;
if (format.equals("PDF") || format.equals("CSV" ))
binaryOutput = b64.decode(textOutput); // decode the PDF/CSV output to array of bytes.
Ensure the the Go Sales and Retailers sample package is setup/deployed properly. This sample will execute the following report in Go Sales and Retailers.
/folder[@name='Documentation Report Samples']/report[@name='Add Color']
- Extract the attached files and modify the code to use a valid endpoint URL.
- Modify the localhost string to use a correct server name.
- Ensure that anonymous logon in Cognos Configuration is enabled.
- Compile and run. The resulting output will be saved on the local file system. c:\reportOutput.<format>
- Modify the following line of code if you wish to execute a report in a format other than PDF.
emf.executeReport(reportPath,"PDF"); // change format to (PDF, CSV, HTML, HTMLFragment, XML)
- Re-compile and re-execute.
/cognos8Compatible = CRN deprecated methods compatible with Cognos8.1 & 8.2, NOT 8.3
/cognos8 = Cognos 8.1 and Cognos 8.2
/cognos10_1 = Cognos 10.1
/cognos10_2 = Cognos 10.2
More support for:
Cognos Business Intelligence
Software Development Kit
Software version: 8.3, 8.4, 8.4.1, 10.1, 10.1.1, 10.2
Operating system(s): AIX, HP Itanium, HP-UX, Linux, Solaris, Windows
Reference #: 1343829
Modified date: 04 January 2011