For this tutorial I will use a debian 5 Lenny setup. But you can use the configuration hints for anything else be it Windows, Mac OS X, Redhat Linux, Suse Linux or whatever runs Java, Apache2, Tomcat 6 and PHP.

# Modified for tomcat6 16.02.2009 - ohaeuser
# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat6.
#TOMCAT6_USER=tomcat6
# The home directory of the Java development kit (JDK). You need at least
# JDK version 1.4. If JAVA_HOME is not set, some common directories for
# the Sun JDK, various J2SE 1.4 versions, and the free runtimes
# java-gcj-compat-dev and kaffe are tried.
JAVA_HOME=/usr/lib/jvm/java-6-sun
# Directory for per-instance configuration files and webapps. It contain the
# directories conf, logs, webapps, work and temp. See RUNNING.txt for details.
# Default: /var/lib/tomcat5.5
CATALINA_BASE=/opt/tomcat6
# Arguments to pass to the Java virtual machine (JVM).
#JAVA_OPTS="-Djava.awt.headless=true -Xmx128M"
JAVA_OPTS="-Djava.awt.headless=true -Xms256m -Xmx512m -XX:MaxPermSize=256m -Dlog.home=$CATALINA_BASE -Dsolr.solr.home=/home/solr -Dcom.idmllib.license=ILJD10-xxxx-xxxx-xxxx-xxxx"
# Java compiler to use for translating JavaServer Pages (JSPs). You can use all
# compilers that are accepted by Ant's build.compiler property.
#JSP_COMPILER=jikes
# Use the Java security manager? (yes/no, default: yes)
# WARNING: Do not disable the security manager unless you understand
# the consequences!
# NOTE: java-gcj-compat-dev currently doesn't support a security
# manager.
TOMCAT6_SECURITY=no
#Export for AWT
#export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64/

Something that is missing here: The Init Script looks under tomcat/conf/policy.d for missing Policy files. Either uncomment the line who tries to load the policies. Or add the files. A simple way is too install a debian tomcat like tomcat5.5 and just use the policy.d folder for a good start for your own stuff!

Unzip this and cop the JavaBridge.war file to our Tomcat webapps. There is a README in it that mentions alternative ways. I have not tried this so you are on your own there.
But it is working with a Tomcat 6 and Java 6 great.

Now you download your own template war which you will rename and where you put the IDMlib.jar into it.

Attention: For some reason I could not get this to run when I used the normal filename with the version in it … idmllib-1.1.0.jar.
Don’t ask me why … works if you rename it to idmllib.jar.

6 Configure Apache and php

Set URL_FOPEN to on stellen.

;Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
allow_url_include = On

You can protect your setup with suhosin – so URL_FOPEN is restricted to a specific address:

7 Test the IDMLlib

If you did everything correct start InDesign, use any InDesign file and export it to an IDML file.
You need of course at least one Textbox with content in the InDesign file.
Upload the file to your web folder and access the file with a small php script:

Note: You must provide a path for the IDML file. And we did not query all the stories. We “cheated” a bit here and just provided the correct story ID from the IDML file.
Just unzip the IDML file and look for the Stories folder. There are of course some utility functions in the IDMLlib to get the Story IDs from the spreads and iterate through them.

So be on the lookout for more complex examples using IDMLlib for Java with PHP5!

Next code example shows how to modify story contents and write an IDML file back!

This entry was posted
on Thursday, May 20th, 2010 at 16:46 and is filed under IDMLlib, php5.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.