Free Support Forum - aspose.com

Word and PDF conversion

I would like to know how to convert word and PDF files to place them on my website, reading them as they are opened on the computer

Hi there,


Thanks for your inquiry. Please check the documentation link for sending document to client browser while converting a document.

If document already exist then you can use following code snippet for the purpose.

byte[] pdfBytes = File.ReadAllBytes(“yourPdfDocument.pdf”);<span style=“font-size:9.0pt;font-family:“Arial”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;color:#333333”><o:p></o:p>

Response.Clear();

//Specify the document type.

Response.ContentType = "application/pdf";

//Other options:

// Response.ContentType = "application/msword"

//Response.ContentType = "text/plain"

//Response.ContentType = "text/html"

//Specify how the document is sent to the browser.

Response.AddHeader("content-disposition", "attachment; filename=test.pdf");

//Another option could be:

//Response.AddHeader "content-disposition","inline; filename=MyDocument.doc";

//Get data bytes from the stream and send it to the response.

Response.BinaryWrite(bytes);

<span style=“font-size:10.0pt;line-height:115%;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#333333;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Response.End();

<span style=“font-size:10.0pt;line-height:115%;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#333333;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>
<span style=“font-size:10.0pt;line-height:115%;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#333333;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>
Best Regards,