繁体   English   中英

Cognos v11 SDK 导出为 pdf

[英]Cognos v11 SDK export to pdf

有没有人有一个示例,可以使用 sdk 生成 PDF 格式的报告? SDK.pdf 只有 html 示例。 我想不通。 我正在使用 ac# 控制器调用 cognos 来生成报告。

runOptionStringArray 值必须是 PDF。

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

数据我从调用看起来像这样得到的:“JVBERi0xLjQKJeLjz9MNCjQgMCBvYmoKPDwvTGluZWFyaXplZCAxL0wgICAgIDExOTEyOC9IWyAgICAgICA1ODggICAgICAgIDE2MV0vTyA2L0UgICAgIDExODAzMi9OIDEvVCAgICAgMTE5MDAyPj4KZW5kb2JqCnhyZWYNCjQgMTUNCjAwMDAwMDAwMTYgMDAwMDAgbg0KMDAwMDAwMDc0OSAwMDAwMCBuDQowM”

我试过这个,但它仍然没有呈现为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打不开。

附注。 我也试过在不使用 UTF8Encoding.UTF8.GetBytes 的情况下写出文件,只使用 System.IO.File.WriteAllText(outputPath,data); 那也行不通。

代替

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM