问题
I have a requirement to print data exactly in a particular position in paper. How can these kind of formatting be done using Java?
回答1:
Jasper, iText will work for you.
回答2:
Which kind of data ?
If it's form, the use of reporting library can help you:
- http://jasperforge.org/projects/jasperreports
If it's graphic you can try using 'raw' java api:
- http://download.oracle.com/javase/tutorial/2d/printing/printable.html
回答3:
Or use the Java print API:
http://www.ibm.com/developerworks/java/library/j-mer0322/index.html
http://www.ibm.com/developerworks/java/library/j-mer0424.html
回答4:
If you really need full control, you can print Graphics2D objects directly. See http://java.sun.com/developer/onlineTraining/Programming/JDCBook/render.html and the next page.
Another possibility would be printing PDF, e.g. using iText. I think exact positioning is possible, but probably harder than using Graphics2D.
来源:https://stackoverflow.com/questions/3959064/how-to-print-documents-using-java