How to use iText java PDF library with PHP?
Asked Answered
Q

4

3

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.

Q answered 8/12, 2010 at 17:55 Comment(4)
If you are on shared hosting that doesn't run Java, I don't think this can be done at all.Vallery
If java is not installed, there is not much you can do. Your best bet is probably a PHP based PDF library, see here: php.net/manual/en/faq.using.php#faq.using.freepdfPrologue
Hey, if you're generating PDFs, I can fairly strongly recommend wkhtmltopdf which uses the super-awesome webkit rendering engine to render html documents to pdf. It has few external dependencies, so it's pretty easy to get going. It's what pdfmyurl uses, so you can try that out if you want to test your results.Thionic
A related question #1649215Ciera
A
1

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)

Alcoran answered 23/6, 2014 at 6:12 Comment(0)
T
0

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.

Trinitrocresol answered 8/12, 2010 at 18:39 Comment(3)
Just my opinion, but if Java is not allowed, I think its highly unlikely that there is a .NET Framework environment where C# apps run. And the COM interface of PHP is not really something you want to use. By the way, the article is from 2002.Prologue
2002? Eek! Well I doubt it's harder to connect the two now.Trinitrocresol
Just checked, C# is not an option either. I guess, I've to look for other libraries.Q
C
0

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!!

Capua answered 8/6, 2018 at 9:10 Comment(0)
C
-1

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.

Constantia answered 1/6, 2016 at 23:29 Comment(1)
Pdftk is a front end to a very, very, very old version of iText.Forbid

© 2022 - 2024 — McMap. All rights reserved.