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

Free Support Forum - aspose.com

Set Image Size (Width Height) during Word to PNG Conversion using C# .NET or Java | Render Page to Graphics Object of Specified Size

Hello

the save option have only a resolution parameter for the png convertion of a word document.

are they a parameter in ImageSaveOptions or a method to define the size of the png produce by aspose

Best regards

Fabien

@fabien.levalois,

You can simply adjust the Dimensions of generated PNG image files by using PageSetup.PageWidth and PageSetup.PageHeight properties. For example, the following C# code will produce PNG images of 500 x 500 height and width:

Document doc = new Document("C:\\Temp\\in.docx");

foreach (Section sec in doc.Sections)
{
    sec.PageSetup.PageWidth = ConvertUtil.PixelToPoint(500);
    sec.PageSetup.PageHeight = ConvertUtil.PixelToPoint(500);
}

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
options.PageCount = 1;
int pageCountDoc = doc.PageCount;
for (int pageCount = 0; pageCount < pageCountDoc; pageCount++)
{
    options.PageIndex = pageCount;
    doc.Save("C:\\Temp\\out_" + pageCount + ".png", options);
}

You can also use ImageSaveOptions.Scale Property to calculate needed scale. Or render document’s page to Graphics object using Document.RenderToSize Method.

Hi awais

I use renderToSize and it works as i need
Thank you