By Tim Dexter on Apr 16, 2008
Trying to get back on track here ... too many demos to get working for various events. Back to bookbinding - hope fully the introduction I provided gave you an idea of what the bookbinding API is and what it can be used for. Before we get to the nitty gritty its worth knowing ehats going on under the covers.
We have our disperate PDFs to the left coming from various sources - the BookBinding APIs sits amid the Publisher engine. It takes a control file in the form of XML as a set of instructions on how to build the bound document - the control file will reference layout templates that can be overlaid atop the the final combined document.
The control file is the most important piece - there is no builder for this and it can get complicated but if we start with the basics and work our way up to the more complex you'll understand the structure.
For the examples I have taken a bunch of Oracle product 'brochures' that we can then bind. They reside in the 'oracle_books' directory in the zip file available here. Unpack the zip and check out the first example.
Example1 - Simple Merge plus front page
In this example we will merge the three Oracle overview documents and add a front page to the document. So we will have a document structure as follows:
1. Front Page
2. Database Overview
3. Application Server Overview
4. E Business Suite Overview
The XML control file for this is pretty straightforward:
<?xml version="1.0" encoding="utf-8"?>
The 'title-page' element should point to a PDF title page inserted
at the beginning of the book. (OPTIONAL)
<!-- So here is the title page reference, in this case it is going to use an RTF template -->
<!-- nex follow the three documents we want to combine -->
I have provided an html page and annotated control file that hopefully provides you with enough information to work out what is going on. The first example takes a template, title_page.rtf from the templates directory and then prefixes it to the following three pdf documents. Cant get much simpler than this.
To run the example you'll find a cmd file that can be run directly in Windows other OS' you need to set environment variables accordingly . Its a straightforward java call to the command line interface of the bookbinder API.
set JAVA_CMD=%JAVA_HOME% -classpath %CLASSPATH% %JAVA_OPTS% %JAVA_CLASS%
echo %JAVA_CMD% -debug true -tmp ..tmp -xml Example1.xml -pdf Example1.pdf
%JAVA_CMD% -debug true -tmp ..tmp -xml Example1.xml -pdf Example1.pdf
The command line arguments take the form
-debug true|false -tmp <temporary directory location> -xml <control file location> -pdf <output file location>
Give it a try - you might have to do a little jiggery pokery with the cmd file to get it working. Notice I have JAVA_HOME set to pick up the java executable to run the API.
Enough for today, try out the first few examples and we'll pick up some of the more complex examples next time.