Java Code Examples for org.apache.poi.hssf.usermodel.HSSFPrintSetup#A4_PAPERSIZE
The following examples show how to use
org.apache.poi.hssf.usermodel.HSSFPrintSetup#A4_PAPERSIZE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JRXlsExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
private final short getSuitablePaperSize(SheetPrintSettings printSettings) { if (printSettings == null) { return -1; } long width = 0; long height = 0; short ps = -1; if ((printSettings.getPageWidth() != 0) && (printSettings.getPageHeight() != 0)) { double dWidth = (printSettings.getPageWidth() / 72.0); double dHeight = (printSettings.getPageHeight() / 72.0); height = Math.round(dHeight * 25.4); width = Math.round(dWidth * 25.4); // Compare to ISO 216 A-Series (A3-A5). All other ISO 216 formats // not supported by POI Api yet. for (int i = 2; i < 6; i++) { int w = calculateWidthForDinAN(i); int h = calculateHeightForDinAN(i); if (((w == width) && (h == height)) || ((h == width) && (w == height))) { if (i == 2) { // local A2_PAPERSIZE constant ps = A2_PAPERSIZE; } if (i == 3) { ps = HSSFPrintSetup.A3_PAPERSIZE; } else if (i == 4) { ps = HSSFPrintSetup.A4_PAPERSIZE; } else if (i == 5) { ps = HSSFPrintSetup.A5_PAPERSIZE; } break; } } //envelope sizes if (ps == -1) { // ISO 269 sizes - "Envelope DL" (110 x 220 mm) if (((width == 110) && (height == 220)) || ((width == 220) && (height == 110))) { ps = HSSFPrintSetup.ENVELOPE_DL_PAPERSIZE; } } // Compare to common North American Paper Sizes (ANSI X3.151-1987). if (ps == -1) { // ANSI X3.151-1987 - "Letter" (216 x 279 mm) if (((width == 216) && (height == 279)) || ((width == 279) && (height == 216))) { ps = HSSFPrintSetup.LETTER_PAPERSIZE; } // ANSI X3.151-1987 - "Legal" (216 x 356 mm) if (((width == 216) && (height == 356)) || ((width == 356) && (height == 216))) { ps = HSSFPrintSetup.LEGAL_PAPERSIZE; } // ANSI X3.151-1987 - "Executive" (190 x 254 mm) else if (((width == 190) && (height == 254)) || ((width == 254) && (height == 190))) { ps = HSSFPrintSetup.EXECUTIVE_PAPERSIZE; } // ANSI X3.151-1987 - "Ledger/Tabloid" (279 x 432 mm) // Not supported by POI Api yet. } } return ps; }
Example 2
Source File: JRXlsMetadataExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
private final short getSuitablePaperSize() { if (pageFormat == null) { return -1; } long width = 0; long height = 0; short ps = -1; if ((pageFormat.getPageWidth() != 0) && (pageFormat.getPageHeight() != 0)) { double dWidth = (pageFormat.getPageWidth() / 72.0); double dHeight = (pageFormat.getPageHeight() / 72.0); height = Math.round(dHeight * 25.4); width = Math.round(dWidth * 25.4); // Compare to ISO 216 A-Series (A3-A5). All other ISO 216 formats // not supported by POI Api yet. // A3 papersize also not supported by POI Api yet. for (int i = 4; i < 6; i++) { int w = calculateWidthForDinAN(i); int h = calculateHeightForDinAN(i); if (((w == width) && (h == height)) || ((h == width) && (w == height))) { if (i == 4) { ps = HSSFPrintSetup.A4_PAPERSIZE; } else if (i == 5) { ps = HSSFPrintSetup.A5_PAPERSIZE; } break; } } //envelope sizes if (ps == -1) { // ISO 269 sizes - "Envelope DL" (110 x 220 mm) if (((width == 110) && (height == 220)) || ((width == 220) && (height == 110))) { ps = HSSFPrintSetup.ENVELOPE_DL_PAPERSIZE; } } // Compare to common North American Paper Sizes (ANSI X3.151-1987). if (ps == -1) { // ANSI X3.151-1987 - "Letter" (216 x 279 mm) if (((width == 216) && (height == 279)) || ((width == 279) && (height == 216))) { ps = HSSFPrintSetup.LETTER_PAPERSIZE; } // ANSI X3.151-1987 - "Legal" (216 x 356 mm) if (((width == 216) && (height == 356)) || ((width == 356) && (height == 216))) { ps = HSSFPrintSetup.LEGAL_PAPERSIZE; } // ANSI X3.151-1987 - "Executive" (190 x 254 mm) else if (((width == 190) && (height == 254)) || ((width == 254) && (height == 190))) { ps = HSSFPrintSetup.EXECUTIVE_PAPERSIZE; } // ANSI X3.151-1987 - "Ledger/Tabloid" (279 x 432 mm) // Not supported by POI Api yet. } } return ps; }