You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ec...@apache.org on 2008/10/11 20:55:11 UTC
svn commit: r703709 - in /ofbiz/trunk/applications/content:
servicedef/services_output.xml
src/org/ofbiz/content/output/OutputServices.java
Author: eckardjf
Date: Sat Oct 11 11:55:10 2008
New Revision: 703709
URL: http://svn.apache.org/viewvc?rev=703709&view=rev
Log:
Adding support for document and print request attributes to the sendPrintFromScreen service (orientation, collate, finishings, copies, page ranges, etc.)
Modified:
ofbiz/trunk/applications/content/servicedef/services_output.xml
ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java
Modified: ofbiz/trunk/applications/content/servicedef/services_output.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services_output.xml?rev=703709&r1=703708&r2=703709&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services_output.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services_output.xml Sat Oct 11 11:55:10 2008
@@ -31,6 +31,8 @@
<attribute name="contentType" type="String" mode="IN" optional="true"/>
<attribute name="printerContentType" type="String" mode="IN" optional="true"/>
<attribute name="printerName" type="String" mode="IN" optional="true"/>
+ <attribute name="docAttributes" type="List" mode="IN" optional="true"/>
+ <attribute name="printRequestAttributes" type="List" mode="IN" optional="true"/>
</service>
<service name="createFileFromScreen" max-retry="0" engine="java"
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java?rev=703709&r1=703708&r2=703709&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java Sat Oct 11 11:55:10 2008
@@ -62,11 +62,15 @@
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
+import javax.print.attribute.DocAttribute;
+import javax.print.attribute.DocAttributeSet;
+import javax.print.attribute.HashDocAttributeSet;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.HashPrintServiceAttributeSet;
+import javax.print.attribute.PrintRequestAttribute;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.PrintServiceAttribute;
import javax.print.attribute.PrintServiceAttributeSet;
-import javax.print.attribute.HashPrintRequestAttributeSet;
-import javax.print.attribute.HashPrintServiceAttributeSet;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.PrinterName;
import javax.print.attribute.standard.PrinterURI;
@@ -141,8 +145,17 @@
// Print is sent
DocFlavor psInFormat = new DocFlavor.INPUT_STREAM(printerContentType);
InputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
- Doc myDoc = new SimpleDoc(bais, psInFormat, null);
+
+ DocAttributeSet docAttributeSet = new HashDocAttributeSet();
+ List docAttributes = (List) serviceContext.remove("docAttributes");
+ if (UtilValidate.isNotEmpty(docAttributes)) {
+ for (Object da : docAttributes) {
+ Debug.logInfo("Adding DocAttribute: " + da, module);
+ docAttributeSet.add((DocAttribute) da);
+ }
+ }
+
+ Doc myDoc = new SimpleDoc(bais, psInFormat, docAttributeSet);
PrintServiceAttributeSet psaset = new HashPrintServiceAttributeSet();
if (UtilValidate.isNotEmpty(printerName)) {
try {
@@ -175,7 +188,13 @@
}
if (UtilValidate.isNotEmpty(printer)) {
PrintRequestAttributeSet praset = new HashPrintRequestAttributeSet();
- praset.add(new Copies(1));
+ List printRequestAttributes = (List) serviceContext.remove("printRequestAttributes");
+ if (UtilValidate.isNotEmpty(printRequestAttributes)) {
+ for (Object pra : printRequestAttributes) {
+ Debug.logInfo("Adding PrintRequestAttribute: " + pra, module);
+ praset.add((PrintRequestAttribute) pra);
+ }
+ }
DocPrintJob job = printer.createPrintJob();
job.print(myDoc, praset);
} else {