As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
public static void main(String[] args) throws ContentFault, RemoteException { Store workspace = new Store(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); Reference referencePath = new Reference(workspace, "1f177f86-f8d3-40a2-922e-598171e3bf1c", null); WebServiceFactory.setEndpointAddress("http://localhost:8080/alfresco/api"); AuthenticationUtils.startSession("admin", "admin"); try { Content[] read = WebServiceFactory.getContentService().read(new Predicate(new Reference[] { referencePath }, workspace, null), Constants.PROP_CONTENT); Content content = read[0]; print(ContentUtils.getContentAsInputStream(content)); } finally { AuthenticationUtils.endSession(); } } private static void print(InputStream in) { DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG; PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(MediaSizeName.ISO_A4); aset.add(new Copies(1)); PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset); if (pservices.length > 0) { DocPrintJob printJob = pservices[0].createPrintJob(); Doc doc = new SimpleDoc(in, flavor, null); try { printJob.print(doc, aset); } catch (PrintException e) { System.err.println(e); } } else { System.err.println("No suitable printers"); } }