Package java.awt.print

Examples of java.awt.print.PrinterJob


    {
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        PrinterJob pj = PrinterJob.getPrinterJob();

        if (pj.printDialog())
        {
          PageFormat pf = graphComponent.getPageFormat();
          Paper paper = new Paper();
          double margin = 36;
          paper.setImageableArea(margin, margin, paper.getWidth()
              - margin * 2, paper.getHeight() - margin * 2);
          pf.setPaper(paper);
          pj.setPrintable(graphComponent, pf);

          try
          {
            pj.print();
          }
          catch (PrinterException e2)
          {
            System.out.println(e2);
          }
View Full Code Here


    final OrderChooser fieldChooser = new OrderChooser(ProgramInfoPrintSettings.getInstance().getFieldTypes(),ProgramTextCreator.getDefaultOrder(),true);
    final FontChooserPanel fontChooser = new FontChooserPanel("",ProgramInfoPrintSettings.getInstance().getFont(), false);
    final JCheckBox printImage = new JCheckBox(mLocalizer.msg("printImage","Print image"), ProgramInfoPrintSettings.getInstance().isPrintImage());
    final JCheckBox printPluginIcons = new JCheckBox(mLocalizer.msg("printPluginIcons","Print plugin icons"), ProgramInfoPrintSettings.getInstance().isPrintPluginIcons());
    final PrinterJob printerJob = PrinterJob.getPrinterJob();
    mPageFormat = printerJob.defaultPage();
   
    JButton printerSetupBtn = new JButton(SettingsDialog.mLocalizer.ellipsisMsg("printer","Printer"),PrintPlugin.getInstance().createImageIcon("devices", "printer", 16));
    printerSetupBtn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        new Thread("Printer setup") {
          public void run() {
            printerJob.printDialog();
          }
        }.start();
      }
    });
   
    JButton pageBtn = new JButton(SettingsDialog.mLocalizer.ellipsisMsg("page","Page"), PrintPlugin.getInstance().createImageIcon("actions", "document-properties", 16));
    pageBtn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent event) {
        new Thread("Document setup (printing)"){
          public void run(){
            if (mPageFormat == null) {
              mPageFormat = printerJob.defaultPage();
            }
            mPageFormat = printerJob.pageDialog(mPageFormat);
          }
        }.start();
      }
    });
   
    JButton previewBtn = new JButton(SettingsDialog.mLocalizer.ellipsisMsg("preview","Preview"), PrintPlugin.getInstance().createImageIcon("actions", "document-print-preview", 16));
    previewBtn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (mPageFormat == null) {
          mPageFormat = printerJob.defaultPage();
        }
       
        mFieldTypes = fieldChooser.getOrder();
       
        DocumentRenderer printJob = createPrintjob(program, fontChooser, printImage, printPluginIcons);
       
        PreviewDlg dlg = new PreviewDlg(mDialog, printJob, mPageFormat, printJob.getPageCount());
       
        PrintPlugin.getInstance().layoutWindow("previewDlg",dlg);
       
        dlg.setVisible(true);
      }
    });
   
    JButton print = new JButton(SettingsDialog.mLocalizer.msg("print","Drucken"));
    print.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (mPageFormat == null) {
          mPageFormat = printerJob.defaultPage();
        }
       
        mFieldTypes = fieldChooser.getOrder();
       
        ProgramInfoPrintSettings.getInstance().setFont(fontChooser.getChosenFont());
        ProgramInfoPrintSettings.getInstance().setFieldTypes(mFieldTypes);
        ProgramInfoPrintSettings.getInstance().setPrintImage(printImage.isSelected());
        ProgramInfoPrintSettings.getInstance().setPrintPluginIcons(printPluginIcons.isSelected());
        close();
       
        DocumentRenderer printable = createPrintjob(program, fontChooser, printImage, printPluginIcons);

        printerJob.setPrintable(printable, mPageFormat);
        try {
          printerJob.print();
        } catch (PrinterException pe) {
          util.exc.ErrorHandler.handle("Could not print pages: "+pe.getLocalizedMessage(), pe);
        }
       
      }
View Full Code Here

    }
     }

     public void printDokument(){
       try {
          PrinterJob pjob = PrinterJob.getPrinterJob();
          pjob.setJobName("Patient Document");
          pjob.setCopies(1);
          pjob.setPrintable(new Printable() {
            public int print(Graphics pg, PageFormat pf, int pageNum) {
              if (pageNum > 0)
                return Printable.NO_SUCH_PAGE;
              pg.drawString(aEEG.loadKDatei(), 50, 50);
              return Printable.PAGE_EXISTS;
            }
          });

          if (pjob.printDialog() == false)
            return;
          pjob.print();
        } catch (PrinterException pe) {
          pe.printStackTrace();
        }
        }
View Full Code Here

     * @throws IndexOutOfBoundsException if the page index is invalid
     */
    public PageFormat getPageFormat(int pageIndex)
    {
        try {
            PrinterJob printerJob = PrinterJob.getPrinterJob();
            return new PDPageable(this, printerJob).getPageFormat(pageIndex);
        } catch (PrinterException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

    public static Font getExtendedFont(int pointSize, int typeFace, boolean isBold, boolean isItalic){
        return getPortableFont(pointSize, typeFace, isBold, isItalic);
    }
    public static PageFormat getDefaultPrintOptions(){
        PrinterJob pjob = PrinterJob.getPrinterJob();
        PageFormat pf = pjob.defaultPage();
        return pf;
    }
View Full Code Here

    public PrintSetupActionListener() {
        super();
    }

    public void actionPerformed(ActionEvent e) {
        PrinterJob pjob = PrinterJob.getPrinterJob();

        // Get and change default page format settings if necessary.
        PageFormat pf = pjob.defaultPage();
       
        // Set the default options.  CraigM: 31/03/2008.
        pf.setOrientation(PrintUtilities.getDefaultPrintOptions().getOrientation());
        pf.setPaper(PrintUtilities.getDefaultPrintOptions().getPaper());

        // Show page format dialog with page format settings.
        pf = pjob.pageDialog(pf);
       
        // Update the default options.  CraigM: 31/03/2008.
        PrintUtilities.getDefaultPrintOptions().setOrientation(pf.getOrientation());
        PrintUtilities.getDefaultPrintOptions().setPaper(pf.getPaper());
    }
View Full Code Here

    public static Font getExtendedFont(int pointSize, int typeFace, boolean isBold, boolean isItalic){
        return getPortableFont(pointSize, typeFace, isBold, isItalic);
    }
    public static PageFormat getDefaultPrintOptions(){
        PrinterJob pjob = PrinterJob.getPrinterJob();
        PageFormat pf = pjob.defaultPage();
        return pf;
    }
View Full Code Here

    /**
     * Prints the document and closes it.
     */
    public static void closePrintDocument(PrintDocument doc){
        defaultPrintOptions = null;
        PrinterJob printJob = getPrinterJob();
        printJob.setPageable(doc);
        try {
            printJob.print();
            printDoc = null;
        } catch(PrinterException pe) {
            RuntimeException errorVar = new RuntimeException(pe.getMessage(), pe);
            ErrorMgr.addError(errorVar);
            throw errorVar;
View Full Code Here

     */
    public static PrintOptionsDesc getDefaultPrintOptions() {
        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
View Full Code Here

         * @throws IOException
         * @throws PrinterException
         */
        public static void main(String[] args) throws IOException, PrinterException {
                // Get the PrinterJob object that coordinates everything
                PrinterJob job = PrinterJob.getPrinterJob();

                // Get the default page format, then ask the user to customize it
                PageFormat format = job.pageDialog(job.defaultPage());

                // Create our PageableText object, and tell the PrinterJob about it
                job.setPageable(new PageableText(new File(args[0]), format));

                // Ask the user to select a printer, etc., and if not canceled, print!
                if (job.printDialog()) {
                        job.print();
                }
        }
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.