12-29-2010 05:34 AM
12-29-2010 07:50 AM
01-03-2011 04:19 PM
01-04-2011 04:13 AM
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");
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.