Page 1 of 1

Using SaveDocumentToByteArray()

Posted: Fri Jun 28, 2013 2:42 pm
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

Re: Using SaveDocumentToByteArray()

Posted: Mon Jul 01, 2013 10:43 am
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.

Re: Using SaveDocumentToByteArray()

Posted: Mon Jul 01, 2013 10:59 am
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.

Re: Using SaveDocumentToByteArray()

Posted: Mon Jul 01, 2013 12:36 pm
by Alex K.
Hello,

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