[英]Cognos v11 SDK export to pdf
Does anyone have an example that will generate a report as PDF using the sdk?有没有人有一个示例,可以使用 sdk 生成 PDF 格式的报告? The SDK.pdf only has html examples. SDK.pdf 只有 html 示例。 I can't figure it out.我想不通。 I'm using ac# controller to call cognos to generate the report.我正在使用 ac# 控制器调用 cognos 来生成报告。
The runOptionStringArray value must be PDF. runOptionStringArray 值必须是 PDF。
outputFormat.value = new string[] { "PDF" };
The data i get back from the call looks like this: "JVBERi0xLjQKJeLjz9MNCjQgMCBvYmoKPDwvTGluZWFyaXplZCAxL0wgICAgIDExOTEyOC9IWyAgICAgICA1ODggICAgICAgIDE2MV0vTyA2L0UgICAgIDExODAzMi9OIDEvVCAgICAgMTE5MDAyPj4KZW5kb2JqCnhyZWYNCjQgMTUNCjAwMDAwMDAwMTYgMDAwMDAgbg0KMDAwMDAwMDc0OSAwMDAwMCBuDQowM"数据我从调用看起来像这样得到的:“JVBERi0xLjQKJeLjz9MNCjQgMCBvYmoKPDwvTGluZWFyaXplZCAxL0wgICAgIDExOTEyOC9IWyAgICAgICA1ODggICAgICAgIDE2MV0vTyA2L0UgICAgIDExODAzMi9OIDEvVCAgICAgMTE5MDAyPj4KZW5kb2JqCnhyZWYNCjQgMTUNCjAwMDAwMDAwMTYgMDAwMDAgbg0KMDAwMDAwMDc0OSAwMDAwMCBuDQowM”
I've tried this, but it still doesn't render as pdf.我试过这个,但它仍然没有呈现为pdf。
asynchReply res = cBIRS.run( reportPath, parameters, runOptions );
// The report is finished, let's fetch the results and save them to a file.
string data = null;
if( res.status == asynchReplyStatusEnum.complete )
{
for (int i = 0; i < res.details.Length; i++)
{
if (res.details[i] is asynchDetailReportOutput)
{
data = ( (asynchDetailReportOutput)res.details[i]).outputPages[0];
}
}
FileStream fs = new FileStream(outputPath, FileMode.Create);
byte[] hunk_data = UTF8Encoding.UTF8.GetBytes(data);
fs.Write(hunk_data, 0, hunk_data.Length);
fs.Close();
}
In the end the pdf does have data, but it can't be opened by adobe.最后pdf确实有数据,但是adobe打不开。
PS.附注。 I've also tried writing out the file without using the UTF8Encoding.UTF8.GetBytes and just using System.IO.File.WriteAllText(outputPath,data);我也试过在不使用 UTF8Encoding.UTF8.GetBytes 的情况下写出文件,只使用 System.IO.File.WriteAllText(outputPath,data); That doesn't work either.那也行不通。
Replace代替
byte[] hunk_data = UTF8Encoding.UTF8.GetBytes(data);
With和
byte[] hunk_data = Convert.FromBase64String(data);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.