Free Support Forum - aspose.com

Re: Is it possible to convert document(doc/docx) byte[] array to .pdf byte array directly

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Of course, you can achieve this. You can try using code like the following:

///

/// Converts document to PDF and returns PDF document's bytes.

///

private byte[] DocumentToPdfBytes(Document doc)

{

byte[] pdfBytes;

using (MemoryStream pdfStream = new MemoryStream())

{

doc.SaveToPdf(0, doc.PageCount, pdfStream, null);

pdfBytes = pdfStream.ToArray();

}

return pdfBytes;

}

Hope this helps. Please let me know in case of any issues, I will be glad to help you.

Best regards,