I'm simply trying to print a .docx document. The problem is, when I print my document, the result doesn't fit with the page. Here's my original document:
And here's what I have when I print it
My code is simple, I don't know what to put inside to settle this:
- Code: Select all
com.spire.doc.Document document = new com.spire.doc.Document();
document.loadFromFile("src/main/resources/test.docx");
PrinterJob printerJob = PrinterJob.getPrinterJob();
PageFormat format = printerJob.defaultPage();
Paper paper = format.getPaper();
paper.setImageableArea(0,0, format.getWidth(), format.getHeight());
format.setPaper(paper);
printerJob.setPrintable(document, format);
if (printerJob.printDialog()){
try {
printerJob.print();
} catch (PrinterException ex) {
ex.printStackTrace();
}
}
document.close();