org.pdfbox.pdmodel.fdf

Class FDFDocument


public class FDFDocument
extends java.lang.Object

This is the in-memory representation of the FDF document. You need to call close() on this object when you are done using it!!
Version:
$Revision: 1.6 $
Author:
Ben Litchfield

Constructor Summary

FDFDocument()
Constructor, creates a new FDF document.
FDFDocument(Document doc)
This will create an FDF document from an XFDF XML document.
FDFDocument(COSDocument doc)
Constructor that uses an existing document.

Method Summary

void
close()
This will close the underlying COSDocument object.
FDFCatalog
getCatalog()
This will get the FDF Catalog.
COSDocument
getDocument()
This will get the low level document.
static FDFDocument
load(File file)
This will load a document from a file.
static FDFDocument
load(InputStream input)
This will load a document from an input stream.
static FDFDocument
load(String filename)
This will load a document from a file.
static FDFDocument
loadXFDF(File file)
This will load a document from a file.
static FDFDocument
loadXFDF(InputStream input)
This will load a document from an input stream.
static FDFDocument
loadXFDF(String filename)
This will load a document from a file.
void
save(File fileName)
This will save this document to the filesystem.
void
save(OutputStream output)
This will save the document to an output stream.
void
save(String fileName)
This will save this document to the filesystem.
void
saveXFDF(File fileName)
This will save this document to the filesystem.
void
saveXFDF(String fileName)
This will save this document to the filesystem.
void
saveXFDF(Writer output)
This will save the document to an output stream and close the stream.
void
setCatalog(FDFCatalog cat)
This will set the FDF catalog for this FDF document.
void
writeXML(Writer output)
This will write this element as an XML document.

Constructor Details

FDFDocument

public FDFDocument()
            throws IOException
Constructor, creates a new FDF document.

FDFDocument

public FDFDocument(Document doc)
            throws IOException
This will create an FDF document from an XFDF XML document.
Parameters:
doc - The XML document that contains the XFDF data.

FDFDocument

public FDFDocument(COSDocument doc)
Constructor that uses an existing document. The COSDocument that is passed in must be valid.
Parameters:
doc - The COSDocument that this document wraps.

Method Details

close

public void close()
            throws IOException
This will close the underlying COSDocument object.

getCatalog

public FDFCatalog getCatalog()
This will get the FDF Catalog. This is guaranteed to not return null.
Returns:
The documents /Root dictionary

getDocument

public COSDocument getDocument()
This will get the low level document.
Returns:
The document that this layer sits on top of.

load

public static FDFDocument load(File file)
            throws IOException
This will load a document from a file.
Parameters:
file - The name of the file to load.
Returns:
The document that was loaded.

load

public static FDFDocument load(InputStream input)
            throws IOException
This will load a document from an input stream.
Parameters:
input - The stream that contains the document.
Returns:
The document that was loaded.

load

public static FDFDocument load(String filename)
            throws IOException
This will load a document from a file.
Parameters:
filename - The name of the file to load.
Returns:
The document that was loaded.

loadXFDF

public static FDFDocument loadXFDF(File file)
            throws IOException
This will load a document from a file.
Parameters:
file - The name of the file to load.
Returns:
The document that was loaded.

loadXFDF

public static FDFDocument loadXFDF(InputStream input)
            throws IOException
This will load a document from an input stream.
Parameters:
input - The stream that contains the document.
Returns:
The document that was loaded.

loadXFDF

public static FDFDocument loadXFDF(String filename)
            throws IOException
This will load a document from a file.
Parameters:
filename - The name of the file to load.
Returns:
The document that was loaded.

save

public void save(File fileName)
            throws IOException,
                   COSVisitorException
This will save this document to the filesystem.
Parameters:
fileName - The file to save as.
Throws:
COSVisitorException - If an error occurs while generating the data.

save

public void save(OutputStream output)
            throws IOException,
                   COSVisitorException
This will save the document to an output stream.
Parameters:
output - The stream to write to.
Throws:
COSVisitorException - If an error occurs while generating the data.

save

public void save(String fileName)
            throws IOException,
                   COSVisitorException
This will save this document to the filesystem.
Parameters:
fileName - The file to save as.
Throws:
COSVisitorException - If an error occurs while generating the data.

saveXFDF

public void saveXFDF(File fileName)
            throws IOException,
                   COSVisitorException
This will save this document to the filesystem.
Parameters:
fileName - The file to save as.
Throws:
COSVisitorException - If an error occurs while generating the data.

saveXFDF

public void saveXFDF(String fileName)
            throws IOException,
                   COSVisitorException
This will save this document to the filesystem.
Parameters:
fileName - The file to save as.
Throws:
COSVisitorException - If an error occurs while generating the data.

saveXFDF

public void saveXFDF(Writer output)
            throws IOException,
                   COSVisitorException
This will save the document to an output stream and close the stream.
Parameters:
output - The stream to write to.
Throws:
COSVisitorException - If an error occurs while generating the data.

setCatalog

public void setCatalog(FDFCatalog cat)
This will set the FDF catalog for this FDF document.
Parameters:
cat - The FDF catalog.

writeXML

public void writeXML(Writer output)
            throws IOException
This will write this element as an XML document.
Parameters:
output - The stream to write the xml to.