public class PageInfo
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:
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()));
}
Property Getters/Setters Summary | ||
---|---|---|
float | getHeightInPoints() | |
Gets the height of the page in points.
|
||
boolean | getLandscape() | |
Returns true if the page orientation specified in the document for this page is landscape.
|
||
int | getPaperSize() | |
Gets the paper size as enumeration.
The value of the property is PaperSize integer constant. |
||
int | getPaperTray() | |
Gets the paper tray (bin) for this page as specified in the document.
The value is implementation (printer) specific.
|
||
java.awt.Dimension | getSizeInPoints() | |
Gets the page size in points.
|
||
float | getWidthInPoints() | |
Gets the width of the page in points.
|
Method Summary | ||
---|---|---|
java.awt.Dimension | getSizeInPixels(float scale, float dpi) | |
Calculates the page size in pixels for a specified zoom factor and resolution.
|
||
java.awt.Dimension | getSizeInPixels(float scale, float horizontalDpi, float verticalDpi) | |
Calculates the page size in pixels for a specified zoom factor and resolution.
|
public float getHeightInPoints()
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())); }
public boolean getLandscape()
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())); }
public int getPaperSize()
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())); }
public int getPaperTray()
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())); }
public java.awt.Dimension getSizeInPoints()
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())); }
public float getWidthInPoints()
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())); }
public java.awt.Dimension getSizeInPixels(float scale, float dpi)
scale
- The zoom factor (1.0 is 100%).dpi
- The resolution (horizontal and vertical) to convert from points to pixels (dots per inch).public java.awt.Dimension getSizeInPixels(float scale, float horizontalDpi, float verticalDpi)
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).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())); }