We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Saving an IWorkBook to a PDFDocument

Thread ID:

Created:

Updated:

Platform:

Replies:

52897 Dec 5,2006 03:59 PM Dec 11,2006 07:27 PM Windows Forms 6
loading
Tags: XlsIO
Shannon Broskie
Asked On December 5, 2006 03:59 PM

Hello,
I just installed v4.4 hoping to use the new save XLS to PDF functionality.

I getting an error when trying to create the PDFDocument object. It tells me I have invalid/unknown/unsupported PDF format. I've been trying to piece together bits from other posts and have not found anything on the final method to do this. I realize that the PDFDocument class constructor is probably looking for a stream with pdf content already in it but I am having a hard time even finding the OpenXML method shown in other posts.

Thanks

MemoryStream stream = new MemoryStream();
workbook.SaveAsXml(stream, ExcelXmlSaveType.DLS);
PDFDocument pdfDoc = new PDFDocument(stream);
pdfDoc.Save(fileName);

Chella Pandian B [Syncfusion]
Replied On December 5, 2006 05:52 PM

Hi Shannon Broskie,

I have created a sample for saving a excel sheet to a PDF. Please check the sample and let me know if you have any other difficulties.

Sample:
ExcelToPDF.zip

Thank for your interest in XlsIO.

With regards,
Chella.


Shannon Broskie
Replied On December 6, 2006 08:45 AM

Thanks for the sample. I have a couple of questions about the sample.

According to the code, 'Hello World' should have shown up in the PDF. If I run the code, a blank PDF document is created.

Secondly, I modified the code to save to a MemoryStream instead of a file. One note there is that after saving the workbook to a stream, you need to set the Position of the stream back to 0 or you will get a root element not found error. Even using a stream though, I'm not getting the 'Hello World' text. The XML output does indead contain the 'Hello World' text though.

Any thoughts on what I might try to get the PDF generation working?

I'm running VS2005.

Thanks again.

Chella Pandian B [Syncfusion]
Replied On December 6, 2006 02:52 PM

Hi Shannon Broskie,

I am afraid that I was unable to reproduce your problem.

Ans:
1. The sample shows the pdf file with “Hello world”.

2. I have modified the sample as per your requirement. This samples creates a memory stream object and converts that stream into a xml file and then save it to pdf.

Please check the new sample, which converts memory stream to PDF and Let me know if you have any other difficulties.

Sample:

ExcelToPDF.zip

Sorry for the inconvenience.
Thanks for using XlsIO.

Best regards,
Chella.

Shannon Broskie
Replied On December 8, 2006 10:15 AM

Thanks again for your post. I've attached a recording of me opening up your solution along with the results. The only thing I have to change is the references to Syncfusion.DLS.Base and Syncfusion.Pdf.Base as they were pointing to version 4.202.0.37 and I'm running the latest 4.4.0.51

Let me know what you think. Hope you enjoy the movie.

Syncfusionxlstopdf.zip

Chella Pandian B [Syncfusion]
Replied On December 8, 2006 06:36 PM

Hi Shannon Broskie ,

I seriously regret for the previous sample. I was able to reproduce the issue. I will take this issue with high priority and discuss this with my team and get back to with in 2 days.

We are extremely sorry for the inconvenience.

With regards,
Chella.

Chella Pandian B [Syncfusion]
Replied On December 11, 2006 07:27 PM

Hi Shannon,

I regret for the delay in getting back to you. I have created a bug report regarding this issue. Please check this following link for further updates. Please let us know if you have any other difficulties in using XlsIO.

Open issue link:
http://www.syncfusion.com/support/issues/xlsio/Default.aspx?ToDo=view&questId=3176

Thank you for your interest in Syncfusion Essential XlsIO.

Regards,
Chella

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;