You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jmh <je...@nrb.be> on 2012/09/19 19:59:48 UTC

print a PDF with camel-printer

Hello,

what is the right syntax (options ?) to print a pdf with camel-printer ?

I don't find any example...

J-M



--
View this message in context: http://camel.465427.n5.nabble.com/print-a-PDF-with-camel-printer-tp5719615.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: print a PDF with camel-printer

Posted by jmh <je...@nrb.be>.
Yes, I wanted to suggest to add this option ;-)

Thanks for your help

J-M



--
View this message in context: http://camel.465427.n5.nabble.com/print-a-PDF-with-camel-printer-tp5719615p5719650.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: print a PDF with camel-printer

Posted by Willem jiang <wi...@gmail.com>.
I just committed the patch[1] of it into the trunk.

Please check out the camel-2.11-SNAPSHOT to verify the patch.

[1]http://svn.apache.org/viewvc?rev=1387889&view=rev 

-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Thursday, September 20, 2012 at 11:57 AM, Willem jiang wrote:

> I think we can add a printer prefix option on the camel-printer endpoint to help us find the right printer we want.
> I just fill a JIRA[1] for it.
> 
> [1]https://issues.apache.org/jira/browse/CAMEL-5630
> -- 
> Willem Jiang
> 
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
> http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang 
> Weibo: willemjiang
> 
> 
> 
> 
> 
> On Thursday, September 20, 2012 at 6:09 AM, jmh wrote:
> 
> > thanks Babak
> > 
> > But I have another problem on Windows 2008 server.
> > 
> > services (printers) are prefixed by "Win32 Printer :" 
> > 
> > i.e :[Win32 Printer : Microsoft XPS Document Writer, Win32 Printer :
> > \\nrbnrw0264\nrbco006]
> > 
> > But when I look the source code, I realize that it can never be equal to the
> > config :-(
> > 
> > 
> > <pre>
> > PrintService printService;
> > 085 
> > 086 if ((config.getHostname().equalsIgnoreCase("localhost")) 
> > 087 &&
> > (config.getPrintername().equalsIgnoreCase("/default"))) {
> > 088 printService =
> > PrintServiceLookup.lookupDefaultPrintService(); 
> > 089 } else {
> > 090 PrintService[] services =
> > PrintServiceLookup.lookupPrintServices(null, null);
> > 091 setPrinter("\\\\" + config.getHostname() + "\\" +
> > config.getPrintername());
> > 092 int position = findPrinter(services, printer);
> > 093 if (position < 0) {
> > 094 throw new PrintException("No printer found with name:
> > " + printer + ". Please verify that the host and printer are registered and
> > reachable from this machine.");
> > 095 } 
> > 096 printService = services[position];
> > 097 }
> > 098 return printService;
> > 099 }
> > 100 
> > 101 private int findPrinter(PrintService[] services, String printer)
> > {
> > 102 int position = -1;
> > 103 for (int i = 0; i < services.length; i++) {
> > 104 if (printer.equalsIgnoreCase(services[i].getName())) {
> > 105 position = i;
> > 106 break;
> > 107 }
> > 108 }
> > 109 return position;
> > 110 }
> > </pre>
> > 
> > J-M
> > 
> > 
> > 
> > --
> > View this message in context: http://camel.465427.n5.nabble.com/print-a-PDF-with-camel-printer-tp5719615p5719631.html
> > Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
> 




Re: print a PDF with camel-printer

Posted by Willem jiang <wi...@gmail.com>.
I think we can add a printer prefix option on the camel-printer endpoint to help us find the right printer we want.
I just fill a JIRA[1] for it.

[1]https://issues.apache.org/jira/browse/CAMEL-5630
-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Thursday, September 20, 2012 at 6:09 AM, jmh wrote:

> thanks Babak
> 
> But I have another problem on Windows 2008 server.
> 
> services (printers) are prefixed by "Win32 Printer :" 
> 
> i.e :[Win32 Printer : Microsoft XPS Document Writer, Win32 Printer :
> \\nrbnrw0264\nrbco006]
> 
> But when I look the source code, I realize that it can never be equal to the
> config :-(
> 
> 
> <pre>
> PrintService printService;
> 085 
> 086 if ((config.getHostname().equalsIgnoreCase("localhost")) 
> 087 &&
> (config.getPrintername().equalsIgnoreCase("/default"))) {
> 088 printService =
> PrintServiceLookup.lookupDefaultPrintService(); 
> 089 } else {
> 090 PrintService[] services =
> PrintServiceLookup.lookupPrintServices(null, null);
> 091 setPrinter("\\\\" + config.getHostname() + "\\" +
> config.getPrintername());
> 092 int position = findPrinter(services, printer);
> 093 if (position < 0) {
> 094 throw new PrintException("No printer found with name:
> " + printer + ". Please verify that the host and printer are registered and
> reachable from this machine.");
> 095 } 
> 096 printService = services[position];
> 097 }
> 098 return printService;
> 099 }
> 100 
> 101 private int findPrinter(PrintService[] services, String printer)
> {
> 102 int position = -1;
> 103 for (int i = 0; i < services.length; i++) {
> 104 if (printer.equalsIgnoreCase(services[i].getName())) {
> 105 position = i;
> 106 break;
> 107 }
> 108 }
> 109 return position;
> 110 }
> </pre>
> 
> J-M
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/print-a-PDF-with-camel-printer-tp5719615p5719631.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: print a PDF with camel-printer

Posted by jmh <je...@nrb.be>.
thanks Babak

But I have another problem on Windows 2008 server.

services (printers) are prefixed by "Win32 Printer :" 

i.e :[Win32 Printer : Microsoft XPS Document Writer, Win32 Printer :
\\nrbnrw0264\nrbco006]

But when I look the source code, I realize that it can never be equal to the
config :-(


<pre>
      PrintService printService;
085            
086            if ((config.getHostname().equalsIgnoreCase("localhost")) 
087                &&
(config.getPrintername().equalsIgnoreCase("/default"))) {
088                printService =
PrintServiceLookup.lookupDefaultPrintService();            
089            } else {
090                PrintService[] services =
PrintServiceLookup.lookupPrintServices(null, null);
091                setPrinter("\\\\" + config.getHostname() + "\\" +
config.getPrintername());
092                int position = findPrinter(services, printer);
093                if (position < 0) {
094                    throw new PrintException("No printer found with name:
" + printer + ". Please verify that the host and printer are registered and
reachable from this machine.");
095                }         
096                printService = services[position];
097            }
098            return printService;
099        }
100        
101        private int findPrinter(PrintService[] services, String printer)
{
102            int position = -1;
103            for (int i = 0; i < services.length; i++) {
104                if (printer.equalsIgnoreCase(services[i].getName())) {
105                    position = i;
106                    break;
107                }
108            }
109            return position;
110        }
</pre>

J-M



--
View this message in context: http://camel.465427.n5.nabble.com/print-a-PDF-with-camel-printer-tp5719615p5719631.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: print a PDF with camel-printer

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

Have you tried setting the mimeType option to "PDF":

http://camel.apache.org/printer.html

Which would correspond to the following MIME type:

http://docs.oracle.com/javase/6/docs/api/javax/print/DocFlavor.BYTE_ARRAY.html#PDF

Also the following unit-test should give you some idea:

https://svn.apache.org/repos/asf/camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java

Babak


jmh wrote
> Hello,
> 
> what is the right syntax (options ?) to print a pdf with camel-printer ?
> 
> I don't find any example...
> 
> J-M





--
View this message in context: http://camel.465427.n5.nabble.com/print-a-PDF-with-camel-printer-tp5719615p5719619.html
Sent from the Camel - Users mailing list archive at Nabble.com.