简体   繁体   English

Cognos v11 SDK 导出为 pdf

[英]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.

相关问题 Cognos v11 SDK 参数传递 - Cognos v11 SDK Parameter Passing 加载Microsoft Speech SDK v11时出错 - Error loading Microsoft Speech SDK v11 如何从Microsoft.Reporting.WinForms.ReportViewer v11将报告导出到.xls文件 - How to export report to .xls file from Microsoft.Reporting.WinForms.ReportViewer v11 hotchocolate v11 中的 DataLoaderOptions.AutoDispatch - DataLoaderOptions.AutoDispatch in hotchocolate v11 我正在使用 Canon SDK Tutorial V11,但在打开会话时出现错误 SDK Error:0x7 - I am using Canon SDK Tutorial V11 , but I get an error SDK Error:0x7 when I open the session 使用来自Skype呼叫的MemoryStream,使用SAPI 5.4或MS Speech SDK v11在C#中进行语音识别 - Speech Recognition in C# with SAPI 5.4 or MS Speech SDK v11 using a MemoryStream from Skype call Azure 搜索 v11:索引复杂类型的可空集合 - Azure Search v11: Indexing nullable Collection of Complex Type 在Kentico V11中导入对象时出错 - Error while importing object in Kentico V11 Newtonsoft.Json v11-DeserializeObject引发JsonReaderException - Newtonsoft.Json v11 - DeserializeObject throws JsonReaderException Azure.Search.Documents v11 中的 ContinuationToken 在哪里 - Where is ContinuationToken in Azure.Search.Documents v11
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM