camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Printer
Date Mon, 29 Mar 2010 01:00:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/Printer">Printer</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~njiang">willem
jiang</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="Printer-PrinterComponent"></a>Printer Component</h2>

<p><b>Available as of Camel 2.1</b></p>

<p>The <b>printer</b> component provides a way to direct payloads on a route
to a printer. Obviously the payload has to be a formatted piece of payload in order for the
component to appropriately print it. The objective is to be able to direct specific payloads
as jobs to a line printer in a camel flow.</p>

<p>This component only supports a camel producer endpoint.</p>

<p>The functionality allows for the payload to be printed on a default printer, named
local, remote or wirelessly linked printer using the javax printing API under the covers.</p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
    &lt;artifactId&gt;camel-printer&lt;/artifactId&gt;
    &lt;version&gt;x.x.x&lt;/version&gt;
    &lt;!-- use the same version as your Camel core version --&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<h3><a name="Printer-URIformat"></a>URI format</h3>

<p>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 <b>"lpr"</b> as the scheme.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
lpr:<span class="code-comment">//localhost/<span class="code-keyword">default</span>[?options]
</span>lpr:<span class="code-comment">//remotehost:port/path/to/printer[?options]</span>
</pre>
</div></div>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="Printer-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>mediaSize</tt> </td>
<td class='confluenceTd'> <tt>MediaSizeName.NA_LETTER</tt> </td>
<td class='confluenceTd'> Sets the stationary as defined by enumeration settings in
the javax.print.attribute.standard.MediaSizeName API. The default setting is to use North
American Letter sized stationary </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>copies</tt> </td>
<td class='confluenceTd'> <tt>1</tt> </td>
<td class='confluenceTd'> Sets number of copies based on the javax.print.attribute.standard.Copies
API </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>sides</tt> </td>
<td class='confluenceTd'> <tt>Sides.ONE_SIDED</tt> </td>
<td class='confluenceTd'> Sets one sided or two sided printing based on the javax.print.attribute.standard.Sides
API </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>flavor</tt> </td>
<td class='confluenceTd'> <tt>DocFlavor.BYTE_ARRAY</tt> </td>
<td class='confluenceTd'> Sets DocFlavor based on the javax.print.DocFlavor API </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>mimeType</tt> </td>
<td class='confluenceTd'> <tt>AUTOSENSE</tt> </td>
<td class='confluenceTd'> Sets mimeTypes supported by the javax.print.DocFlavor API
</td>
</tr>
</tbody></table>


<h3><a name="Printer-SendingMessagestoaPrinter"></a>Sending Messages to
a Printer</h3>

<h4><a name="Printer-PrinterProducer"></a>Printer Producer </h4>
<p>Sending data to the printer is very straightforward and involves creating a producer
endpoint that can be sent message exchanges on in route.</p>

<h3><a name="Printer-UsageSamples"></a>Usage Samples</h3>

<h4><a name="Printer-Example1%3APrintingtextbasedpayloadsonaDefaultprinterusingletterstationaryandonesidedmode"></a>Example
1: Printing text based payloads on a Default printer using letter stationary and one-sided
mode</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
RouteBuilder builder = <span class="code-keyword">new</span> RouteBuilder() {
    <span class="code-keyword">public</span> void configure() {
       from(file:<span class="code-comment">//inputdir/?delete=<span class="code-keyword">true</span>)
</span>       .to(<span class="code-quote">"lpr:<span class="code-comment">//localhost/<span
class="code-keyword">default</span>?copies=2"</span> +
</span>           <span class="code-quote">"&amp;flavor=DocFlavor.INPUT_STREAM&amp;"</span>
+
           <span class="code-quote">"&amp;mimeType=AUTOSENSE"</span> +
           <span class="code-quote">"&amp;mediaSize=na-letter"</span> +
           <span class="code-quote">"&amp;sides=one-sided"</span>)
    }};
</pre>
</div></div>

<h4><a name="Printer-Example2%3APrintingGIFbasedpayloadsonaRemoteprinterusingA4stationaryandonesidedmode"></a>Example
2: Printing GIF based payloads on a Remote printer using A4 stationary and one-sided mode</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
RouteBuilder builder = <span class="code-keyword">new</span> RouteBuilder() {
    <span class="code-keyword">public</span> void configure() {
       from(file:<span class="code-comment">//inputdir/?delete=<span class="code-keyword">true</span>)
</span>       .to(<span class="code-quote">"lpr:<span class="code-comment">//remotehost/sales/salesprinter"</span>
+
</span>           <span class="code-quote">"?copies=2&amp;sides=one-sided"</span>
+
           <span class="code-quote">"&amp;mimeType=GIF&amp;mediaSize=iso-a4"</span>
+
           <span class="code-quote">"&amp;flavor=DocFlavor.INPUT_STREAM"</span>)
   }};
</pre>
</div></div>

<h4><a name="Printer-Example3%3APrintingJPEGbasedpayloadsonaRemoteprinterusingJapanesePostcardstationaryandonesidedmode"></a>Example
3: Printing JPEG based payloads on a Remote printer using Japanese Postcard stationary and
one-sided mode</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
RouteBuilder builder = <span class="code-keyword">new</span> RouteBuilder() {
    <span class="code-keyword">public</span> void configure() {
       from(file:<span class="code-comment">//inputdir/?delete=<span class="code-keyword">true</span>)
</span>       .to(<span class="code-quote">"lpr:<span class="code-comment">//remotehost/sales/salesprinter"</span>
+
</span>           <span class="code-quote">"?copies=2&amp;sides=one-sided"</span>
+
           <span class="code-quote">"&amp;mimeType=JPEG"</span> +
           <span class="code-quote">"&amp;mediaSize=japanese-postcard"</span>
+
           <span class="code-quote">"&amp;flavor=DocFlavor.INPUT_STREAM"</span>)
    }};
</pre>
</div></div>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Printer">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=3474125&revisedVersion=5&originalVersion=4">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Printer?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message