de.frame4j
Class PDFcompose

java.lang.Object
  extended by de.frame4j.util.App
      extended by de.frame4j.PDFcompose
All Implemented Interfaces:
AttrSettable, TextHelper.MessageComponents, UIInfo, ActionListener, EventListener, DynamicMBean

@MinDoc(copyright="Copyright 2008 , 2009  A. Weinert",
        author="Albrecht Weinert",
        version="V.21",
        lastModified="12.02.2010",
        lastModifiedBy="A. Weinert",
        usage="start as Java application (-? for help)\njava de.frame4j.PDFcompose [options] xmlFile\nsee de.frame4j.PDFcompose javaDoc for xml control file syntax",
        purpose="compose a PDF from other PDF\'s parts")
public class PDFcompose
extends App

Compose a PDF file from parts.

This application generates a PDF output file fom parts (pages) of one or more other PDF input files.

The composition is controlled completely by a XML file given as start parameter. The XML syntax / format is self explaining by the following example:

    <?xml version="1.0" encoding="ISO-8859-1"?>
  
    <!-- see de.frame4j.PDFcompose
         http://www.a-weinert.de/java/ -->
  
    <compose type="pdf" filename="outfile.pdf">
      <!-- type at present pdf only; filename will be overwritten
              Text content: descriptive not for the pdf output -->
      set of transparencies about having guinea pigs composed of (parts  
      of)    animal species,   open-air enclosure and feeding
   
      <in filename="species.pdf">
        description of guinea pigs;  pages: 1, 3, 8..10, 22..24
         <page nr="1" />
         <page nr="3" />
         <!-- default end = nr , count = 1 -->
         <page nr="8"  end="10" />
         <page nr="22" count="3" />
      </in>
   
      <in filename=" open-air.pdf">
        open air cage for guinea pigs; pages: 7..11
         <page nr="7" count="5" />
      </in>
   
      <in filename="feeding.pdf">
        feeding guinea pigs; pages:  7, 9, 2
         <page nr="7" />
         <page nr="9" />
         <page nr="2" />
      </in>
    </compose>
  
The first page (i.e. page 1, not the first used / transfered page) of the first <in />-file determines the page format of the output PDF file. Eventually use a first dummy <in />-file without using any of its <page />s.

A page range specified by nr..end or by & count, may be given and then processed also in reverse order.
The keyword "last" (instead of a number denotes the highest page number of the related input file.


Copyright 2008   Albrecht Weinert

See Also:
TextHelper, SAXHandler

Field Summary
 
Fields inherited from class de.frame4j.util.App
ano, appBase, appIO, appStartTime, args, bgColor, err, fullClassName, help, icon, INIT_ERROR, jmxRemoteNote, JOB_DONE_OK, log, LOG_OUT_ERROR, MAIN_THREAD_EXC, mainThread, myClass, myFrame, name, NO_PARS_ERROR, objectName, out, outMode, packName, prop, retCode, runFlag, shortClassName, title, verbose, verbosity
 
Fields inherited from interface de.frame4j.net.AttrSettable
ILLEGAL_TYPE, ILLEGAL_VALUE, NO_ATTRIBUTE, NO_KNOWN_ATTRIBUTE, NO_VALUE, OK
 
Constructor Summary
PDFcompose()
           
 
Method Summary
protected  boolean allowNoPropertiesFile()
          Decide, if the basic .properties file may be omitted.
 int doIt()
          Working method of the application PDFcompose.
static void main(String[] args)
          Start method of PDFcomposer.
static void makePDFcomposite(String xmlInp, String pdfOut, PrintWriter log, boolean verbose)
          Make a PDF file / compositum according to XML description.
 
Methods inherited from class de.frame4j.util.App
actionPerformed, clientOrder, condHelpLog, connect, errMeld, errMeld, errorExit, errorExit, errorExit, errorText, formMessage, formMessage, getAbout, getAboutText, getActTime, getAppLogger, getAppStartTime, getArgs, getAttribute, getAttributes, getAuthor, getCopyright, getDbLogger, getExecTimeMs, getExecTimeString, getHelp, getHelpText, getIcon, getLanguage, getLogHandler, getMBeanInfo, getMessageComponent, getMessageComponentsLength, getMyFrame, getName, getNameWithVersDate, getOutMode, getProp, getPurpose, getStartTime, getStateString, getTitle, getUsage, getVerbosity, getVerbosityString, getVersDate, getXMLinput, go, go, go, haveIcon, invoke, isDebug, isHelp, isHelpLog, isNormal, isRunFlag, isSilent, isTest, isVerbose, logVerbose, logVerbose, makeDbLogger, makeMenuBar, makeMenuBar, makeStatusTextEnd, makeStatusTextStart, messageFormat, normalExit, parsePartial, performeAction, postDeregister, postRegister, preRegister, queueAction, registerAsMBean, setAboutText, setAttribute, setAttribute, setAttribute, setAttributes, setAuthor, setBgColor, setCodePages, setCopyright, setHelp, setJmxRemoteNote, setLogOut2, setName, setOutMode, setOutMode, setPurpose, setTitle, setUsage, setVerbose, setVerbose, setVerbosity, setVerbosity, setVerbosityString, setVersDate, stop, threeLineEndMsg, toString, twoLineEndMsg, twoLineStartMsg, valueLang, valueLang, wakeMainThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PDFcompose

public PDFcompose()
Method Detail

allowNoPropertiesFile

protected boolean allowNoPropertiesFile()
Description copied from class: App
Decide, if the basic .properties file may be omitted.

Starting an application inheriting from App with a go method constructs the App's Prop object. In this process .properties files of appropriate name (appName.properties) are searched as file or as resource (in the .jar).

It is a basic (compile time) property of the application class, if or if not one such .properties file must be found. If true and no such file (or resource) can be found and read, this would be an initialisation error, detaining the application from being started.

At all places (in this class) the decision if no such file found is an initialisation error, is done by calling this method. It can (or must) be overridden in extending classes accordingly.

This implementation returns The tart up procedure (usually by one of the methods go()) constructs a Prop object for the application using a constructor like Prop.Prop(App, CharSequence). Hereby a basic property file named App.shortClassName.properties is searched for as file or resource at different places. Finding it nowhere gets a FileNotFoundException going up to the starter method. The reason for that stringency is, that App-Extensions and their .properties file are considered as a unit. If not this is considered as the special case "allowNoPropertiesFile".

Without that file one only has the common default properties for all Apps (seeProp.Prop()).

Hint: If there is a inheritance hierarchy of App only the last ones base .properties file is searched for.


Overrides:
allowNoPropertiesFile in class App
Returns:
false: normal App class, true: inner class

main

public static void main(String[] args)
Start method of PDFcomposer.

Execute by: java de.frame4j.PDFcompose [options] xmlFile

Parameters:
args - command line parameter
See Also:
doIt(), App.go(String[], boolean)

makePDFcomposite

public static void makePDFcomposite(String xmlInp,
                                    String pdfOut,
                                    PrintWriter log,
                                    boolean verbose)
                             throws SAXNotRecognizedException,
                                    SAXNotSupportedException,
                                    ParserConfigurationException,
                                    SAXException,
                                    IOException
Make a PDF file / compositum according to XML description.

This method is the "factory" for a PDFcompose object according to a XML description.
See class documentation.

This method is, of course, used by this class PDFcompose if executed as application / programme. It will be the central working method for other uses.

Parameters:
xmlInp - file name of the XML description
pdfOut - file name of the PDF output (overrides a denotation in the XML if given)
log - log output
verbose - log extensively
Throws:
SAXException
ParserConfigurationException
SAXNotSupportedException
SAXNotRecognizedException
IOException

doIt

public int doIt()
Working method of the application PDFcompose.

Specified by:
doIt in class App
See Also:
makePDFcomposite(String, String, PrintWriter, boolean), App