...
Maven users will need to add the following dependency to their pom.xml
for this component:
Codeblock |
|
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-printer</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
|
...
Since the URI scheme for a printer has not been standardized (the nearest thing to a standard being the IETF print standard) and therefore not uniformly applied by vendors, we have chosen "lpr" as the scheme.
Codeblock |
lpr://localhost/default[?options]
lpr://remotehost:port/path/to/printer[?options]
|
...
Wiki-Markup |
{div:class=confluenceTableSmall}
|| Name || Default Value || Description ||
| {{mediaSize}} | {{MediaSizeName.NA_LETTER}} | Sets the stationary as defined by enumeration settings in the [javax.print.attribute.standard.MediaSizeName API|http://download.oracle.com/javase/6/docs/api/javax/print/attribute/standard/MediaSizeName.html]. The default setting is to use North American Letter sized stationary |
| {{copies}} | {{1}} | Sets number of copies based on the javax.print.attribute.standard.Copies API |
| {{sides}} | {{Sides.ONE_SIDED}} | Sets one sided or two sided printing based on the javax.print.attribute.standard.Sides API |
| {{flavor}} | {{DocFlavor.BYTE_ARRAY}} | Sets DocFlavor based on the javax.print.DocFlavor API |
| {{mimeType}} | {{AUTOSENSE}} | Sets mimeTypes supported by the javax.print.DocFlavor API |
| {{mediaTray}} | {{AUTOSENSE}} | Since *Camel 2.11.x* sets MediaTray supported by the javax.print.DocFlavor API |
| {{printerPrefix}} | null | Since *Camel 2.11.x* sets the prefix name of the printer, it is useful when the printer name is not start with //hostname/printer|
| {{sendToPrinter}} | true | Setting this option to {{false}} prevents sending of the [print data|http://docs.oracle.com/javase/6/docs/api/javax/print/Doc.html] to the printer|
| {{orientation}} | {{portrait}} | Since *Camel 2.13.x* Sets the page orientation. Possible values: {{portrait}}, {{landscape}}, {{reverse-portrait}} or {{reverse-landscape}}, based on {{javax.print.attribute.standard.OrientationRequested}} |
{div} |
Sending Messages to a Printer
...
Example 1: Printing text based payloads on a Default printer using letter stationary and one-sided mode
Codeblock |
RouteBuilder builder = new RouteBuilder() {
public void configure() {
from(file://inputdir/?delete=true)
.to("lpr://localhost/default?copies=2" +
"&flavor=DocFlavor.INPUT_STREAM&" +
"&mimeType=AUTOSENSE" +
"&mediaSize=na-letter" +
"&sides=one-sided")
}};
|
Example 2: Printing GIF based payloads on a Remote printer using A4 stationary and one-sided mode
Codeblock |
RouteBuilder builder = new RouteBuilder() {
public void configure() {
from(file://inputdir/?delete=true)
.to("lpr://remotehost/sales/salesprinter" +
"?copies=2&sides=one-sided" +
"&mimeType=GIF&mediaSize=iso-a4" +
"&flavor=DocFlavor.INPUT_STREAM")
}};
|
Example 3: Printing JPEG based payloads on a Remote printer using Japanese Postcard stationary and one-sided mode
Codeblock |
RouteBuilder builder = new RouteBuilder() {
public void configure() {
from(file://inputdir/?delete=true)
.to("lpr://remotehost/sales/salesprinter" +
"?copies=2&sides=one-sided" +
"&mimeType=JPEG" +
"&mediaSize=japanese-postcard" +
"&flavor=DocFlavor.INPUT_STREAM")
}};
|