DocumentGetPageInfo Method
Gets the page size, orientation and other information about a page that might be useful for printing or rendering.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
public PageInfo GetPageInfo(
	int pageIndex


Type: SystemInt32
The 0-based page index.

Return Value

Type: PageInfo
Renders a page of a Word document into a bitmap using a specified zoom factor.

Document doc = new Document(MyDir + "Rendering.doc");

            PageInfo pageInfo = doc.GetPageInfo(0);

            // Let's say we want the image at 50% zoom.
            const float myScale = 0.50f;

            // Let's say we want the image at this resolution.
            const float myResolution = 200.0f;

            Size pageSize = pageInfo.GetSizeInPixels(myScale, myResolution);
            using (SKBitmap bitmap = new SKBitmap(pageSize.Width, pageSize.Height))
                using (SKCanvas canvas = new SKCanvas(bitmap))
                    // Scale to compensate for the larger bitmap

                    // Fill the page background.
                    // If you need to set color without specific options, you can use "canvas.Clear(SKColors.White);"
                    SKPaint paint = new SKPaint
                        Color = SKColors.White,
                        IsAntialias = true,
                        FilterQuality = SKFilterQuality.High


                    // Render the page using the zoom.
                    doc.RenderToScale(0, canvas, 0, 0, myScale);

                using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "Rendering.RenderToScale.png"))
                    bitmap.PeekPixels().Encode(fs, SKEncodedImageFormat.Png, 100);
            using (Bitmap img = new Bitmap(pageSize.Width, pageSize.Height))
                img.SetResolution(myResolution, myResolution);

                using (Graphics gr = Graphics.FromImage(img))
                    // You can apply various settings to the Graphics object.
                    gr.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

                    // Fill the page background.
                    gr.FillRectangle(Brushes.White, 0, 0, pageSize.Width, pageSize.Height);

                    // Render the page using the zoom.
                    doc.RenderToScale(0, gr, 0, 0, myScale);

                img.Save(ArtifactsDir + "Rendering.RenderToScale.png");
See Also