Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.pdfbox.examples.persistence
Class AppendAndFillDoc

    java.lang.Object
      org.pdfbox.examples.persistence.AppendAndFillDoc

public class AppendAndFillDoc
extends Object

This concatenates two documents with fields and fills the fields in the two templates using different values.

Version:
  $Revision: 1.6 $
Author:
  Michael Traut

Constructor Summary
`AppendAndFillDoc()` Constructor.

Method Summary
`void` | `appendDocument(COSDocument destination, COSDocument source)` Append all pages from source to destination.
`void` | `appendPage(COSDocument destination, COSDictionary page)` append a page dict to destination.
`void` | `doIt(String in1, String in2, String out, String name1, String value1, String name2, String value2)` concat two pdf documents and fill fields in both templates this is a bit tricky as one has to rename the fields if we use the same template two times.
`COSDictionary` | `getPages(COSDocument doc)` Lookup the pages dictionary in a document.
`static void` | `main(String[] args)` This will concat two pdf documents and fill fields in both.
`void` | `setField(COSDocument doc, String prefix, COSString name, COSString value)` lookup and fill the field.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AppendAndFillDoc

    public AppendAndFillDoc()

  Constructor.

Method Detail

### appendDocument

    public void appendDocument(COSDocument destination,
                               COSDocument source)

  Append all pages from source to destination. todo: this method will go to the pdfmodel package one day

  Parameters:
    `destination` - the document to receive the pages
    `source` - the document originating the new pages

### appendPage

    public void appendPage(COSDocument destination,
                           COSDictionary page)

  append a page dict to destination. todo: this method will go to the pdfmodel package one day

  Parameters:
    `destination` - the document to receive the page
    `page` - the page to append to the document

### doIt

    public void doIt(String in1,
                     String in2,
                     String out,
                     String name1,
                     String value1,
                     String name2,
                     String value2)
              throws IOException,
                     COSVisitorException

  concat two pdf documents and fill fields in both templates this is a bit tricky as one has to rename the fields if we use the same template two times. here we don't user a clever algorithm to create dynamic fieldnames - this is left to the user..

  Parameters:
    `in1` - The first template file
    `in2` - The second template file
    `out` - The created fiel with all pages from document one and document two
    `name1` - The name of the PDF field (FDF field) in the first template
    `value1` - The value to be used for the field in the first template
    `name2` - The name of the PDF field (FDF field) in the second template
    `value2` - The value to be used for the field in the second template
  Throws:
    `IOException` - If there is an error writing the data.
    `COSVisitorException` - If there is an error generating the PDF document.

### getPages

    public COSDictionary getPages(COSDocument doc)

  Lookup the pages dictionary in a document. todo: this method will go to the pdfmodel package one day

  Parameters:
    `doc` - the document where the pages dict is searched
  Returns:
    The Pages dictionary.

### main

    public static void main(String[] args)

  This will concat two pdf documents and fill fields in both.
  see usage() for commandline

  Parameters:
    `args` - command line arguments

### setField

    public void setField(COSDocument doc,
                         String prefix,
                         COSString name,
                         COSString value)

  lookup and fill the field. todo: this method will go to the pdfmodel package one day

  Parameters:
    `doc` - the document where the field resides
    `prefix` - a prefix to use to make the field name unique in the new document
    `name` - the name of the PDF Annotation field
    `value` - The desired value to be used for the field

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD