How to add the necessary permissions for Printer Job to work on Tomcat7

1

Environment

My environment is Tomcat7 and I'm using Java 1.8, Windows 10 and I'm using a PDF Reader to test the print. My user is an administrator of the machine.

Problem

I'm trying to send a PDF to print, but this PDF does not print. When the print request arrives in the queue, it is spooled eternally with a blank size.

Printing works if I start Tomcat7 from CMD, if I use services.msc or TomcatW the printout does not work. The difference between the two is the initialization of the user profile in the CMD log Tomcat7 loads C: \ WINDOWS \ system32 \ config \ systemprofile.dnx \ bin and logs using services.msc > C: \ Users \ MY_USER.dnx \ bin

I have discovered that this means permission problems for the print queue, but I can not find a specific reason why my user who is the administrator of the machine can not print. Things I've already tried to solve the problem:

  • Run Tomcat7 using the LogOn option with an Administrator account (Including network administrator)
  • Enable the "Allow service to interact with desktop" option
  • Disable Firewall / AntiVirus
  • Start Tomcat7w with admin privileges for all users.
  • Add the machine user to 'Log on as service' using gpedit
  • Switch the Java version to 7.
  • Install / Uninstall the tomcat service using a user with Administrator privileges.
  • Clear the Tomcat7 registry key (HKEY)
  • I've already looked at SO in English, including the web, none of the solutions found worked.

    Code that I'm using to print: Using PDFBox to load PDF.

    PDDocument pdDoc = PDDocument.load(pdfFile);
    
    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintService(service);
    job.setJobName("The System Job");
    job.setPageable(new PDFPageable(pdDoc));
    job.print();
    
    pdDoc.close();
    

    I found a solution using PrintService to create PrinterJob and it still did not work.

    service.createPrintJob().print(pdDoc, null);
    

    Does anyone have any solutions to the problem?

        
    asked by anonymous 25.10.2016 / 20:29

    0 answers