Extracting pages from Word byte[]

Hello,

I would like to find out if it possible to convert specific pages (a range of pages) of a word document byte[] into an image byte[].

I didn’t find a way for that in the documentation.

I hope someone can help,

Thank you,

Eyal.

Hi Eyal,

Thanks for your inquiry. Yes, you can convert specific page of Word document into image byte[] by using following code snippet. Please note that Document’s Constructor does not take byte array as input. First you need to convert byte array into steam object and then load it into Aspose.Word DOM. I suggest you please read the members of ImageSaveOptions from here:

https://reference.aspose.com/words/net/aspose.words.saving/imagesaveoptions/

Byte[] bytes = File.ReadAllBytes(MyDir + "in.doc");
MemoryStream mStream = new MemoryStream(bytes);
Document doc = new Document(mStream); 
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff);
options.Resolution = 300;
options.PageIndex = 1;
options.PageCount = 1;
MemoryStream SaveStream = new MemoryStream();
doc.Save(SaveStream, options);
Byte[] image = SaveStream.ToArray();

Hope this helps you. Please let us know if you have any more queries.