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.11
Syntax
public PageInfo GetPageInfo(
	int pageIndex
)

Parameters

pageIndex
Type: SystemInt32
The 0-based page index.

Return Value

Type: PageInfo
Examples
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);
#if NETSTANDARD2_0 || __MOBILE__
            using (SKBitmap bitmap = new SKBitmap(pageSize.Width, pageSize.Height))
            {
                using (SKCanvas canvas = new SKCanvas(bitmap))
                {
                    // Scale to compensate for the larger bitmap
                    canvas.Scale(2);

                    // 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
                    };

                    canvas.DrawPaint(paint);

                    // 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);
                }
            }
#else
            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");
            }
#endif
See Also