We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert doc/docx byte array to pdf and return pdf byte array

I have a byte array of .docx/.doc document and I need to convert this byte array of .docx/.doc to pdf byte array.

I need a function which accepts byte array of .docx/.doc document and return byte array of pdf document.

Is that possible?

And How?


Thanks for your inquiry. Yes, this is possible. Please see the following code for example:

Document doc = new Document(MyDir + “in.docx”);

MemoryStream docStream = new MemoryStream();

doc.Save(docStream, SaveFormat.Doc);

// This represents the input byte array

byte[] docBytes = docStream.ToArray();

// Load Word Document from this byte array

Document loadedFromBytes = new Document(new MemoryStream(docBytes));

// Save Word to PDF byte array

MemoryStream pdfStream = new MemoryStream();

loadedFromBytes.Save(pdfStream, SaveFormat.Pdf);

byte[] pdfBytes = pdfStream.ToArray();

Hope, this helps.

Best regards,