/** * Prints using custom PrintRequestAttribute values. */ private static void printWithAttributes(PDDocument document) throws IOException, PrinterException { PrinterJob job = PrinterJob.getPrinterJob(); job.setPageable(new PDFPageable(document)); PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet(); attr.add(new PageRanges(1, 1)); // pages 1 to 1 job.print(attr); }
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); Media[] supportedMedia = (Media[]) prnJob.getPrintService().getSupportedAttributeValues(Media.class, null, null); for (Media m : supportedMedia) { if (m.toString().equals("Tray 1")) { aset.add(m); break; } }
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); if (pjob.printDialog(aset)) { try { pjob.print(aset); }
public CurrentJob(int id,PrinterJob job,PrintRequestAttributeSet a,String name,int count) { this.id=id; att=new HashPrintRequestAttributeSet(); att.addAll(a); this.job=job; this.job.setJobName(name); pages=new Page[count]; }
DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT; PrintRequestAttributeSet aset = new HashPrintRequestHashAttributeSet(); aset.add(MediaSizeName.ISO_A4); PrintService[] pservices =PrintServiceLookup.lookupPrintServices(flavor, aset); if (pservices.length > 0) { DocPrintJob pj = pservices[0].createPrintJob(); //.... }
@Override public boolean add(String value) { throw new UnmodifiableSetException(); }
DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT; PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(MediaSizeName.ISO_A4); PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);
job.setPageable(new PDFPageable(document)); PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet(); attr.add(new PageRanges(1, 1)); // pages 1 to 1 if (PDViewerPreferences.DUPLEX.DuplexFlipLongEdge.toString().equals(dp)) attr.add(Sides.TWO_SIDED_LONG_EDGE); attr.add(Sides.TWO_SIDED_SHORT_EDGE); attr.add(Sides.ONE_SIDED);
@Override public void clear() { throw new UnmodifiableSetException(); }
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(new Copies(5)); aset.add(MediaSize.ISO_A4); aset.add(Sides.DUPLEX);
PrintRequestAttributeSet attr_set = new HashPrintRequestAttributeSet(); attr_set.add(MediaSizeName.ISO_A4); attr_set.add(new Copies(3));
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(OrientationRequested.PORTRAIT); aset.add(MediaSizeName.INVOICE); job.print( aset);
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet(); set.add(OrientationRequested.LANDSCAPE); resultFxTable.print(JTable.PrintMode.FIT_WIDTH, header, footer, false, set, false);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(new Copies(2));
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet(); set.add(OrientationRequested.LANDSCAPE); resultFxTable.print(JTable.PrintMode.FIT_WIDTH, header, footer, false, set, false);
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); attributes.add(selectedTray);
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); PDViewerPreferences vp = document.getDocumentCatalog().getViewerPreferences(); if (vp != null && vp.getDuplex() != null) if (PDViewerPreferences.DUPLEX.DuplexFlipLongEdge.toString().equals(dp)) pras.add(Sides.TWO_SIDED_LONG_EDGE); pras.add(Sides.TWO_SIDED_SHORT_EDGE); pras.add(Sides.ONE_SIDED);
PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(); attrs.add(new PrinterResolution(203, 203, ResolutionSyntax.DPI)); printerExporter.setParameter( JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, attrs);
MessageFormat header = new MessageFormat(" Whatever"); MessageFormat footer = new MessageFormat(" Page {0,number,integer} Whatever"); try { PrintRequestAttributeSet set = new HashPrintRequestAttributeSet(); set.add(OrientationRequested.LANDSCAPE); myTable.print(JTable.PrintMode.FIT_WIDTH, header, footer, false, set, false); JOptionPane.showMessageDialog(null, "\n" + "JTable was Successfully " + "\n" + "Printed on your Default Printer"); } catch (java.awt.print.PrinterException e) { JOptionPane.showMessageDialog(null, "\n" + "Error from Printer Job " + "\n" + e); }
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource); JasperPrint jrPrint = JasperFillManager.fillReport(jasperReport, params, getDataSource()); if (reportName != null && reportName.length() > 0) { jrPrint.setName(reportName); } PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); printRequestAttributeSet.add(MediaSizeName.ISO_A4); PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet(); printServiceAttributeSet.add(new PrinterName("PDFCreator", null)); JRPrintServiceExporter exporter = new JRPrintServiceExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jrPrint); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.TRUE); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE); exporter.exportReport();