Package java.awt.print

Examples of java.awt.print.PrinterJob


    throws ServletException
  {
    try
      {
        Driver        driver   = new Driver(foFile, null);
        PrinterJob    pj       = PrinterJob.getPrinterJob();
        PrintRenderer renderer = new PrintRenderer(pj);
       
        driver.setLogger  (log);
        driver.setRenderer(renderer);
        driver.run();
View Full Code Here


    throws ServletException
  {
    try
      {
        Driver        driver   = new Driver();       
        PrinterJob    pj       = PrinterJob.getPrinterJob();
        PrintRenderer renderer = new PrintRenderer(pj);
       
        pj.setCopies(1);       
       
        driver.setLogger   (log);
        driver.setRenderer (renderer);
        driver.render      (input.getParser(), input.getInputSource());
       
View Full Code Here

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

    public void print() throws PrinterException{
        //
        // Now, request the transcoder to actually perform the
        // printing job.
        //
        PrinterJob printerJob =
            PrinterJob.getPrinterJob();

        PageFormat pageFormat =
            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);
        }
        else if(VALUE_PAGE_ORIENTATION_LANDSCAPE.equalsIgnoreCase(pageOrientation)){
            pageFormat.setOrientation(pageFormat.LANDSCAPE);
        }
        else if(VALUE_PAGE_ORIENTATION_REVERSE_LANDSCAPE.equalsIgnoreCase(pageOrientation)){
            pageFormat.setOrientation(pageFormat.REVERSE_LANDSCAPE);
        }

        pageFormat.setPaper(paper);
        pageFormat = printerJob.validatePage(pageFormat);

        //
        // If required, pop up a dialog to adjust the page format
        //
        Boolean showPageFormat = (Boolean)hints.get(KEY_SHOW_PAGE_DIALOG);
        if(showPageFormat != null && showPageFormat.booleanValue()){
            PageFormat tmpPageFormat = printerJob.pageDialog(pageFormat);
            if(tmpPageFormat == pageFormat){
                // Dialog was cancelled, meaning that the print process should
                // be stopped.
                return;
            }

            pageFormat = tmpPageFormat;
        }

        //
        // If required, pop up a dialog to select the printer
        //
        Boolean showPrinterDialog = (Boolean)hints.get(KEY_SHOW_PRINTER_DIALOG);
        if(showPrinterDialog != null && showPrinterDialog.booleanValue()){
            if(!printerJob.printDialog()){
                // Dialog was cancelled, meaning that the print process
                // should be stopped.
                return;
            }
        }

        // Print now
        printerJob.setPrintable(this, pageFormat);
        printerJob.print();

    }
View Full Code Here

            template.setZoomToSelectionHint(true);
            template.setMapScaleHint(currentViewportScaleDenom);
       
       
       
        final PrinterJob printerJob = PrinterJob.getPrinterJob();
        final PageFormat pageFormat = printerJob.defaultPage();
       
       
        //setup the paper
       
        Paper paper = new Paper();
        Rectangle pageSize = getITextPageSize(page1.getPageSize());
        paper.setSize(pageSize.getWidth(), pageSize.getHeight());
        //paper.setSize(11.7*72, 16.5*72);
        //double imageableWidth = paper.getWidth() - MARGIN*2;
        //double imageableHeight = paper.getHeight() - MARGIN*2;
        paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight() );
        pageFormat.setPaper(paper);

       
        if (page1.getTemplateFactory().createTemplate().getPreferredOrientation() == Template.ORIENTATION_LANDSCAPE) {
            pageFormat.setOrientation(PageFormat.LANDSCAPE);
        }
       
        final String jobName = map.getName();
        final TemplatePrintingEngine engine = new TemplatePrintingEngine(map, template, showRasters);
       
        printerJob.setPrintable(engine, pageFormat);
      
       
        Job job = new Job(Messages.PrintAction_jobTitle){
            protected IStatus run( IProgressMonitor monitor ) {
              
               
                if (printerJob.printDialog()) {
                    try {
                       
                        printerJob.setJobName(jobName);
                        printerJob.print();
                       
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
View Full Code Here

            {
                StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
                document.openProtection(sdm);
            }

            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setJobName(new File(pdfFile).getName());

            if (printerName != null)
            {
                PrintService[] printService = PrinterJob.lookupPrintServices();
                boolean printerFound = false;
                for (int i = 0; !printerFound && i < printService.length; i++)
                {
                    if (printService[i].getName().contains(printerName))
                    {
                        printJob.setPrintService(printService[i]);
                        printerFound = true;
                    }
                }
            }
View Full Code Here

                try
                {
                    if (document != null)
                    {
                        PDFPrinter printer = new PDFPrinter(document);
                        PrinterJob job = PrinterJob.getPrinterJob();
                        job.setPageable(printer.getPageable());
                        if (job.printDialog())
                        {
                            job.print();
                        }
                    }
                }
                catch (PrinterException e)
                {
View Full Code Here

  {
    final ModifiableConfiguration reportConfiguration = report.getReportConfiguration();
    final String jobName = reportConfiguration.getConfigProperty
        (PRINTER_JOB_NAME_KEY, report.getTitle());

    final PrinterJob printerJob = PrinterJob.getPrinterJob();
    if (jobName != null)
    {
      printerJob.setJobName(jobName);
    }

    final PrintReportProcessor reportPane = new PrintReportProcessor(report);
    if (progressListener != null)
    {
      reportPane.addReportProgressListener(progressListener);
    }
    printerJob.setPageable(reportPane);
    try
    {
      printerJob.setCopies(getNumberOfCopies(reportConfiguration));
      printerJob.print();
    }
    finally
    {
      reportPane.close();
      if (progressListener != null)
View Full Code Here

      throws PrinterException, ReportProcessingException
  {
    final ModifiableConfiguration reportConfiguration = report.getReportConfiguration();
    final String jobName = reportConfiguration.getConfigProperty(PRINTER_JOB_NAME_KEY, report.getTitle());

    final PrinterJob printerJob = PrinterJob.getPrinterJob();
    if (jobName != null)
    {
      printerJob.setJobName(jobName);
    }

    final PrintReportProcessor reportPane = new PrintReportProcessor(report);
    if (progressListener != null)
    {
      reportPane.addReportProgressListener(progressListener);
    }

    try
    {
      reportPane.fireProcessingStarted();
      printerJob.setPageable(reportPane);
      printerJob.setCopies(getNumberOfCopies(reportConfiguration));
      if (printerJob.printDialog())
      {
        printerJob.print();
        return true;
      }
      return false;
    }
    finally
View Full Code Here

      return true;
    }
    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

TOP

Related Classes of java.awt.print.PrinterJob

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.