Saving an IWorkBook to a PDFDocument
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);
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);
SIGN IN To post a reply.
6 Replies
CP
Chella Pandian B
Syncfusion Team
December 5, 2006 10:52 PM UTC
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.
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.
SB
Shannon Broskie
December 6, 2006 01:45 PM UTC
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.
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.
CP
Chella Pandian B
Syncfusion Team
December 6, 2006 07:52 PM UTC
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.
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.
SB
Shannon Broskie
December 8, 2006 03:15 PM UTC
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
Let me know what you think. Hope you enjoy the movie.
Syncfusionxlstopdf.zip
CP
Chella Pandian B
Syncfusion Team
December 8, 2006 11:36 PM UTC
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.
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.
CP
Chella Pandian B
Syncfusion Team
December 12, 2006 12:27 AM UTC
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
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
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
SB Shannon Broskie
- Dec 5, 2006 08:59 PM UTC
- Dec 12, 2006 12:27 AM UTC