Hi,

That isn't a PDFBox problem. You can't print on the client from the server unless the server has access to the 28 client printers. You can test this by using the pdfbox-app command line utility PrintPDF without parameters.

    java -jar pdfbox-app-2.0.20.jar PrintPDF

it will print the available names. If these 28 client printers are available (which I doubt, discuss this with the network security folks), then they will be listed.

You can then set that printer by using

    job.setPrintService(name);

Tilman

Am 24.08.2020 um 05:57 schrieb Subbiah, Murugan:
NONCONFIDENTIAL // EXTERNAL
Hi Tilman,

Our web application is built on JSF (XHTML) and Spring services. PDFbox code is 
on the server side. When we call the load PDF and print code on the server 
side, it gets the default printer of the computer's network where the server is 
running. Our clients are in 28 different locations. We would like the print job 
to grab client's default printer while printing. If you have an example for 
that please send it across. That'll be helpful. Appreciate your help!

Best Regards,
Murugan.



-----Original Message-----
From: Tilman Hausherr <thaush...@t-online.de>
Sent: Thursday, August 20, 2020 11:34 PM
To: users@pdfbox.apache.org
Subject: [External] Re: Silent Printing PDF from server on the client side

NONCONFIDENTIAL // EXTERNAL

PLEASE NOTE: This email is not from a Federal Reserve address.
Do not click on suspicious links. Do not give out personal or bank information 
to unknown senders.



Am 21.08.2020 um 00:24 schrieb Subbiah, Murugan:
NONCONFIDENTIAL // EXTERNAL
I built a PDF Box POC for silent printing. When I ran it in the local machine 
everything worked perfectly. The same didn't work as expected when hosted on 
the network server.

Please try the non PDFBox code below. If it also "didn't work as expected" then 
the cause is not related to PDFBox.


public class PDFBOX4935PrintDpi implements Printable {

      public static void main(String[] args) throws PrinterException
      {
          new PDFBOX4935PrintDpi().doStuff();
      }

      PDFBOX4935PrintDpi()
      {
      }

      void doStuff() throws PrinterException
      {
          PrinterJob job = PrinterJob.getPrinterJob(); 
job.setPrintService(PrintServiceLookup.lookupDefaultPrintService());
          job.setPrintable(this);
          job.print();
      }

      @Override
      public int print(Graphics graphics, PageFormat pageFormat, int index)
      {
          if (index == 0)
          {
              Graphics2D g2d = (Graphics2D) graphics;
              g2d.setFont(new Font("Courier", Font.PLAIN, 12));
              g2d.setColor(Color.BLACK);

              g2d.drawString("ScaleX: " + g2d.getTransform().getScaleX(),
                      (int) (pageFormat.getWidth() / 10), (int)
(pageFormat.getHeight() / 2));
              g2d.drawString("ScaleY: " + g2d.getTransform().getScaleY(),
                      (int) (pageFormat.getWidth() / 10), (int)
(pageFormat.getHeight() / 2) + 25);
              g2d.drawString("DPI:    " +
Math.round(g2d.getTransform().getScaleX() * 72),
                      (int) (pageFormat.getWidth() / 10), (int)
(pageFormat.getHeight() / 2) + 60);

              return Printable.PAGE_EXISTS;
          }
          return Printable.NO_SUCH_PAGE;
      }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to