简体   繁体   English

从URL Java打印pdf

[英]Print pdf from url java

I have to print a pdf from a URL. 我必须从URL打印pdf。 I had read a lot of websites but, I have not found a solution. 我读过很多网站,但没有找到解决方案。 I´m using JAVA 7 for my project. 我正在为项目使用JAVA 7。 Could somebody help me with this problem? 有人可以帮我解决这个问题吗? (example, website, manual, code) (例如,网站,手册,代码)

Thank you in advance. 先感谢您。

You need a servlet - HTTP listener - that's listening for HTTP GET/POST requests to that URL. 您需要一个Servlet-HTTP侦听器-侦听对该URL的HTTP GET / POST请求。

The servlet will need to generate the PDF and write the bytes to the output stream. servlet将需要生成PDF并将字节写入输出流。

You have at least two choices for generating the PDF: XSL-FO, which is a good choice if the data is XML, or iText, a Java library that creates a PDF in code. 生成PDF至少有两个选择:XSL-FO,如果数据是XML,则是一个很好的选择,或者iText是一个以代码创建PDF的Java库,这是一个不错的选择。

If the file already exists on the file system you just need to read the bytes and stream them to the output stream. 如果文件已存在于文件系统上,则只需要读取字节并将其流式传输到输出流即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM