How to use iText java PDF library with PHP?

风流意气都作罢 提交于 2019-12-01 06:18:47

问题


Google search results suggested that it's possible via PHP/Java Bridge . This bridge requires Java Application Server. My host (bluehost) does not allow to run any Java Application Server. What are the alternatives in this case to make iText work? Switching a host is not viable option for me.

Thanks.


回答1:


There's always iTextSharp, a C# translation of iText. Will your host let you run C#?

It looks like you can call C# from PHP, as detailed here.




回答2:


I know this is an old post, but for those still looking for an answer, may I suggest having Java do your work for you as a REST service using Jersey (JAX-RS), then just call the service from PHP. You can put your Java service on a host that does allow Java and you can call that service from PHP using cURL (or even file_get_contents if your host allows it and if you know what you're doing).

Loose coupling over RESTful services is allows you to have your Java service and your PHP app on separate hosts. Don't waste you time with a PHP/Java Bridge. It's perfectly sane to call a RESTful service with a Java back-end from PHP. This way, later if you decide, your would rather re-do the service in C# or something else, at least there will be 0 impact on the PHP app because you used a language neutral RESTful approach.

I have not had any performance issues using this approach myself, YMMV

(It's mostly a matter of design: It's usually better to "bolt" things together then "weld" them together.)

Also, Java with JAX-RS is very very simple (IMHO, but again .. YMMV)




回答3:


The ITEXT website specifically says JAVA and .NET, Wish they can also build the PHP or PERL version

I have used the Java Itext, Its superb!!




回答4:


PDFtk is a command line tool installed on many Linux systems. It is a front end to the iText library. It may do what you need. You'd have to shell out to the command line to invoke it from PHP.



来源:https://stackoverflow.com/questions/4390675/how-to-use-itext-java-pdf-library-with-php

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