PageInfo Class

Represents information about a particular document page.

Inheritance Hierarchy

SystemObject
  Aspose.Words.RenderingPageInfo

Namespace:  Aspose.Words.Rendering
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0

Syntax

public class PageInfo

The PageInfo type exposes the following members.

Properties

  NameDescription
Public propertyCode exampleHeightInPoints
Gets the height of the page in points.
Public propertyCode exampleLandscape
Returns true if the page orientation specified in the document for this page is landscape.
Public propertyCode examplePaperSize
Gets the paper size as enumeration.
Public propertyCode examplePaperTray
Gets the paper tray (bin) for this page as specified in the document. The value is implementation (printer) specific.
Public propertyCode exampleSizeInPoints
Gets the page size in points.
Public propertyCode exampleWidthInPoints
Gets the width of the page in points.

Methods

  NameDescription
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetDotNetPaperSize
Gets the PaperSize object suitable for printing the page represented by this PageInfo.
Public methodGetHashCode (Inherited from Object.)
Public methodGetSizeInPixels(Single, Single)
Calculates the page size in pixels for a specified zoom factor and resolution.
Public methodCode exampleGetSizeInPixels(Single, Single, Single)
Calculates the page size in pixels for a specified zoom factor and resolution.
Public methodCode exampleGetSpecifiedPrinterPaperSource
Gets the PaperSource object suitable for printing the page represented by this PageInfo.
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)

Remarks

The page width and height returned by this object represent the "final" size of the page e.g. they are already rotated to the correct orientation.

Examples

Shows how to print page size and orientation information for every page in a Word document.
Document doc = new Document(MyDir + "Rendering.docx");

// The first section has 2 pages
// We will assign a different printer paper tray to each one, whose number will match a kind of paper source
// These sources and their Kinds will vary depending on the installed printer driver
PrinterSettings.PaperSourceCollection paperSources = new PrinterSettings().PaperSources;

doc.FirstSection.PageSetup.FirstPageTray = paperSources[0].RawKind;
doc.FirstSection.PageSetup.OtherPagesTray = paperSources[1].RawKind;

Console.WriteLine("Document \"{0}\" contains {1} pages.", doc.OriginalFileName, doc.PageCount);

float scale = 1.0f;
float dpi = 96;

for (int i = 0; i < doc.PageCount; i++)
{
    // Each page has a PageInfo object, whose index is the respective page's number
    PageInfo pageInfo = doc.GetPageInfo(i);

    // Print the page's orientation and dimensions
    Console.WriteLine($"Page {i + 1}:");
    Console.WriteLine($"\tOrientation:\t{(pageInfo.Landscape ? "Landscape" : "Portrait")}");
    Console.WriteLine($"\tPaper size:\t\t{pageInfo.PaperSize} ({pageInfo.WidthInPoints:F0}x{pageInfo.HeightInPoints:F0}pt)");
    Console.WriteLine($"\tSize in points:\t{pageInfo.SizeInPoints}");
    Console.WriteLine($"\tSize in pixels:\t{pageInfo.GetSizeInPixels(1.0f, 96)} at {scale * 100}% scale, {dpi} dpi");

    // Paper source tray information
    Console.WriteLine($"\tTray:\t{pageInfo.PaperTray}");
    PaperSource source = pageInfo.GetSpecifiedPrinterPaperSource(paperSources, paperSources[0]);
    Console.WriteLine($"\tSuitable print source:\t{source.SourceName}, kind: {source.Kind}");
}

See Also