Cognos v11 SDK导出为pdf [英] Cognos v11 SDK export to pdf

查看:100
本文介绍了Cognos v11 SDK导出为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人举一个使用sdk生成PDF格式报告的示例? SDK.pdf仅具有html示例.我不知道.我正在使用c#控制器调用cognos来生成报告.

Does anyone have an example that will generate a report as PDF using the sdk? The SDK.pdf only has html examples. I can't figure it out. I'm using a c# controller to call cognos to generate the report.

runOptionStringArray的值必须为PDF.

The runOptionStringArray value must be PDF.

outputFormat.value = new string[] { "PDF" };

在数据我回来从调用看起来是这样的:JVBERi0xLjQKJeLjz9MNCjQgMCBvYmoKPDwvTGluZWFyaXplZCAxL0wgICAgIDExOTEyOC9IWyAgICAgICA1ODggICAgICAgIDE2MV0vTyA2L0UgICAgIDExODAzMi9OIDEvVCAgICAgMTE5MDAyPj4KZW5kb2JqCnhyZWYNCjQgMTUNCjAwMDAwMDAwMTYgMDAwMDAgbg0KMDAwMDAwMDc0OSAwMDAwMCBuDQowM"

The data i get back from the call looks like this: "JVBERi0xLjQKJeLjz9MNCjQgMCBvYmoKPDwvTGluZWFyaXplZCAxL0wgICAgIDExOTEyOC9IWyAgICAgICA1ODggICAgICAgIDE2MV0vTyA2L0UgICAgIDExODAzMi9OIDEvVCAgICAgMTE5MDAyPj4KZW5kb2JqCnhyZWYNCjQgMTUNCjAwMDAwMDAwMTYgMDAwMDAgbg0KMDAwMDAwMDc0OSAwMDAwMCBuDQowM"

我已经尝试过了,但是它仍然不能呈现为pdf.

I've tried this, but it still doesn't render as 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();
}

最后pdf确实有数据,但是Adobe无法打开它.

In the end the pdf does have data, but it can't be opened by adobe.

PS.我也尝试过不使用UTF8Encoding.UTF8.GetBytes而是仅使用System.IO.File.WriteAllText(outputPath,data)来写出文件;那也不行.

PS. I've also tried writing out the file without using the UTF8Encoding.UTF8.GetBytes and just using System.IO.File.WriteAllText(outputPath,data); That doesn't work either.

推荐答案

替换

 byte[] hunk_data = UTF8Encoding.UTF8.GetBytes(data);

使用

 byte[] hunk_data = Convert.FromBase64String(data);

这篇关于Cognos v11 SDK导出为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆