Hello,
it seems a rather sparse question, but I've found several occurences of
the same problem, only not directly bound to PDFBox as it is mainly a
Java Printing framework problem, but I'm looking for a workaround.
I'm generating documents using Freemarker templates + FlyingSaucer
library (template -> HTML -> PDF). That part works well, producing
desired documents with any requested custom "paper" formats.
Adobe AcrobatReader displays them correctly and it is even capable of
printing them to a label printer via Windows print drivers (Zebra
thermal printer, a Chineese 4Barcode thermal printer or any standard
Windows printer).
I'm using PDFBox (currently 3.0.2, but it is probably a problem since
dark ages) to get PDFPageable to be printed on a HW printer (or a
Windows virtual printer or whatever else, it really doesn't matter).
And there comes the problem with Java printing framework - it doesn't
accept MediaSize with width > height. I'm not talking about printing
"landscape" as on most printers (taking the paper with the narrower edge
first and rotating the image). I'm printing on labels on a long roll, so
I can't feed them rotated. Everything works perfectly with "portrait"
format media (e.g. 10x15cm labels), but when it comes to "landscape" fed
media (40x10mm, 50x20mm...), I'm out of luck as Java framework "fixes"
page format to nearest "portrait" oriented format with borders, silently
ignoring the exception thrown in the MediaSize print attribute
constructor (complaining about the W>H). The same happens when using the
PDFBox-app.jar with print command (I'm printing almost the same way as
the PDFBox-app does, only loading the generated PDF directly via a
memory buffer).
I know that it is a Java framework limitation, question is if there is a
known workaround for that. I can't make the media "higher" as it wastes
labels (and in case of e.g. RFID tag labels it gets very expensive).
Attached is a test "label.pdf" PDF (40x10mm) that prints badly from Java
(even on "PrintToPDF" printer or any standard printer, no need for a
label printer to test) - shifted down and left by a default A10 paper
border. "label_result.pdf" is an attempt to print similar label (40x20)
to a windows "Print to PDF" printer. Printing the same PDF from
AcrobatReader works perfectly, even directly to the label printer.
Thanks, Jakub
Jakub Jelínek
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]