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

Free Support Forum - aspose.com

How to save all Word pages to JPG using .NET

Hello,

Document.Save(String) Method says it “Saves the document to a file.”, however when I call this function with JPG target format, only first page is saved. Either the description is misleading or the function has an error.

How do I correctly save all Word pages?

@YuriGubanov

Please use following code example to convert all pages of Word document to JPG images.

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

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Jpeg);
options.PageSavingCallback = new HandlePageSavingCallback();
options.PageCount = doc.PageCount;
options.PageIndex = 0;

doc.Save(MyDir + "Out.jpg", options);

private class HandlePageSavingCallback : IPageSavingCallback
{
    public void PageSaving(PageSavingArgs args)
    {
        args.PageFileName = string.Format(MyDir + @"Page_{0}.jpg", args.PageIndex);
    }
}
1 Like