Using SaveDocumentToByteArray()

Stimulsoft Reports.WPF discussion
Post Reply
bsilence
Posts: 34
Joined: Wed Feb 13, 2013 12:15 pm

Using SaveDocumentToByteArray()

Post by bsilence »

Hello,

I'm trying to use this method SaveDocumentToByteArray(), to get a byte[] and return to a client, so that this client can then create a pdf file using this byte[] object. For some weird reason, the pdf file created doesn't open because of an error when creating the file.
Do i have to do anything else?

Server:

documentPDF = stiReport.SaveDocumentToByteArray();
return documentPDF;

Client:

byte[] document = target.GetPDFDocumentPreview(doc, true, "Report.mrt");

//Save byte[] in a pdf file
system.IO.File.WriteAllBytes(@"C:\Temp\filetosave.pdf", document);

Thank you for your help.

Best Regards
Bruno Fernandes
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Using SaveDocumentToByteArray()

Post by Alex K. »

Hello,

SaveDocument method save the rendered document in our format - .mdc file, not in PDF. You can use the Export method for save the document as pdf.
Please try to use the following code on client:

Code: Select all

byte[] document = target.GetPDFDocumentPreview(doc, true, "Report.mrt");
...
report.LoadDocument(document);
report.ExportDocument(StiExportFormat.Pdf, @"C:\Temp\filetosave.pdf");
Thank you.
bsilence
Posts: 34
Joined: Wed Feb 13, 2013 12:15 pm

Re: Using SaveDocumentToByteArray()

Post by bsilence »

Thank you for your help.
I just thought that the method SaveDocumentToByteArray(), would save the document to a Byte[], and then i could pick this byte[] and save it to a pdf file.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Using SaveDocumentToByteArray()

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.
Post Reply