We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ASPOSE.Words 6.0.1 Save Word file to PDF

I upgrade ASPOSE.Words 5.2.0 to latest 6.0.1
Below is my test code:

Aspose.Words.Document doc1 = new Document("c:\\temp\\word.doc");
doc1.Save("c:\\temp\\word.pdf",Aspose.Words.SaveFormat.AsposePdf);

But the saved PDF file can’t be opened in Adobe Reader. Error says “File is damaged…”, however when I open it in Notepad, it turns to be a XML format file.
Any idea? What else should I do to solve this? Thanks in advance.

Hi
Thanks for your request. AsposePdf is intermediate XML used by Aspose.Pdf to generate PDF when you use Aspose.Word+Aspose.Pdf to convert your document to PDF.
Currently there are two ways to convert Word document to PDF.

  1. Direct conversion (without using Aspose.Pdf). Here is code:
Document doc = new Document("in.doc");
doc.SaveToPdf("aw_out.pdf");

or

Document doc = new Document("in.doc");
doc.Save("out.pdf", SaveFormat.Pdf);
  1. Another option is using Aspose.Words+Aspose.Pdf (old method). Here is code:
Document doc = new Document("in.doc");
// Save in intermediate AsposePdf format
MemoryStream aPdfStream = new MemoryStream();
doc.Save(aPdfStream, SaveFormat.AsposePdf);
// Create Aspose.Pdf.Pdf document
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(aPdfStream, null);
// Save pdf
pdf.Save("out.pdf");

Best regards.

Thanks very much. That works!