Hi Guy, When you set up the Service, you can tell Windows what credentials to use to run the job. By default, it will be Local Admin, but you can give it any AD user (and password).
Try running the job under your own credentials. Frank On Mon, Jan 12, 2015 at 11:12 AM, John Hewson <[email protected]> wrote: > 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 > >

