6

I use the PDFBox 1.8.3 jar to print a PDF file in printer(HW). I printed the PDF file in both ways normal and program. When I print the PDF using normal way, I got the original pdf file as a printed document. But when I use my code I'm unable to get the original pdf file as the printed output. I can see a couple of changes in the printed file; for example alignments, font and ink are different from the original document.

ReadPDF readPDF = new ReadPDF();
PDDocument document = readPDF.loadPdf(path);
document.addPage(new PDPage());
printerJob.setPageable(document);
printRequestAttributeSet.add(new PageRanges(1,3));
printerJob.print(printRequestAttributeSet);

Also I try to uppgrade the PDFBox jar 1.8.3 to upcoming jar 2.0.0. I faced a few difficulties (for example: in PDFBox 2.0.0 I'm unable to use the printerJob.setPageable(document);). Could you please help me to solve this issue.

Jeroen Vannevel
  • 43,651
  • 22
  • 107
  • 170
stacktome
  • 790
  • 2
  • 9
  • 32
  • Is this issue with a particular pdf file or have you tested it with different pdf's ? If possible, can you post a link to a sample pdf which is NOT printing as you expect it to? – chronodekar Dec 17 '13 at 08:13
  • All the PDF files and specially 2.0.0 – stacktome Dec 17 '13 at 11:05
  • 1
    Do you preview and print the file from the same computer? If the fonts aren't embedded in the PDF file and aren't installed on your computer, you will get some changes in the rendering. – ssssteffff Dec 17 '13 at 22:42
  • Please do illustrate a sample of such a change with a PDF file. Otherwise your issue is too undefined for any help. That been said, in the course of answering [here](http://stackoverflow.com/a/21573253/1729265) I also applied PDFBox' page rendering to the differently styled text and was surprised to see that the artificially styled texts were drawn as plain text, i.e. without the desired effects. – mkl Feb 11 '14 at 22:27

2 Answers2

0

This is sometimes related with printer also. Please try out in a different printer, just to check.

tesnik03
  • 1,324
  • 2
  • 13
  • 23
0

You can have a look at the answer of below question on StackOverflow and can make use of extracts from the explaination.

How to determine artificial bold style ,artificial italic style and artificial outline style of a text using PDFBOX

Also, verify if the fonts which are supplied to the original PDF are also present in the container in which the application is running.

Shishir

Community
  • 1
  • 1
Shishir Kumar
  • 7,981
  • 3
  • 29
  • 45