I am attempting to print Word documents generated using docx4j that I convert to PDF and print using PDFBox. The document I'm attempting to print just contains a simple table with basic English text.
This is the method I use:
private void printDocument(){
PrinterJob job = PrinterJob.getPrinterJob();
try {
PDDocument document;
document = PDDocument.load("files\\textDocs\\OITScanSheet.pdf");
job.setPageable(new PDPageable(document, job));
job.setJobName("OIT Scan Sheet");
job.print();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PrinterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
This is what I'm trying to print: Before print
And this is what comes out when I print (Sorry for the terrible quality): After print
The table is intact with the correct number of rows, but the text is not there. When I print the document from Adobe Reader it prints as it should.
I'm using PDFBox 2.0.0-snapshot right now. I switched from version 1.8.4 because I was running into this problem, where it was printing the table correctly but all of the text was junk.
I'm fairly certain the problem has something to do with some sort of font problem behind the scenes, but I have no idea how to go about fixing it. Any help would be greatly appreciated.