If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Save to PDF using Cognos SDK

Started by swiyyala, 27 Aug 2015 01:10:10 PM

Previous topic - Next topic

swiyyala

Hi all,

I have the below questions which I have been stuck on for a while. Sincerely hoping someone will help me out on it or point me in the right direction.

When I try to save the report to PDF I get the "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters"

//Output format
            runOptionStringArray outputFormat = new runOptionStringArray();
            outputFormat.name = runOptionEnum.outputFormat;
            outputFormat.value = new string[] { "PDF" };
            reportType = outputFormat.value[0].ToString();
            runOptions[1] = outputFormat;

//Run the report
                res = repService.run(irReportPath, parameters, runOptions);

using(FileStreamfs = new FileStream(outputPath, FileMode.Append))

                                {

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

                                    //If I use the above I get the not a supported file type error when I open the saved pdf since it is not decoded properly.                   

                                    fs.Write(binaryOutput, 0, binaryOutput.Length);
                         }

If I use the byte[] binaryOutput = Convert.FromBase64String(data)instead of the code above it wouldn't even convert the data it would straight on throw an error not a valid Base-64 string.

How are you all able to get that to work from your end? Should I be replacing any special characters or so in the output data before converting it?

 

Andrew Weiss

How are you getting "data"?  I don't see that being assigned in your code.  Convert.FromBase64String should be correct assuming that the output is complete and you received the base 64 encoded binary data.  It's possible it's a prompted report and the data is HTML!  Spit the data out to the console and I bet you'll see what's going on.  If it's a problem with the report still running then you can cheat and set the primaryWaitThreshold to 0 so that you don't have to deal with the asynch loop (or asynch waltz as I like to call it).

-Andy
MetaManager makes administering IBM Cognos a breeze.  http://www.bspsoftware.com/MetaManager