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.

understack
  • 11,212
  • 24
  • 77
  • 100
  • If you are on shared hosting that doesn't run Java, I don't think this can be done at all. – Pekka Dec 08 '10 at 17:59
  • 1
    If java is not installed, there is not much you can do. Your best bet is probably a PHP based PDF library, see here: http://php.net/manual/en/faq.using.php#faq.using.freepdf – Max Dec 08 '10 at 18:46
  • 2
    Hey, if you're generating PDFs, I can fairly strongly recommend [wkhtmltopdf](http://code.google.com/p/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](http://pdfmyurl.com/) uses, so you can try that out if you want to test your results. – davidtbernal Dec 08 '10 at 18:52
  • A related question http://stackoverflow.com/questions/1648715/best-pdf-generator-in-php-mpdf-or-fpdf – Jaydee Jun 09 '14 at 14:30

4 Answers4

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)

Michael M
  • 8,185
  • 2
  • 35
  • 51
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.

Mark Storer
  • 15,672
  • 3
  • 42
  • 80
  • 1
    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. – Max Dec 08 '10 at 18:43
  • 2002? Eek! Well I doubt it's _harder_ to connect the two now. – Mark Storer Dec 08 '10 at 18:54
  • Just checked, C# is not an option either. I guess, I've to look for other libraries. – understack Dec 08 '10 at 19:03
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!!

jsraymond
  • 1
  • 1
-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.

bmb
  • 6,058
  • 2
  • 37
  • 58