Package java.awt.print

Examples of java.awt.print.PageFormat


     */
    public PageFormat getPageFormat()
    {
      if (pageDefinition == null)
      {
        return new PageFormat();
      }

      final PageFormat pageFormat = pageDefinition.getPageFormat();
      final Paper orgPaper = pageFormat.getPaper();
      final PageFormatFactory pff = PageFormatFactory.getInstance();

      final double virtualPaperWidth = orgPaper.getImageableWidth() +
          pff.getLeftBorder(orgPaper) + pff.getRightBorder(orgPaper);
      final double virtualPaperHeight = orgPaper.getImageableHeight() +
          pff.getTopBorder(orgPaper) + pff.getBottomBorder(orgPaper);

      final Paper p = pff.createPaper(virtualPaperWidth, virtualPaperHeight);
      pff.setBorders(p, pff.getTopBorder(orgPaper), pff.getLeftBorder(orgPaper),
          pff.getBottomBorder(orgPaper), pff.getRightBorder(orgPaper));
      return pff.createPageFormat(p, pageFormat.getOrientation());
    }
View Full Code Here


      if (pageDefinition == null)
      {
        return new Dimension();
      }

      final PageFormat pageFormat = getPageFormat();
      return new Dimension((int) pageFormat.getWidth(), (int) pageFormat.getHeight());
    }
View Full Code Here

      if (name != null)
      {
        report.setName(name);
      }

      PageFormat format = report.getPageDefinition().getPageFormat(0);
      float defTopMargin = (float) format.getImageableY();
      float defBottomMargin = (float) (format.getHeight() - format.getImageableHeight()
          - format.getImageableY());
      float defLeftMargin = (float) format.getImageableX();
      float defRightMargin = (float) (format.getWidth() - format.getImageableWidth()
          - format.getImageableX());

      format = createPageFormat(format, attrs);

      defTopMargin = ParserUtil.parseFloat(attrs.getValue(getUri(), JFreeReportReadHandler.TOPMARGIN_ATT),
          defTopMargin);
      defBottomMargin = ParserUtil.parseFloat(attrs.getValue(getUri(), JFreeReportReadHandler.BOTTOMMARGIN_ATT),
          defBottomMargin);
      defLeftMargin = ParserUtil.parseFloat(attrs.getValue(getUri(), JFreeReportReadHandler.LEFTMARGIN_ATT),
          defLeftMargin);
      defRightMargin = ParserUtil.parseFloat(attrs.getValue(getUri(), JFreeReportReadHandler.RIGHTMARGIN_ATT),
          defRightMargin);

      final Paper p = format.getPaper();
      switch (format.getOrientation())
      {
        case PageFormat.PORTRAIT:
          PageFormatFactory.getInstance().setBorders(p, defTopMargin, defLeftMargin,
              defBottomMargin, defRightMargin);
          break;
        case PageFormat.LANDSCAPE:
          // right, top, left, bottom
          PageFormatFactory.getInstance().setBorders(p, defRightMargin, defTopMargin,
              defLeftMargin, defBottomMargin);
          break;
        case PageFormat.REVERSE_LANDSCAPE:
          PageFormatFactory.getInstance().setBorders(p, defLeftMargin, defBottomMargin,
              defRightMargin, defTopMargin);
          break;
        default:
          throw new IllegalStateException("Unexpected paper orientation.");
      }

      final int pageSpan = ParserUtil.parseInt(attrs.getValue(getUri(), JFreeReportReadHandler.PAGESPAN_ATT), 1);

      format.setPaper(p);
      report.setPageDefinition(new SimplePageDefinition(format, pageSpan, 1));
    }
    getRootHandler().setHelperObject(ReportParserUtil.HELPER_OBJ_REPORT_NAME, report);

    final String useMinChunkWidth = attrs.getValue(getUri(), "use-min-chunkwidth");
View Full Code Here

    }
    else
    {

      final PrinterJob pj = PrinterJob.getPrinterJob();
      final PageFormat original = report.getPageDefinition().getPageFormat(0);
      final PageFormat pf = pj.validatePage(pj.pageDialog(original));
      if (PageFormatFactory.isEqual(pf, original))
      {
        return false;
      }
View Full Code Here

    if (definition instanceof SimplePageDefinition)
    {
      final SimplePageDefinition sdef = (SimplePageDefinition) definition;
      final int pageCountHorizontal = sdef.getPageCountHorizontal();
      final int pageCountVertical = sdef.getPageCountVertical();
      final PageFormat pageFormat = sdef.getPageFormat();

      final AttributeList attr = new AttributeList();
      attr.setAttribute(ExtParserModule.NAMESPACE, "horizontal-span", String.valueOf(pageCountHorizontal));
      attr.setAttribute(ExtParserModule.NAMESPACE, "vertical-span", String.valueOf(pageCountVertical));
      buildPageFormatProperties(pageFormat, attr);
View Full Code Here

  public PhysicalPageBox getPage(final int row, final int col)
  {
    final long offsetX = horizontalBreaksFull[col];
    final long offsetY = verticalBreaksFull[row];

    final PageFormat format = pageMapping[row][col];
    return new PhysicalPageBox(format, offsetX, offsetY);
  }
View Full Code Here

      default:
        // will not happen..
        throw new IllegalArgumentException("Unexpected page-orientation encountered.");
    }

    this.pageFormat = new PageFormat();
    this.pageFormat.setPaper(p);
    this.pageFormat.setOrientation(page.getOrientation());
  }
View Full Code Here

  {
    final PageDefinition format;
    final ExtendedConfiguration config = ClassicEngineBoot.getInstance().getExtendedConfig();
    if (config.getBoolProperty(ClassicEngineCoreModule.NO_PRINTER_AVAILABLE_KEY))
    {
      format = new SimplePageDefinition(new PageFormat());
    }
    else
    {
      format = new SimplePageDefinition(PrinterJob.getPrinterJob().defaultPage());
    }
View Full Code Here

    // use A4...
    final PageFormatFactory pff = PageFormatFactory.getInstance();
    final Paper paper = pff.createPaper(PageSize.A4);
    pff.setBorders(paper, PAGE_MARGIN_TOP, PAGE_MARGIN_LEFT, PAGE_MARGIN_BOTTOM, PAGE_MARGIN_RIGHT);
    final PageFormat format = pff.createPageFormat(paper, PageFormat.PORTRAIT);
    report.setPageDefinition(new SimplePageDefinition(format));

    setupWatermark(report);
    setupPageHeader(report);
    //// REPORT GROUP /////////////////////////////////////////////////////////////////////////
View Full Code Here

   * @return the generated image.
   */
  private BufferedImage createImage(final PageDefinition pd)
  {
    // in this simple case we know, that all pages have the same size..
    final PageFormat pf = pd.getPageFormat(0);

    final double width = pf.getWidth();
    final double height = pf.getHeight();
    //write the report to the temp file
    return new BufferedImage
        ((int) width, (int) height, BufferedImage.TYPE_BYTE_INDEXED);
  }
View Full Code Here

TOP

Related Classes of java.awt.print.PageFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.