0

I am using iText java lib with php script to fill-out pdf etc...

It worked perfectly on my computer, but when it went live on the server, it started acting up. For example the load time of pdf is totally unpredictable. Sometimes it would be almost instantaneous, like on my machine, and sometimes it would take up to 20 seconds.

I suspect it has something to do with JVM constantly loading up on every request. It it possible to somehow optimize for this situation?

The way I invoke it is simply:

exec('java -classpath ".;itextpdf-5.1.1.jar" StreamPdf blah.pdf blah.fdf target.pdf');
1
  • 1
    Long-running JVM process in the background rather than spawning a JVM-per-request? I'm just guessing... You may want to include some details as to how you are invoking Java from PHP. Commented Nov 22, 2011 at 2:26

1 Answer 1

3

best bet... see if there is an interface or wrapper for this that you can use with an app server, such as apache tomcat or others.

looks like a tutorial already exists for this here http://www.geek-tutorials.com/java/itext/servlet_jsp_output_pdf.php

This will allow you to keep one instance of the app constantly running, avoiding the overhead of re-instantiating the jar every time.

You would need to then issue http requests in php to the running instance via curl etc...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.