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 Thu, 26 Jul 2012 07:02:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Printer">Printer</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~njiang">willem
jiang</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{flavor}} | {{DocFlavor.BYTE_ARRAY}}
| Sets DocFlavor based on the javax.print.DocFlavor API | <br>| {{mimeType}} | {{AUTOSENSE}}
| Sets mimeTypes supported by the javax.print.DocFlavor API | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{mediaTray}} | {{AUTOSENSE}} | Since *Camel 2.11.x* sets MediaTray supported by the javax.print.DocFlavor
API | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <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-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-printer<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</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>
<div class="confluenceTableSmall"><div class='table-wrap'>
<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 <a href="http://download.oracle.com/javase/6/docs/api/javax/print/attribute/standard/MediaSizeName.html"
class="external-link" rel="nofollow">javax.print.attribute.standard.MediaSizeName API</a>.
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>
<tr>
<td class='confluenceTd'> <tt>mediaTray</tt> </td>
<td class='confluenceTd'> <tt>AUTOSENSE</tt> </td>
<td class='confluenceTd'> Since <b>Camel 2.11.x</b> sets MediaTray supported
by the javax.print.DocFlavor API </td>
</tr>
</tbody></table>
</div>
</div>

<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="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Printer">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=3474125&revisedVersion=8&originalVersion=7">View
Changes</a>
                |
        <a href="https://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