Thank you for the response.

-----Message d'origine-----
De : John Hewson [mailto:[email protected]] 
Envoyé : dimanche 11 janvier 2015 23:12
À : [email protected]
Objet : Re: PDFBOX as a windows Service

Hi Guy,

The print(PrinterJob job) method of PDDocument calls job.printDialog() which 
shows the system print dialog where the user can specify custom print settings.

Window services run under a non-interactive user account, rather than running 
as the current user. That means you won’t see the print dialog, and you won’t 
get any of the default print settings belonging to the your desktop user.

I suspect that your desktop user has set some custom printing preferences and 
these are being passed to Java either via printDialog() or as the PrinterJob 
defaults. Try calling the silentPrint(job) method on PDDocument to bypass the 
dialog. If that does not work, you will need to specify the print settings you 
want using the PrinterJob object.

-- John

> On 11 Jan 2015, at 05:44, [email protected] wrote:
> 
> Hello
>  
> We launch as a dos command an application that listen incoming request to 
> print documents with PDFBOX:
> PDDocument document = PDDocument.load(new URL(d[1])); PrinterJob 
> printJob = PrinterJob.getPrinterJob(); if (printer == null) { 
> System.out.println("printer " + d[0] + " not found. Default printer choosen");
>                 PrintService printService = 
> PrintServiceLookup.lookupDefaultPrintService();
>                 printJob.setPrintService(printService);
> } else {
>           PrintService[] printServices = PrinterJob.lookupPrintServices();
>           for (PrintService printService : printServices) {
>                       if (printService.getName().equals(printer)){
>                           printJob.setPrintService(printService);
>                           break;
> }
> }
> document.print(printJob);
> document.close();
>  
> Everything seems perfect.
>  
> But when I put this application as a Windows Service the document is Half of 
> its size.
> Do you have an Idea ?
>  
> Thanks
>  
>  
> Guy Smadja
> Optic <http://opticemarket.com/>e <http://opticemarket.com/>market.com 
> <http://opticemarket.com/> http://www.optic-box.com 
> <http://www.optic-box.com/> Tel : 01 76 71 08 32

Reply via email to