Package java.awt.print

Examples of java.awt.print.Paper


    final double topBorder = Double.parseDouble(attrs.getValue(getUri(), "topBorder"));
    final double leftBorder = Double.parseDouble(attrs.getValue(getUri(), "leftBorder"));
    final double bottomBorder = Double.parseDouble(attrs.getValue(getUri(), "bottomBorder"));
    final double rightBorder = Double.parseDouble(attrs.getValue(getUri(), "rightBorder"));

    final Paper paper = PageFormatFactory.getInstance().createPaper(pageSize.getWidth(), pageSize.getHeight());
    PageFormatFactory.getInstance().setBorders(paper, topBorder, leftBorder, bottomBorder, rightBorder);

    pageFormat = new PageFormat();
    pageFormat.setPaper(paper);
View Full Code Here


  }

  private static Paper createPaper(final MediaSize mediaSize,
                                   final MediaPrintableArea printableArea)
  {
    final Paper paper = new Paper();
    if (mediaSize != null)
    {
      paper.setSize(mediaSize.getX(Size2DSyntax.INCH) * POINTS_PER_INCH,
          mediaSize.getY(Size2DSyntax.INCH) * POINTS_PER_INCH);
    }
    if (printableArea != null)
    {
      paper.setImageableArea
          (printableArea.getX(Size2DSyntax.INCH) * POINTS_PER_INCH,
              printableArea.getY(Size2DSyntax.INCH) * POINTS_PER_INCH,
              printableArea.getWidth(Size2DSyntax.INCH) * POINTS_PER_INCH,
              printableArea.getHeight(Size2DSyntax.INCH) * POINTS_PER_INCH);
    }
View Full Code Here

    }

    // for now, be lazy, assume that the first page is the reference
    final PageDefinition pdef = report.getPageDefinition();
    final PageFormat format = pdef.getPageFormat(0);
    final Paper paper = format.getPaper();

    final Media media = MediaSize.findMedia((float) (paper.getWidth() / POINTS_PER_INCH),
        (float) (paper.getHeight() / POINTS_PER_INCH), Size2DSyntax.INCH);
    attributes.add(media);

    final MediaPrintableArea printableArea = new MediaPrintableArea
        ((float) (paper.getImageableX() / POINTS_PER_INCH),
            (float) (paper.getImageableY() / POINTS_PER_INCH),
            (float) (paper.getImageableWidth() / POINTS_PER_INCH),
            (float) (paper.getImageableHeight() / POINTS_PER_INCH),
            Size2DSyntax.INCH);

    attributes.add(printableArea);
    attributes.add(mapOrientation(format.getOrientation()));
View Full Code Here

  private static final Log logger = LogFactory.getLog(PageFormatTest.class);

  public static void testPageFormat()
  {
    ClassicEngineBoot.getInstance().start();
    final Paper p = PageFormatFactory.getInstance().createPaper("A4"); //$NON-NLS-1$
    final PageFormat pageFormat = PageFormatFactory.getInstance().createPageFormat(p, PageFormat.LANDSCAPE);
    final double defRightMargin = 70;
    final double defTopMargin = 50;
    final double defLeftMargin = 30;
    final double defBottomMargin= 10;
View Full Code Here

    report.setDataFactory(tableDataFactory);
    report.setName("Raportti");

    PageFormatFactory pfFact = PageFormatFactory.getInstance();
    // 0.8.9.4
    Paper paper = pfFact.createPaper(PageSize.A4);
    // // 0.8.8-01 (works also with 0.8.9.4 although deprecated)
    // Paper paper = pfFact.createPaper(PageFormatFactory.A4);
    pfFact.setBordersMm(paper, 25.5, 25.5, 25.5, 25.5);
    PageFormat pf = pfFact.createPageFormat(paper, PageFormat.LANDSCAPE);
    SimplePageDefinition pageDef = new SimplePageDefinition(pf);
View Full Code Here

      orientationVal = PageFormat.PORTRAIT;
    }

    if (pageformatName != null)
    {
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatName);
      if (p == null)
      {
        PageDefinitionReadHandler.logger.warn("Paper size '" + pageformatName + "' is not regognized.");
        return defaultPageFormat;
      }
      return PageFormatFactory.getInstance().createPageFormat(p, orientationVal);
    }

    if (atts.getValue(getUri(), "width") != null && atts.getValue(getUri(), "height") != null)
    {
      final int[] pageformatData = new int[2];
      pageformatData[0] = ParserUtil.parseInt(atts.getValue(getUri(), "width"),
          "Specified attribute 'width' is not valid", getLocator());
      pageformatData[1] = ParserUtil.parseInt(atts.getValue(getUri(), "height"),
          "Specified attribute 'height' is not valid", getLocator());
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatData);
      if (p == null)
      {
        PageDefinitionReadHandler.logger.warn("Unable to create the requested Paper size with width " +
            pageformatData[0] + " and height " + pageformatData[1]);
        return defaultPageFormat;
View Full Code Here

    defTopMargin = ParserUtil.parseFloat(atts.getValue(getUri(), "margin-top"), defTopMargin);
    defBottomMargin = ParserUtil.parseFloat(atts.getValue(getUri(), "margin-bottom"), defBottomMargin);
    defLeftMargin = ParserUtil.parseFloat(atts.getValue(getUri(), "margin-left"), defLeftMargin);
    defRightMargin = ParserUtil.parseFloat(atts.getValue(getUri(), "margin-right"), defRightMargin);

    final Paper p = format.getPaper();
    switch (format.getOrientation())
    {
      case PageFormat.PORTRAIT:
        PageFormatFactory.getInstance().setBorders(p, defTopMargin, defLeftMargin,
            defBottomMargin, defRightMargin);
View Full Code Here

    this.metaData = metaData;
    this.width = StrictGeomUtility.toExternalValue(rootBox.getPageWidth());
    this.height = StrictGeomUtility.toExternalValue(rootBox.getPageHeight());
    this.drawPageBackground = true;

    final Paper paper = new Paper();
    paper.setImageableArea(0, 0, width, height);

    this.pageFormat = new PageFormat();
    this.pageFormat.setPaper(paper);

    this.strictClipping = "true".equals(metaData.getConfiguration().getConfigProperty
View Full Code Here

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

    final Paper p = format.getPaper();
    switch (format.getOrientation())
    {
      case PageFormat.PORTRAIT:
        PageFormatFactory.getInstance().setBorders(p, defTopMargin, defLeftMargin,
            defBottomMargin, defRightMargin);
View Full Code Here

      throw new ParseException("Orientation value in REPORT-Tag is invalid.",
          getRootHandler().getDocumentLocator());
    }
    if (pageformatName != null)
    {
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatName);
      if (p == null)
      {
        PageReadHandler.logger.warn("Unable to create the requested Paper. " + pageformatName);
        return format;
      }
      return PageFormatFactory.getInstance().createPageFormat(p, orientationVal);
    }

    if (atts.getValue(getUri(), PageReadHandler.WIDTH_ATT) != null && atts.getValue(getUri(),
        PageReadHandler.HEIGHT_ATT) != null)
    {
      final int[] pageformatData = new int[2];
      pageformatData[0] = ParserUtil.parseInt(atts.getValue(getUri(), PageReadHandler.WIDTH_ATT), "No Width set",
          getLocator());
      pageformatData[1] = ParserUtil.parseInt(atts.getValue(getUri(), PageReadHandler.HEIGHT_ATT), "No Height set",
          getLocator());
      final Paper p = PageFormatFactory.getInstance().createPaper(pageformatData);
      if (p == null)
      {
        PageReadHandler.logger.warn("Unable to create the requested Paper. Paper={" + pageformatData[0] + ", "
            + pageformatData[1] + '}');
        return format;
View Full Code Here

TOP

Related Classes of java.awt.print.Paper

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.