Refine search
import javax.print.*; class Test { public static void main (String [] args) PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null); System.out.println("Number of print services: " + printServices.length); for (PrintService printer : printServices) System.out.println("Printer: " + printer.getName());
PrintServiceLookup.lookupPrintServices(flavor, aset);
int i;
switch(pservices.length) {
break;
DocPrintJob pj = pservices[i].createPrintJob();
InputStream is = getClass().getResourceAsStream(INPUT_FILE_NAME);
if (is == null) {
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet ();
PrintService [] pservices = PrintServiceLookup.lookupPrintServices (flavor, aset);
throw new Exception("No network printer found");
DocPrintJob pj = pservices[2].createPrintJob();
FileInputStream fis = new FileInputStream ("c:/Temp/test.txt");
Doc doc = new SimpleDoc (fis, flavor, null);
int printer = -1;
for(int i = 0; i<pservices.size(); i++) {
if(pservices[i].getName().contains("\\\\")) {
System.out.println("network printer: " + pservices[i].toString());
printer = i;
PrintService pserv = PrintServiceLookup.lookupDefaultPrintService();
if (pserv == null) {
System.out.println("ERROR-01: no default print service");
System.out.println("Printer: " + pserv.getName());
DocPrintJob job = pserv.createPrintJob();
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
String content = makeZplLabel();
printServiceAttributes.add(new PrinterName(printerName, locale));
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, printServiceAttributes);
if (printServices.length > 0) {
printer = printServices[0];
Debug.logInfo("Using printer: " + printer.getName(), module);
if (!printer.isDocFlavorSupported(psInFormat)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPrinterNotSupportDocFlavorFormat", UtilMisc.toMap("psInFormat", psInFormat, "printerName", printer.getName()), locale));
printer = PrintServiceLookup.lookupDefaultPrintService();
if (printer != null) {
Debug.logInfo("No printer name supplied, using default printer: " + printer.getName(), module);
private void printHelloDocument(String value) {
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.READER.TEXT_PLAIN;
Doc doc = new SimpleDoc(new StringReader(value), flavor, null);
PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, aset);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
if (services.length == 0) {
if (defaultService == null) {
new Notification("No printer found", WARNING_MESSAGE).show(getPage());
} else {
DocPrintJob job = defaultService.createPrintJob();
printDocument(doc, aset, job);
} else {
SwingUtilities.invokeLater(() -> {
PrintService service = ServiceUI.printDialog(null, 200, 200,
services, defaultService, flavor, aset);
if (service != null) {
DocPrintJob job = service.createPrintJob();
printDocument(doc, aset, job);
javax.print.PrintService[] services = PrintServiceLookup.lookupPrintServices(null, set);
DocPrintJob job = queue.createPrintJob();
PrintRequestAttributeSet jobAttrs = new HashPrintRequestAttributeSet();
jobAttrs.add(new JobName(jobName, null));
if (endUserName != null && queue.isAttributeCategorySupported(RequestingUserName.class))
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class);
sPrinterName = ((PrinterName) attr).getValue();
if (sPrinterName.toLowerCase().indexOf(printerName) >= 0) {
throw new ZebraPrintNotFoundException("Zebra printer not found : " + printerName);
DocPrintJob job = psZebra.createPrintJob();
public TableModel produce( final DataRow parameters, final DataFactoryContext dataFactoryContext ) throws ReportDataFactoryException { final PrintService[] services = PrintServiceLookup.lookupPrintServices( DocFlavor.SERVICE_FORMATTED.PAGEABLE, null ); final TypedTableModel tt = new TypedTableModel(); tt.addColumn( "Printer ID", String.class ); tt.addColumn( "Printer Name", String.class ); for ( int i = 0; i < services.length; i++ ) { final PrintService service = services[i]; final PrinterName displayName = service.getAttribute( PrinterName.class ); if ( displayName != null ) { tt.addRow( new Object[] { service.getName(), displayName.getValue() } ); } else { tt.addRow( new Object[] { service.getName(), service.getName() } ); return tt;
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob job = service.createPrintJob();
Doc doc = new SimpleDoc(is, DocFlavor.INPUT_STREAM.AUTOSENSE, null);
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
PrintService printService = null;
for(PrintService ps : printServices){
if(ps.getName().equals(printer)){
printService = ps;
break;
jrExporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE, printService);
jrExporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET,
printService.getAttributes());
jrExporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
jrExporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
private PrintService[] lookForPrintServices() {
PrintService[] services = PrintServiceLookup.lookupPrintServices(
DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
// check for a default service and make sure it is at index 0. the lookupPrintServices does not
// aways put the default printer first in the array.
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
if (defaultService != null && services.length > 1) {
PrintService printService;
for (int i = 1, max = services.length; i < max; i++) {
printService = services[i];
if (printService.equals(defaultService)) {
// found the default printer, now swap it with the first index.
PrintService tmp = services[0];
services[0] = defaultService;
services[i] = tmp;
break;
return services;
/**
* List available devices
* @return returns a list of available devices that accepts DocFlavor.INPUT_STREAM.AUTOSENSE
public static PrintService[] getDevices() {
PrintService[] printers = PrintServiceLookup.lookupPrintServices(FLAVOR, null);
return printers;
public ClarionPrinter()
CWin.getInstance();
services=PrinterJob.lookupPrintServices();
defaultService=PrintServiceLookup.lookupDefaultPrintService();
if (getJob()!=null) {
setProperty(Propprint.DEVICE,getJob().getPrintService().getName());
PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
AttributeSet att = printer.getAttributes();
import javax.print.PrintServiceLookup; PrintService service = PrintServiceLookup.lookupDefaultPrintService();
Doc myDoc = new SimpleDoc(psStream, psInFormat, null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, aset);
DocPrintJob job = myPrinter.createPrintJob();
try {
job.print(myDoc, aset);
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
PrintService printServices[] = PrintServiceLookup.lookupPrintServices(
flavor, pras);
printerList.add( printerService.getName());
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
PrintService printService[] = PrintServiceLookup.lookupPrintServices(
flavor, pras);
PrintService service = findPrintService(printerName, printService);
DocPrintJob job = service.createPrintJob();
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
PrintService printService[] = PrintServiceLookup.lookupPrintServices(
flavor, pras);
PrintService service = findPrintService(printerName, printService);
DocPrintJob job = service.createPrintJob();
public static void main(String[] args) throws PrintException {
final DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintService ps=PrintServiceLookup.lookupDefaultPrintService();
System.out.println(ps.getName());
ps.createPrintJob().print(new SimpleDoc(new PrintDev(), flavor, null), null);
attributeSet.add(Sides.ONE_SIDED);
attributeSet.add(OrientationRequested.PORTRAIT);
PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null);//attributeSet);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob job = chosenService.createPrintJob();
Doc myDoc = new SimpleDoc(masterImage, flavor, null);//attributeSet);
try {