Total members 11894 |It is currently Thu Nov 21, 2024 5:35 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





I spent most of the day yesterday trying to print a PDF file from a
Java application. I finally succeeded, but the solution may not work. So
here I am.

The requirements are that it cannot have user interaction. The target
systems are locked down terminals that are imaged and set up in
warehouse with specific settings, so I can reasonably assume that
default printer settings will work. Preferably, the solution would
require neither spending money (like most companies it is bad enough
ordering office supplies let alone software licenses) nor using GPL
software (BSD/Apache are fine though). Ideally this would be a pure Java
solution that is cross platform, unlike the current solution of shell
scripts that break in Windows and half the Linux distributions.

I found PDFBox - http://www.pdfbox.org/ - but I cannot get it to work no
matter how hard I try. Usually I get an exception while printing stating
"operation not implemented" even on simple PDFs. Sometimes PDFs print,
Windows says it sent a job to the printer, but the job has "N/A" pages
and nothing prints.

Next I tried setting up command line utilities and scripts against my
better judgment to convert PDF files on the fly (or preconvert them,
doesn't matter) and send PostScript files directly to the printer.
According to Java, there are no printers attached to my computer (there
are four network printers) that support either PDF or PostScript
flavors. If I send the job anyway (it is a high end Ricoh color laser
printer that supports PDF and PostScript natively according to Ricoh's
web site) then Java throws an exception about an invalid flavor. Oddly
enough, the scripting side of the equation works. I can use "pdftops
input.pdf -" and pipe its STDOUT into an InputStream in my application
and then (try to) send it off to the printer.

Finally I downloaded a trial of jPDFPrint -
http://www.qoppa.com/jprindex.html - and this works, but costs money,
and like I said my company is cheap. It does pop up a print options
dialog but I am sure I can get rid of it, but 6:00 PM on a Friday is
time to declare victory and go home for the weekend.

I will admit that printing is one part of software development I do not
have much experience with. Is there anything I am missing here, any
libraries that are known to work? Does anyone have any recommendations?



_________________
Please recommend my post if you found it helpful


Author:
Proficient
User avatar Posts: 228
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Printing PDFs in Java
 Function printing text on a Web Page     -  
 Printing today+ current date with different format     -  
 avoid showing/printing figures, text after conclusion     -  
 2d game in java-Monster-Java 2D Game Graphics and Animation     -  
 Using FTP in java     -  
 what is java     -  
 Java course     -  
 need help in java     -  
 What is Java API?!!!     -  
 java or .net     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com