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;
XmlDocument xmlDoc = new XmlDocument();
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.Save(“test.pdf”, Aspose.Pdf.SaveType.OpenInBrowser, Response);
Thank you for considering Aspose.
Can you please send an example which can reproduce the error to me?
FYI: The solution was very simple: I had forgot to end the response.
pdf.Save(“test.pdf”, Aspose.Pdf.SaveType.OpenInAcrobat, System.Web.HttpContext.Current.Response);
Thanks for the info. Fixed my problem also..
Well, I thought I had everything under control now, but it seems there’s more to be solved.
First of all. By ending the response, the pdf worked, but I encountered another problem; after opening the pdf, there are more code I want to run, but since I’m ending the response, the code won’t run.
Do anyone have any idea how this can be solved?