本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFPrintSetup.LEGAL_PAPERSIZE属性的典型用法代码示例。如果您正苦于以下问题:Java HSSFPrintSetup.LEGAL_PAPERSIZE属性的具体用法?Java HSSFPrintSetup.LEGAL_PAPERSIZE怎么用?Java HSSFPrintSetup.LEGAL_PAPERSIZE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.poi.hssf.usermodel.HSSFPrintSetup
的用法示例。
在下文中一共展示了HSSFPrintSetup.LEGAL_PAPERSIZE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSuitablePaperSize
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;
}
示例2: formatPage
@Override
protected void formatPage(final HSSFSheet sheet)
{
super.formatPage(sheet);
MPrintPaper paper = MPrintPaper.get(this.m_printFormat.getAD_PrintPaper_ID());
//
// Set paper size:
short paperSize = -1;
MediaSizeName mediaSizeName = paper.getMediaSize().getMediaSizeName();
if (MediaSizeName.NA_LETTER.equals(mediaSizeName))
{
paperSize = HSSFPrintSetup.LETTER_PAPERSIZE;
}
else if (MediaSizeName.NA_LEGAL.equals(mediaSizeName))
{
paperSize = HSSFPrintSetup.LEGAL_PAPERSIZE;
}
else if (MediaSizeName.EXECUTIVE.equals(mediaSizeName))
{
paperSize = HSSFPrintSetup.EXECUTIVE_PAPERSIZE;
}
else if (MediaSizeName.ISO_A4.equals(mediaSizeName))
{
paperSize = HSSFPrintSetup.A4_PAPERSIZE;
}
else if (MediaSizeName.ISO_A5.equals(mediaSizeName))
{
paperSize = HSSFPrintSetup.A5_PAPERSIZE;
}
else if (MediaSizeName.NA_NUMBER_10_ENVELOPE.equals(mediaSizeName))
{
paperSize = HSSFPrintSetup.ENVELOPE_10_PAPERSIZE;
}
// else if (MediaSizeName..equals(mediaSizeName)) {
// paperSize = HSSFPrintSetup.ENVELOPE_DL_PAPERSIZE;
// }
// else if (MediaSizeName..equals(mediaSizeName)) {
// paperSize = HSSFPrintSetup.ENVELOPE_CS_PAPERSIZE;
// }
else if (MediaSizeName.MONARCH_ENVELOPE.equals(mediaSizeName))
{
paperSize = HSSFPrintSetup.ENVELOPE_MONARCH_PAPERSIZE;
}
if (paperSize != -1)
{
sheet.getPrintSetup().setPaperSize(paperSize);
}
//
// Set Landscape/Portrait:
sheet.getPrintSetup().setLandscape(paper.isLandscape());
//
// Set Paper Margin:
sheet.setMargin(HSSFSheet.TopMargin, ((double)paper.getMarginTop()) / 72);
sheet.setMargin(HSSFSheet.RightMargin, ((double)paper.getMarginRight()) / 72);
sheet.setMargin(HSSFSheet.LeftMargin, ((double)paper.getMarginLeft()) / 72);
sheet.setMargin(HSSFSheet.BottomMargin, ((double)paper.getMarginBottom()) / 72);
//
}