How to print documents using Java?

泪湿孤枕 提交于 2019-12-24 17:26:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!