How to use iText java PDF library with PHP?

16,808

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)

Share:
16,808
understack
Author by

understack

Updated on June 04, 2022

Comments

  • understack
    understack almost 2 years

    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.