com.aspose.words
Class PageInfo

java.lang.Object
    extended by com.aspose.words.PageInfo

public class PageInfo 
extends java.lang.Object

Represents information about a particular document page.

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.

Example:

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

System.out.println(MessageFormat.format("Document \"{0}\" contains {1} pages.", doc.getOriginalFileName(), doc.getPageCount()));

float scale = 1.0f;
float dpi = 96f;

for (int i = 0; i < doc.getPageCount(); 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
    System.out.println(MessageFormat.format("Page {0}:", i + 1));
    System.out.println(MessageFormat.format("\tOrientation:\t{0}", pageInfo.getLandscape() ? "Landscape" : "Portrait"));
    System.out.println(MessageFormat.format("\tPaper size:\t\t{0} ({1}x{2}pt)", pageInfo.getPaperSize(), pageInfo.getWidthInPoints(), pageInfo.getHeightInPoints()));
    System.out.println(MessageFormat.format("\tSize in points:\t{0}", pageInfo.getSizeInPoints()));
    System.out.println(MessageFormat.format("\tSize in pixels:\t{0} at {1}% scale, {2} dpi", pageInfo.getSizeInPixels(1.0f, 96), scale * 100, dpi));
    System.out.println(MessageFormat.format("\tTray:\t{0}", pageInfo.getPaperTray()));
}
See Also:
Document.getPageInfo(int)

Property Getters/Setters Summary
floatgetHeightInPoints()
           Gets the height of the page in points.
booleangetLandscape()
           Returns true if the page orientation specified in the document for this page is landscape.
intgetPaperSize()
           Gets the paper size as enumeration. The value of the property is PaperSize integer constant.
intgetPaperTray()
           Gets the paper tray (bin) for this page as specified in the document. The value is implementation (printer) specific.
java.awt.DimensiongetSizeInPoints()
           Gets the page size in points.
floatgetWidthInPoints()
           Gets the width of the page in points.
 
Method Summary
java.awt.DimensiongetSizeInPixels(float scale, float dpi)
           Calculates the page size in pixels for a specified zoom factor and resolution.
java.awt.DimensiongetSizeInPixels(float scale, float horizontalDpi, float verticalDpi)
           Calculates the page size in pixels for a specified zoom factor and resolution.
 

Property Getters/Setters Detail

getHeightInPoints

public float getHeightInPoints()
Gets the height of the page in points.

Example:

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

System.out.println(MessageFormat.format("Document \"{0}\" contains {1} pages.", doc.getOriginalFileName(), doc.getPageCount()));

float scale = 1.0f;
float dpi = 96f;

for (int i = 0; i < doc.getPageCount(); 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
    System.out.println(MessageFormat.format("Page {0}:", i + 1));
    System.out.println(MessageFormat.format("\tOrientation:\t{0}", pageInfo.getLandscape() ? "Landscape" : "Portrait"));
    System.out.println(MessageFormat.format("\tPaper size:\t\t{0} ({1}x{2}pt)", pageInfo.getPaperSize(), pageInfo.getWidthInPoints(), pageInfo.getHeightInPoints()));
    System.out.println(MessageFormat.format("\tSize in points:\t{0}", pageInfo.getSizeInPoints()));
    System.out.println(MessageFormat.format("\tSize in pixels:\t{0} at {1}% scale, {2} dpi", pageInfo.getSizeInPixels(1.0f, 96), scale * 100, dpi));
    System.out.println(MessageFormat.format("\tTray:\t{0}", pageInfo.getPaperTray()));
}

getLandscape

public boolean getLandscape()
Returns true if the page orientation specified in the document for this page is landscape.

Example:

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

System.out.println(MessageFormat.format("Document \"{0}\" contains {1} pages.", doc.getOriginalFileName(), doc.getPageCount()));

float scale = 1.0f;
float dpi = 96f;

for (int i = 0; i < doc.getPageCount(); 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
    System.out.println(MessageFormat.format("Page {0}:", i + 1));
    System.out.println(MessageFormat.format("\tOrientation:\t{0}", pageInfo.getLandscape() ? "Landscape" : "Portrait"));
    System.out.println(MessageFormat.format("\tPaper size:\t\t{0} ({1}x{2}pt)", pageInfo.getPaperSize(), pageInfo.getWidthInPoints(), pageInfo.getHeightInPoints()));
    System.out.println(MessageFormat.format("\tSize in points:\t{0}", pageInfo.getSizeInPoints()));
    System.out.println(MessageFormat.format("\tSize in pixels:\t{0} at {1}% scale, {2} dpi", pageInfo.getSizeInPixels(1.0f, 96), scale * 100, dpi));
    System.out.println(MessageFormat.format("\tTray:\t{0}", pageInfo.getPaperTray()));
}

getPaperSize

public int getPaperSize()
Gets the paper size as enumeration. The value of the property is PaperSize integer constant.

Example:

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

System.out.println(MessageFormat.format("Document \"{0}\" contains {1} pages.", doc.getOriginalFileName(), doc.getPageCount()));

float scale = 1.0f;
float dpi = 96f;

for (int i = 0; i < doc.getPageCount(); 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
    System.out.println(MessageFormat.format("Page {0}:", i + 1));
    System.out.println(MessageFormat.format("\tOrientation:\t{0}", pageInfo.getLandscape() ? "Landscape" : "Portrait"));
    System.out.println(MessageFormat.format("\tPaper size:\t\t{0} ({1}x{2}pt)", pageInfo.getPaperSize(), pageInfo.getWidthInPoints(), pageInfo.getHeightInPoints()));
    System.out.println(MessageFormat.format("\tSize in points:\t{0}", pageInfo.getSizeInPoints()));
    System.out.println(MessageFormat.format("\tSize in pixels:\t{0} at {1}% scale, {2} dpi", pageInfo.getSizeInPixels(1.0f, 96), scale * 100, dpi));
    System.out.println(MessageFormat.format("\tTray:\t{0}", pageInfo.getPaperTray()));
}

getPaperTray

public int getPaperTray()
Gets the paper tray (bin) for this page as specified in the document. The value is implementation (printer) specific.

Example:

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

System.out.println(MessageFormat.format("Document \"{0}\" contains {1} pages.", doc.getOriginalFileName(), doc.getPageCount()));

float scale = 1.0f;
float dpi = 96f;

for (int i = 0; i < doc.getPageCount(); 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
    System.out.println(MessageFormat.format("Page {0}:", i + 1));
    System.out.println(MessageFormat.format("\tOrientation:\t{0}", pageInfo.getLandscape() ? "Landscape" : "Portrait"));
    System.out.println(MessageFormat.format("\tPaper size:\t\t{0} ({1}x{2}pt)", pageInfo.getPaperSize(), pageInfo.getWidthInPoints(), pageInfo.getHeightInPoints()));
    System.out.println(MessageFormat.format("\tSize in points:\t{0}", pageInfo.getSizeInPoints()));
    System.out.println(MessageFormat.format("\tSize in pixels:\t{0} at {1}% scale, {2} dpi", pageInfo.getSizeInPixels(1.0f, 96), scale * 100, dpi));
    System.out.println(MessageFormat.format("\tTray:\t{0}", pageInfo.getPaperTray()));
}

getSizeInPoints

public java.awt.Dimension getSizeInPoints()
Gets the page size in points.

Example:

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

System.out.println(MessageFormat.format("Document \"{0}\" contains {1} pages.", doc.getOriginalFileName(), doc.getPageCount()));

float scale = 1.0f;
float dpi = 96f;

for (int i = 0; i < doc.getPageCount(); 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
    System.out.println(MessageFormat.format("Page {0}:", i + 1));
    System.out.println(MessageFormat.format("\tOrientation:\t{0}", pageInfo.getLandscape() ? "Landscape" : "Portrait"));
    System.out.println(MessageFormat.format("\tPaper size:\t\t{0} ({1}x{2}pt)", pageInfo.getPaperSize(), pageInfo.getWidthInPoints(), pageInfo.getHeightInPoints()));
    System.out.println(MessageFormat.format("\tSize in points:\t{0}", pageInfo.getSizeInPoints()));
    System.out.println(MessageFormat.format("\tSize in pixels:\t{0} at {1}% scale, {2} dpi", pageInfo.getSizeInPixels(1.0f, 96), scale * 100, dpi));
    System.out.println(MessageFormat.format("\tTray:\t{0}", pageInfo.getPaperTray()));
}

getWidthInPoints

public float getWidthInPoints()
Gets the width of the page in points.

Example:

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

System.out.println(MessageFormat.format("Document \"{0}\" contains {1} pages.", doc.getOriginalFileName(), doc.getPageCount()));

float scale = 1.0f;
float dpi = 96f;

for (int i = 0; i < doc.getPageCount(); 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
    System.out.println(MessageFormat.format("Page {0}:", i + 1));
    System.out.println(MessageFormat.format("\tOrientation:\t{0}", pageInfo.getLandscape() ? "Landscape" : "Portrait"));
    System.out.println(MessageFormat.format("\tPaper size:\t\t{0} ({1}x{2}pt)", pageInfo.getPaperSize(), pageInfo.getWidthInPoints(), pageInfo.getHeightInPoints()));
    System.out.println(MessageFormat.format("\tSize in points:\t{0}", pageInfo.getSizeInPoints()));
    System.out.println(MessageFormat.format("\tSize in pixels:\t{0} at {1}% scale, {2} dpi", pageInfo.getSizeInPixels(1.0f, 96), scale * 100, dpi));
    System.out.println(MessageFormat.format("\tTray:\t{0}", pageInfo.getPaperTray()));
}

Method Detail

getSizeInPixels

public java.awt.Dimension getSizeInPixels(float scale, float dpi)
Calculates the page size in pixels for a specified zoom factor and resolution.
Parameters:
scale - The zoom factor (1.0 is 100%).
dpi - The resolution (horizontal and vertical) to convert from points to pixels (dots per inch).
Returns:
The size of the page in pixels.

getSizeInPixels

public java.awt.Dimension getSizeInPixels(float scale, float horizontalDpi, float verticalDpi)
Calculates the page size in pixels for a specified zoom factor and resolution.
Parameters:
scale - The zoom factor (1.0 is 100%).
horizontalDpi - The horizontal resolution to convert from points to pixels (dots per inch).
verticalDpi - The vertical resolution to convert from points to pixels (dots per inch).
Returns:
The size of the page in pixels.

Example:

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

System.out.println(MessageFormat.format("Document \"{0}\" contains {1} pages.", doc.getOriginalFileName(), doc.getPageCount()));

float scale = 1.0f;
float dpi = 96f;

for (int i = 0; i < doc.getPageCount(); 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
    System.out.println(MessageFormat.format("Page {0}:", i + 1));
    System.out.println(MessageFormat.format("\tOrientation:\t{0}", pageInfo.getLandscape() ? "Landscape" : "Portrait"));
    System.out.println(MessageFormat.format("\tPaper size:\t\t{0} ({1}x{2}pt)", pageInfo.getPaperSize(), pageInfo.getWidthInPoints(), pageInfo.getHeightInPoints()));
    System.out.println(MessageFormat.format("\tSize in points:\t{0}", pageInfo.getSizeInPoints()));
    System.out.println(MessageFormat.format("\tSize in pixels:\t{0} at {1}% scale, {2} dpi", pageInfo.getSizeInPixels(1.0f, 96), scale * 100, dpi));
    System.out.println(MessageFormat.format("\tTray:\t{0}", pageInfo.getPaperTray()));
}

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.