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");

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.

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");


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

Best regards.

Thanks very much. That works!