Package java.awt.print

Examples of java.awt.print.Paper


        {
            diffWidth = (media.getWidth() - crop.getWidth()) / 2.0;
            diffHeight = (media.getHeight() - crop.getHeight()) / 2.0;
        }

        Paper paper = format.getPaper();
        if (media.getWidth() < media.getHeight())
        {
          format.setOrientation(PageFormat.PORTRAIT);
          paper.setImageableArea(diffWidth, diffHeight, crop.getWidth(), crop.getHeight());
        }
        else
        {
          format.setOrientation(PageFormat.LANDSCAPE);
          paper.setImageableArea(diffHeight, diffWidth, crop.getHeight(), crop.getWidth());
        }
        format.setPaper(paper);

        return format;
    }
View Full Code Here


      if(currentService != null){
        PrinterJob job = PrinterJob.getPrinterJob();

        job.setPrintService(currentService);
        PageFormat pf = job.defaultPage();        
        Paper paper = new Paper();
        paper.setSize(pf.getWidth(), pf.getHeight());
        paper.setImageableArea(0.0,0.0,pf.getWidth(), pf.getHeight());       

        pf.setPaper(paper);        
        job.setPrintable(sVGImagemanipulator.print(userDataVO,pINs,pUKs,hardTokenSN, copyOfHardTokenSN),pf);        
                job.setCopies(copies);
        job.print();                                  
View Full Code Here

                return null;
            }

            PageFormat pageFormat = new PageFormat();

            Paper paper = new Paper();

            Rectangle2D dim = getPageViewport(pageIndex).getViewArea();
            double width = dim.getWidth();
            double height = dim.getHeight();

            // if the width is greater than the height assume lanscape mode
            // and swap the width and height values in the paper format
            if (width > height) {
                paper.setImageableArea(0, 0, height / 1000d, width / 1000d);
                paper.setSize(height / 1000d, width / 1000d);
                pageFormat.setOrientation(PageFormat.LANDSCAPE);
            } else {
                paper.setImageableArea(0, 0, width / 1000d, height / 1000d);
                paper.setSize(width / 1000d, height / 1000d);
                pageFormat.setOrientation(PageFormat.PORTRAIT);
            }
            pageFormat.setPaper(paper);
            return pageFormat;
        } catch (FOPException fopEx) {
View Full Code Here

            printerJob.defaultPage();

        //
        // Set the page parameters from the hints
        //
        Paper paper = pageFormat.getPaper();

        Float pageWidth = (Float)hints.get(KEY_PAGE_WIDTH);
        Float pageHeight = (Float)hints.get(KEY_PAGE_HEIGHT);
        if(pageWidth != null){
            paper.setSize(pageWidth.floatValue(),
                          paper.getHeight());
        }
        if(pageHeight != null){
            paper.setSize(paper.getWidth(),
                          pageHeight.floatValue());
        }

        float x=0, y=0;
        float width=(float)paper.getWidth(), height=(float)paper.getHeight();

        Float leftMargin = (Float)hints.get(KEY_MARGIN_LEFT);
        Float topMargin = (Float)hints.get(KEY_MARGIN_TOP);
        Float rightMargin = (Float)hints.get(KEY_MARGIN_RIGHT);
        Float bottomMargin = (Float)hints.get(KEY_MARGIN_BOTTOM);

        if(leftMargin != null){
            x = leftMargin.floatValue();
            width -= leftMargin.floatValue();
        }
        if(topMargin != null){
            y = topMargin.floatValue();
            height -= topMargin.floatValue();
        }
        if(rightMargin != null){
            width -= rightMargin.floatValue();
        }
        if(bottomMargin != null){
            height -= bottomMargin.floatValue();
        }

        paper.setImageableArea(x, y, width, height);

        String pageOrientation = (String)hints.get(KEY_PAGE_ORIENTATION);
        if(VALUE_PAGE_ORIENTATION_PORTRAIT.equalsIgnoreCase(pageOrientation)){
            pageFormat.setOrientation(PageFormat.PORTRAIT);
        }
View Full Code Here

        if (defaultPrintOptions == null) {
          defaultPrintOptions = new PrintOptionsDesc();
        }
        PrinterJob pjob = PrinterJob.getPrinterJob();
        PageFormat defaultPage = pjob.defaultPage();
        Paper paper = new Paper();
        double imagableWidth = defaultPage.getPaper().getWidth() - (defaultPrintMargin * 2);
        double imagableHeight = defaultPage.getPaper().getHeight() - (defaultPrintMargin * 2);
       
        // Swap the width and height if in landscape mode
        if (defaultPrintOptions.getForteOrientation() == Constants.PO_LANDSCAPE) {
          double tmpWidth = imagableWidth;
          imagableWidth = imagableHeight;
          imagableHeight = tmpWidth;
        }
       
        paper.setSize(defaultPage.getPaper().getWidth(), defaultPage.getPaper().getHeight());
        paper.setImageableArea(defaultPrintMargin, defaultPrintMargin, imagableWidth, imagableHeight);
        defaultPrintOptions.setPaper(paper);
        return defaultPrintOptions;
    }
View Full Code Here

    public void printWorkingPage(){
        UIutils.processGUIActions();

        // Set the working page to be the size of the paper
        PrintOptionsDesc options = getPrintOptions();
        Paper paper = options.getPaper();

        int topMargin = TopMargin.get(workingPage);
        int leftMargin = LeftMargin.get(workingPage);
        int bottomMargin = BottomMargin.get(workingPage);
        int rightMargin = RightMargin.get(workingPage);

        // CraigM:06/06/2008 - The paper.getImageable values seem to be way too big.  I'm guessing with my defaultMargin value.
//      double x = (leftMargin != 0) ? PrintUtilities.milsToPoints(leftMargin) : paper.getImageableX();
//      double y = (topMargin != 0) ? PrintUtilities.milsToPoints(topMargin) : paper.getImageableY();
//      double width = (rightMargin != 0) ? options.getWidth() - PrintUtilities.milsToPoints(rightMargin) - x : paper.getImageableWidth();
//      double height = (bottomMargin != 0) ? options.getHeight() - PrintUtilities.milsToPoints(bottomMargin) - y : paper.getImageableHeight();
        double defaultMargin = 35;
        double x = (leftMargin != 0) ? PrintUtilities.milsToPoints(leftMargin) : defaultMargin;
        double y = (topMargin != 0) ? PrintUtilities.milsToPoints(topMargin) : defaultMargin;
        double width = (rightMargin != 0) ? options.getWidth() - PrintUtilities.milsToPoints(rightMargin) - x : options.getWidth() - (defaultMargin*2);
        double height = (bottomMargin != 0) ? options.getHeight() - PrintUtilities.milsToPoints(bottomMargin) - y : options.getHeight() - (defaultMargin*2);

        // If we are in landscape mode, then we need to swap the width and height around.
        if (options.getOrientation() == PageFormat.LANDSCAPE) {
          double tmpWidth = width;
          width = height;
          height = tmpWidth;
        }

        // CraigM:30/05/2008 - The working page is now scaled in the BookComponentPrintable so we shouldn't set the size
        // workingPage.setSize((int)width, (int)height);
       
        paper.setImageableArea(x, y, width, height);
        options.setPaper(paper);

        this.append(new BookComponentPrintable(workingPage), getPrintOptions());
    }
View Full Code Here

    // fix for bug ID 6255588 from Sun bug database
    initPrinterJobFields(printJob);
   
    PageFormat pageFormat = printJob.defaultPage();
    Paper paper = pageFormat.getPaper();

    printJob.setJobName("JasperReports - " + jasperPrint.getName());
   
    switch (jasperPrint.getOrientation())
    {
      case JRReport.ORIENTATION_LANDSCAPE :
      {
        pageFormat.setOrientation(PageFormat.LANDSCAPE);
        paper.setSize(jasperPrint.getPageHeight(), jasperPrint.getPageWidth());
        paper.setImageableArea(
          0,
          0,
          jasperPrint.getPageHeight(),
          jasperPrint.getPageWidth()
          );
        break;
      }
      case JRReport.ORIENTATION_PORTRAIT :
      default :
      {
        pageFormat.setOrientation(PageFormat.PORTRAIT);
        paper.setSize(jasperPrint.getPageWidth(), jasperPrint.getPageHeight());
        paper.setImageableArea(
          0,
          0,
          jasperPrint.getPageWidth(),
          jasperPrint.getPageHeight()
          );
View Full Code Here

        if (defaultPrintOptions == null) {
          defaultPrintOptions = new PrintOptionsDesc();
        }
        PrinterJob pjob = PrinterJob.getPrinterJob();
        PageFormat defaultPage = pjob.defaultPage();
        Paper paper = new Paper();
        double imagableWidth = defaultPage.getPaper().getWidth() - (defaultPrintMargin * 2);
        double imagableHeight = defaultPage.getPaper().getHeight() - (defaultPrintMargin * 2);
       
        // Swap the width and height if in landscape mode
        if (defaultPrintOptions.getForteOrientation() == Constants.PO_LANDSCAPE) {
          double tmpWidth = imagableWidth;
          imagableWidth = imagableHeight;
          imagableHeight = tmpWidth;
        }
       
        paper.setSize(defaultPage.getPaper().getWidth(), defaultPage.getPaper().getHeight());
        paper.setImageableArea(defaultPrintMargin, defaultPrintMargin, imagableWidth, imagableHeight);
        defaultPrintOptions.setPaper(paper);
        return defaultPrintOptions;
    }
View Full Code Here

    public void printWorkingPage(){
        UIutils.processGUIActions();

        // Set the working page to be the size of the paper
        PrintOptionsDesc options = getPrintOptions();
        Paper paper = options.getPaper();

        int topMargin = TopMargin.get(workingPage);
        int leftMargin = LeftMargin.get(workingPage);
        int bottomMargin = BottomMargin.get(workingPage);
        int rightMargin = RightMargin.get(workingPage);

        // CraigM:06/06/2008 - The paper.getImageable values seem to be way too big.  I'm guessing with my defaultMargin value.
//      double x = (leftMargin != 0) ? PrintUtilities.milsToPoints(leftMargin) : paper.getImageableX();
//      double y = (topMargin != 0) ? PrintUtilities.milsToPoints(topMargin) : paper.getImageableY();
//      double width = (rightMargin != 0) ? options.getWidth() - PrintUtilities.milsToPoints(rightMargin) - x : paper.getImageableWidth();
//      double height = (bottomMargin != 0) ? options.getHeight() - PrintUtilities.milsToPoints(bottomMargin) - y : paper.getImageableHeight();
        double defaultMargin = 35;
        double x = (leftMargin != 0) ? PrintUtilities.milsToPoints(leftMargin) : defaultMargin;
        double y = (topMargin != 0) ? PrintUtilities.milsToPoints(topMargin) : defaultMargin;
        double width = (rightMargin != 0) ? options.getWidth() - PrintUtilities.milsToPoints(rightMargin) - x : options.getWidth() - (defaultMargin*2);
        double height = (bottomMargin != 0) ? options.getHeight() - PrintUtilities.milsToPoints(bottomMargin) - y : options.getHeight() - (defaultMargin*2);

        // If we are in landscape mode, then we need to swap the width and height around.
        if (options.getOrientation() == PageFormat.LANDSCAPE) {
          double tmpWidth = width;
          width = height;
          height = tmpWidth;
        }

        // CraigM:30/05/2008 - The working page is now scaled in the BookComponentPrintable so we shouldn't set the size
        // workingPage.setSize((int)width, (int)height);
       
        paper.setImageableArea(x, y, width, height);
        options.setPaper(paper);

        this.append(new BookComponentPrintable(workingPage), getPrintOptions());
    }
View Full Code Here

    }

    public int getNumberOfPages() {
        StyledDocument doc = (StyledDocument)getDocument();
       
        Paper paper = PAGE_FORMAT.getPaper();
       
        numPages =
            (int)Math.ceil(getSize().getHeight() / paper.getImageableHeight());
       
        return numPages;
    }
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.