pageFormat = printerjob.defaultPage(); pageFormat = printerjob.defaultPage(); // Set the default printer instead. } catch (PrinterException exception) { System.err.println("Printing error: " + exception);
static private PageFormat getMinimumMarginPageFormat(PrinterJob printJob) { PageFormat pf0 = printJob.defaultPage(); PageFormat pf1 = (PageFormat) pf0.clone(); Paper p = pf0.getPaper(); p.setImageableArea(0, 0,pf0.getWidth(), pf0.getHeight()); pf1.setPaper(p); PageFormat pf2 = printJob.validatePage(pf1); return pf2; }
PageFormat pf = pj.defaultPage(); Paper paper = pf.getPaper(); double width = fromCMToPPI(3.5);
/** @return an instance of PageFormat * The returned page format is either previously set by * PageSetupAction or is acquired as a default PageFormat * from supported PrinterJob */ public static PageFormat getPageFormat(PrinterJob pj) { if (pageFormat == null) { pageFormat = pj.defaultPage(); } return pageFormat; } /** @deprecated Use {@link #getPageFormat(PrinterJob)} instead. */
/** @return an instance of PageFormat * The returned page format is either previously set by * PageSetupAction or is acquired as a default PageFormat * from supported PrinterJob */ public static PageFormat getPageFormat(PrinterJob pj) { if (pageFormat == null) { pageFormat = pj.defaultPage(); } return pageFormat; } /** @deprecated Use {@link #getPageFormat(PrinterJob)} instead. */
PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); pf.setOrientation(PageFormat.LANDSCAPE); job.setPrintable(myPrintableObject, pf);
final PrinterJob printJob = PrinterJob.getPrinterJob(); printJob.setPrintService(ps); final PageFormat pf = printJob.defaultPage(); System.out.println("Printer Page width=" + pf.getWidth() + " height=" + pf.getHeight());
JFrame yourComponent = new JFrame(); PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat preformat = pjob.defaultPage(); preformat.setOrientation(PageFormat.LANDSCAPE); PageFormat postformat = pjob.pageDialog(preformat); if (preformat != postformat) { pjob.setPrintable(new Printer(yourComponent), postformat); if (pjob.printDialog()) { pjob.print(); } }
/** @deprecated Use {@link #getPageFormat(PrinterJob)} instead. */ public PageFormat getPageFormat() { if (pageFormat == null) { PrinterJob pj = PrinterJob.getPrinterJob(); pageFormat = pj.defaultPage(new PageFormat()); pj.cancel(); } return pageFormat; }
JFrame yourComponent = new JFrame(); PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat preformat = pjob.defaultPage(); preformat.setOrientation(PageFormat.LANDSCAPE); PageFormat postformat = pjob.pageDialog(preformat); //If user does not hit cancel then print. if (preformat != postformat) { //Set print component pjob.setPrintable(new Printer(yourComponent), postformat); if (pjob.printDialog()) { pjob.print(); } }
PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); pjob.setPrintable(null, pf); if (pjob.printDialog()) { pjob.print(); }
/** @deprecated Use {@link #getPageFormat(PrinterJob)} instead. */ public PageFormat getPageFormat() { if (pageFormat == null) { PrinterJob pj = PrinterJob.getPrinterJob(); pageFormat = pj.defaultPage(new PageFormat()); pj.cancel(); } return pageFormat; }
private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); pjob.setPrintable(this, pf); try { if (pjob.printDialog()) { pjob.print(); } } catch (PrinterException e) { Exceptions.printStackTrace(e); } }//GEN-LAST:event_printButtonActionPerformed private final String LAST_PATH = "SimpleHTMLReport_Save_Last_Path";
import java.awt.print.PageFormat; import java.awt.print.PrinterJob; public class PrinterSetup { public static void main(String[] args) throws Exception { PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); pjob.setPrintable(null, pf); if (pjob.printDialog()) { pjob.print(); } } }
PageFormat format = new PageFormat(); format.setOrientation(PageFormat.REVERSE_LANDSCAPE); PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(OrientationRequested.REVERSE_LANDSCAPE); aset.add(MediaSizeName.JAPANESE_POSTCARD); PrinterJob printerJob = PrinterJob.getPrinterJob(); printerJob.setPrintable(new ImagePrintable(sap.getGraphicImage())); printerJob.defaultPage(format); printerJob.print(aset);
public void print() { PrinterJob printJob = PrinterJob.getPrinterJob(); if (printJob.printDialog()) { try { PageFormat pf = printJob.defaultPage(); pf.setOrientation(PageFormat.LANDSCAPE); printJob.setPrintable(this, pf); printJob.print(); } catch (PrinterException e) { ErrorViewManager.getInstance().showErrorDialog(null, e); } } }
private PageDefinition createDefaultPageDefinition() { 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() ); } return format; }
public void print() { PrinterJob printJob = PrinterJob.getPrinterJob(); if (printJob.printDialog()) { try { PageFormat pf = printJob.defaultPage(); pf.setOrientation(PageFormat.LANDSCAPE); printJob.setPrintable(new MyPrintable(), pf); printJob.print(); } catch (PrinterException e) { ErrorViewManager.getInstance().showErrorDialog(this, e); } } }
public void print() { PrinterJob printJob = PrinterJob.getPrinterJob(); if (printJob.printDialog()) { try { PageFormat pf = printJob.defaultPage(); pf.setOrientation(PageFormat.LANDSCAPE); printJob.setPrintable(new MyPrintable(), pf); printJob.print(); } catch (PrinterException e) { ErrorViewManager.getInstance().showErrorDialog(this, e); } } }
PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); Paper paper = pf.getPaper(); double margin = 20.; paper.setImageableArea(margin, paper.getImageableY(), paper.getWidth() - 2* margin, paper.getImageableHeight()); pf.setPaper(paper); job.setPrintable(table.getPrintable(JTable.PrintMode.FIT_WIDTH, null, null), job.validatePage(pf)); job.print();