Hello,
We’re tyring out different APIs for converting Word documents to PDF on the fly on our website, and Aspose.Pdf and Aspose.Word seems to be a good option. But before buying the license we want to make sure it can handle our files and do what we want.
Right now I’m having a problem opening the created pdf document in the browser or acrobat. But, if I save the pdf to disk, it opens without any problems. I get this error: “There was an error opening the document. The file is damaged and could not be repaired.” First I had a more complex word document, but I’ve also tried a word document with one single line of text.
Here’s my code:
Aspose.Word.License word = new Aspose.Word.License();
Document doc = new Document(“c:\Temp\gb.doc”);
MemoryStream memStream = new MemoryStream();
byte[] buffer = new byte[1024];
doc.Save(memStream, SaveFormat.FormatAsposePdf);
memStream.Seek(0, SeekOrigin.Begin);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(memStream);
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(xmlDoc, null);
[//pdf.Save](https://pdf.save/)(“c:\temp\testpdf.pdf”);
pdf.Save(“test.pdf”, Aspose.Pdf.SaveType.OpenInBrowser, Response);
Regards,
Jan-Erik Rom?ren