/** * Fix for bug ID 6255588 from Sun bug database * @param job print job that the fix applies to */ public static void initPrinterJobFields(PrinterJob job) { try { job.setPrintService(job.getPrintService()); } catch (PrinterException e) { } }
@Override protected void notifyLocalChange(int indx, ClarionObject value) { if (indx==Propprint.DEVICE && job!=null && !value.toString().trim().equals(job.getPrintService().getName())) { job=null; } super.notifyLocalChange(indx, value); }
Frame f = new Frame(); DialogOwner dialogOwner = new sun.print.DialogOwner(f); PrinterJob pj = PrinterJob.getPrinterJob(); boolean ok = pj.printDialog(aset); System.out.println( "Result : " + dialogOwner.getName() + " supported : " + pj.getPrintService().isAttributeCategorySupported(dialogOwner.getClass()) ); // Result : dialog-owner supported : false
public void printPDF() { PrinterJob printerJob = PrinterJob.getPrinterJob(); PrintService printService; if(printerJob.printDialog()) { printService = printerJob.getPrintService(); } DocFlavor docType = DocFlavor.INPUT_STREAM.AUTOSENSE; for (//fetch documents to be printed) { DocPrintJob printJob = printService.createPrintJob(); final byte[] byteStream = // fetch content in byte array; Doc documentToBePrinted = new SimpleDoc(new ByteArrayInputStream(byteStream), docType, null); printJob.print(documentToBePrinted, null); } }
Doc document = new SimpleDoc(jTextArea1.getText(), DocFlavor.STRING, new HashDocAttributeSet()); PrinterJob pj = PrinterJob.getPrinterJob(); if (pj.printDialog()) { PrintService ps = pj.getPrintService(); DocPrintJob dpj = ps.createPrintJob(); dpj.print(document, new HashPrintRequestAttributeSet()); }
/** * Private constructor as this only works as a one-shot per print attempt. Use the static method above to hack a * PrintJob, then tell it to print. The hack is gone by the time printing occurs and this instance will be garbage * collected due to having no other references once the PrintJob is back to its original state. * * @param printJob * the print job to affect */ private ForcedAcceptPrintService(PrinterJob printJob) { this.thePrintJob = printJob; this.delegate = printJob.getPrintService(); try { thePrintJob.setPrintService(this); // replace the private PrintService field on the PrintJob instance with a reference // to our replacement PrintService so that we can intercept calls to getAttributes(). // it is expected that the first thing the PrintJob will do is check it's PrintService's // PrinterIsAcceptingJobs attribute, at which point we'll force it to think it is accepting // jobs and restore the PrintService to the original instance to get out of the way. // The only real requirement is that the PrintJob does not cast the PrintService // to it's expected type until after it has checked the PrinterIsAcceptingJobs // attribute. } catch (PrinterException e) { AuditLog.logError(LOGGER, e, "Set Print Service"); //$NON-NLS-1$ } }
PrintService printer = job.getPrintService(); System.out.println("Printer Name:"+printer.getName());
public void print(PrinterJob printerJob) throws PrinterException { HashPrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); Media[] res = (Media[]) printerJob.getPrintService().getSupportedAttributeValues(Media.class, null, null); for (int i = 0; i < res.length; i++) { System.out.println("res[" + i + "]=" + res[i]); System.out.println(res[i].toString()); if (res[i].toString().equals(printerMedia)) { attributes.add(res[i]); } } printerJob.print(attributes); PageFormat pageFormat = printerJob.getPageFormat(attributes); System.out.println("[after opening]"); printPageFormat(pageFormat); pageFormat.setOrientation(PageFormat.PORTRAIT); printerJob.setPrintable(new TestSequenceInstanceLabel.MyPrintable(this), pageFormat); try { printerJob.print(); } catch (PrinterException ex) { ex.printStackTrace(); } }
public ClarionPrinter() { CWin.getInstance(); services=PrinterJob.lookupPrintServices(); defaultService=PrintServiceLookup.lookupDefaultPrintService(); if (getJob()!=null) { setProperty(Propprint.DEVICE,getJob().getPrintService().getName()); } }
Thread newThread = new Thread(new Runnable() { public void run() { PrintService ps = PrinterJob.getPrinterJob().getPrintService();
if ( ok ) { printer_job.print(); final String print_service_name = printer_job.getPrintService().getName(); if ( !ForesterUtil.isEmpty( print_service_name ) ) { return print_service_name;
private String doPrinterDialog(final ClarionString title,final Integer mode) { Object lock=new Object(); ClarionEventQueue.getInstance().setRecordState(false,"Entering printDialog",lock); PrintService ps = printDialog(title!=null?title.toString():null, mode,null,50,50,services, getJob()==null? null : getJob().getPrintService(), null,getAttribute()); ClarionEventQueue.getInstance().setRecordState(true,"Exiting printDialog",lock); if (ps==null) return null; String name = ps.getName(); ClarionString cs = new ClarionString(name); setProperty(Propprint.DEVICE,cs); return name; }
printService = printerJob.getPrintService();
PrintServiceAttributeSet pas = job.getPrintService().getAttributes(); if (pas!=null) { for (Attribute a : pas.toArray()) {