Cells 4.7.0 saving to PDF stream does not work

Hi, i'm trying to save an workbook to pdf via a stream(filestream) directly:

workbook.Save( stream, FileFormatType.Pdf);

Then i try to save this stream to a file and the resulted file is not readable by AcrobatReader.


Thank you very much for your feedback.

Hi Claudiu,

Thank you for providing the sample application.

We will look into the direct XLS2PDF conversion using File Streams. Currently, as a work around, either you can save the XLS file to PDF directly without using the File Stream (wb.Save(“c:\MyPDF.PDF”, FileFormatType.Pdf)) or you can use Aspose.Cells and Aspose.PDF combination to generate a PDF from XLS using File Stream. Please see the following sample code in this regard,

Sample Code:


Workbook wb = new Workbook();

wb.Worksheets.Clear();

Worksheet ws1 = wb.Worksheets.Add("shee1");

ws1.Cells[0, 0].PutValue("SampleHeader1");

ws1.Cells[0, 2].PutValue("SampleHeader2");

wb.Save("c:\\MySpreadsheet2.xml", FileFormatType.AsposePdf);

using (FileStream fs = File.Create(@"C:\sample2.pdf"))

{

Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf(fs);

pdf1.BindXML("c:\\MySpreadsheet2.xml", null);

pdf1.Close();

fs.Close();

}

Thank You & Best Regards,

Hi,

Thank you for considering Aspose.

Please try the attached latest fix. We have supported to directly export workbook to PDF stream.

Thank You & Best Regards,

Still doesn’t work in my case. The converted pdf file seems to be corrupt. (Thats what Acrobat says)


I tried both xls and xlsx. Nothing special in these files. Just some testtext and a single image.

Edit:
Same problem when converting from file to file, like the example

//Instantiate the Workbook object

Workbook workbook = new Workbook();

//Open an excel file

workbook.Open(“f:\test\Input.xls”);

//Save the document in Pdf format

workbook.Save(f:\test\Output.pdf, FileFormatType.Pdf);

Hi,

Thank you for considering Aspose.

We have found the issue when we convert the XLS2PDF using file stream but it works fine in the direct file conversion. Please share your template file and we will look into it.

Thank You & Best Regards,

As allready said, a very simple excel workbook.

pyranha:
Still doesn't work in my case. The converted pdf file seems to be corrupt. (Thats what Acrobat says)

I tried both xls and xlsx. Nothing special in these files. Just some testtext and a single image.
Thanks for your feedback, we will look into it soon.
pyranha:
Edit:
Same problem when converting from file to file, like the example

//Instantiate the Workbook object

Workbook workbook = new Workbook();

//Open an excel file

workbook.Open("f:\\test\\Input.xls");

//Save the document in Pdf format

workbook.Save("f:\\test\\Output.pdf", FileFormatType.Pdf);

Well, I don't find any problem using the above code (directly converting excel file to pdf....file2file conversion), the ouput pdf file is ok. Could you post your input file here, we will check it soon.

Thank you.

Hi,

Thanks for sharing your testexcel.xlsx file here.

I tried the conversion using the following code and it works fine. The ouput file (attached) opened fine into Acrobat Reader.

Sample code:

//Instantiate the Workbook object
Workbook workbook = new Workbook();

//Open an excel file
workbook.Open("f:\\test\\testexcel.xlsx");

//Save the document in Pdf format
workbook.Save("f:\\test\\testOutputexcel.pdf", FileFormatType.Pdf);

Thank you.

ok direkt file to file conversion works… was another problem, my mistake. I’m sorry for the unnecessary effort.

Hi, I just tried the fix 4.7.0.1.
Unfortunatelly with sample i have attached on the first message post of this thread post , it does not work.
I have updated the references to this new Aspose.Cells assembly so basically it should work if your fix have resolved this issue.
I have Adobe Reader 8.1.3. and the message when i try to open the pdf file is:
"There was an error opening this document. The file is damaged and could not be repaired."
In the attachment is the result pdf file.

Thank you for your feedback.

Hi Claudiu,

Thank you for considering Aspose.

We are working on resolving your mentioned issue and we will get back to you soon.

Thank you for understanding,

Hi,

Thanks for providing us the template file.

Hopefully, we can provide you the fix in 1-2 days for your need.

Thanks and keep in touch.

Hi,

Please try the attached version (4.7.0.2), we have fixed the issue.

Thank you.