Word 2007 document to pdf conversion

Hi,

I have tried to convert a word 2007 document to pdf format. I am not getting any errors while converting but when i tried to open the generated pdf, its saying that the file is damaged.

Shankar.

Hi

Thanks for your inquiry. Could you please attach your input document here for testing? I will check the problem on my side and provide you more information.

Best regards,

Hi,

I have attached the docx file that I have tried to convert to pdf.

Thanks,

Shankar.

Hi

Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words 9.0.0. The latest version you can download here:

https://downloads.aspose.com/words/net

Best regards,

Hi,

Its working fine with new dlls.

Is it possible to convert a remote document to pdf? I am trying to do it but it is not working. Can you please guide me?

Thanks in Advance

Shankar.

Hi Shankar,

Thanks for your inquiry. Yes, of course, you can achieve this. For example, you can try using the following code to load your document from URL:

string url = @"http://localhost/mysite/mydocument.doc";
// Prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/msword";
request.UserAgent = "Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0";
// Execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// We will read data via the response stream
Stream resStream = response.GetResponseStream();
// Write content into the MemoryStream
BinaryReader resReader = new BinaryReader(resStream);
MemoryStream docStream = new MemoryStream(resReader.ReadBytes((int)response.ContentLength));
Document doc = new Document(docStream);
// Save document
doc.SaveToPdf("out.pdf");

Hope this helps.

Best regards,