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