Skip to content

Commit

Permalink
Added debug logs to troubleshoot print size problem
Browse files Browse the repository at this point in the history
  • Loading branch information
imTigger committed Aug 28, 2020
1 parent 5bf8d35 commit 4c87253
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,17 @@ private void printImage(PrintDocument printDocument) throws PrinterException, IO
job.setPrintService(docPrintJob.getPrintService());
PageFormat pageFormat = job.defaultPage();

logger.trace("Paper Size: " + pageFormat.getWidth() + " x " + pageFormat.getHeight());
logger.trace("Imageable Size:" + pageFormat.getImageableWidth() + " x " + pageFormat.getImageableHeight());
logger.debug("Driver Returned PageFormat Size: " + pageFormat.getWidth() + " x " + pageFormat.getHeight());
logger.debug("Driver Returned PageFormat Imageable Size:" + pageFormat.getImageableWidth() + " x " + pageFormat.getImageableHeight());
logger.debug("Driver Returned Paper Size: " + pageFormat.getPaper().getWidth() + " x " + pageFormat.getPaper().getHeight());
logger.debug("Driver Returned Paper Imageable Size: " + pageFormat.getPaper().getImageableWidth() + " x " + pageFormat.getPaper().getImageableHeight());

Paper paper = pageFormat.getPaper();
double width = pageFormat.getWidth();
double height = pageFormat.getHeight();

Paper paper = pageFormat.getPaper();

// Reset Imageable Area
paper.setSize(width, height);
paper.setImageableArea(0, 0, width, height);
pageFormat.setPaper(paper);
Expand Down Expand Up @@ -220,13 +225,17 @@ private void printPDF(PrintDocument printDocument) throws PrinterException, IOEx
job.setPrintService(docPrintJob.getPrintService());
PageFormat pageFormat = job.defaultPage();

logger.trace("Paper Size: " + pageFormat.getWidth() + " x " + pageFormat.getHeight());
logger.trace("Imageable Size:" + pageFormat.getImageableWidth() + " x " + pageFormat.getImageableHeight());
logger.debug("Driver Returned PageFormat Size: " + pageFormat.getWidth() + " x " + pageFormat.getHeight());
logger.debug("Driver Returned PageFormat Imageable Size:" + pageFormat.getImageableWidth() + " x " + pageFormat.getImageableHeight());
logger.debug("Driver Returned Paper Size: " + pageFormat.getPaper().getWidth() + " x " + pageFormat.getPaper().getHeight());
logger.debug("Driver Returned Paper Imageable Size: " + pageFormat.getPaper().getImageableWidth() + " x " + pageFormat.getPaper().getImageableHeight());

Paper paper = pageFormat.getPaper();
double width = pageFormat.getWidth();
double height = pageFormat.getHeight();


Paper paper = pageFormat.getPaper();

// Reset Imageable Area
paper.setSize(width, height);
paper.setImageableArea(0, 0, width, height);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</appenders>

<loggers>
<root level="TRACE">
<root level="DEBUG">
<appender-ref ref="Console" level="INFO"/>
<appender-ref ref="RollingFile" level="DEBUG"/>
</root>
Expand Down

0 comments on commit 4c87253

Please sign in to comment.