Package com.tom_roush.pdfbox.pdmodel.fdf
Class FDFDocument
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.fdf.FDFDocument
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class FDFDocument extends Object implements Closeable
This is the in-memory representation of the FDF document. You need to call close() on this object when you are done using it!!
-
-
Constructor Summary
Constructors Constructor Description FDFDocument()Constructor, creates a new FDF document.FDFDocument(COSDocument doc)Constructor that uses an existing document.FDFDocument(Document doc)This will create an FDF document from an XFDF XML document.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This will close the underlying COSDocument object.FDFCataloggetCatalog()This will get the FDF Catalog.COSDocumentgetDocument()This will get the low level document.static FDFDocumentload(File file)This will load a document from a file.static FDFDocumentload(InputStream input)This will load a document from an input stream.static FDFDocumentload(String filename)This will load a document from a file.static FDFDocumentloadXFDF(File file)This will load a document from a file.static FDFDocumentloadXFDF(InputStream input)This will load a document from an input stream.static FDFDocumentloadXFDF(String filename)This will load a document from a file.voidsave(File fileName)This will save this document to the filesystem.voidsave(OutputStream output)This will save the document to an output stream.voidsave(String fileName)This will save this document to the filesystem.voidsaveXFDF(File fileName)This will save this document to the filesystem.voidsaveXFDF(Writer output)This will save the document to an output stream and close the stream.voidsaveXFDF(String fileName)This will save this document to the filesystem.voidsetCatalog(FDFCatalog cat)This will set the FDF catalog for this FDF document.voidwriteXML(Writer output)This will write this element as an XML document.
-
-
-
Constructor Detail
-
FDFDocument
public FDFDocument()
Constructor, creates a new FDF document.
-
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.
-
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.- Throws:
IOException- If there is an error reading from the dom.
-
-
Method Detail
-
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.- Throws:
IOException- If there is an error writing the XML.
-
getDocument
public COSDocument getDocument()
This will get the low level document.- Returns:
- The document that this layer sits on top of.
-
getCatalog
public FDFCatalog getCatalog()
This will get the FDF Catalog. This is guaranteed to not return null.- Returns:
- The documents /Root dictionary
-
setCatalog
public void setCatalog(FDFCatalog cat)
This will set the FDF catalog for this FDF document.- Parameters:
cat- The FDF catalog.
-
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.
- Throws:
IOException- If there is an error reading from the stream.
-
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.
- Throws:
IOException- If there is an error reading from the stream.
-
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.
- Throws:
IOException- If there is an error reading from the stream.
-
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.
- Throws:
IOException- If there is an error reading from the stream.
-
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.
- Throws:
IOException- If there is an error reading from the stream.
-
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.
- Throws:
IOException- If there is an error reading from the stream.
-
save
public void save(File fileName) throws IOException
This will save this document to the filesystem.- Parameters:
fileName- The file to save as.- Throws:
IOException- If there is an error saving the document.
-
save
public void save(String fileName) throws IOException
This will save this document to the filesystem.- Parameters:
fileName- The file to save as.- Throws:
IOException- If there is an error saving the document.
-
save
public void save(OutputStream output) throws IOException
This will save the document to an output stream.- Parameters:
output- The stream to write to.- Throws:
IOException- If there is an error writing the document.
-
saveXFDF
public void saveXFDF(File fileName) throws IOException
This will save this document to the filesystem.- Parameters:
fileName- The file to save as.- Throws:
IOException- If there is an error saving the document.
-
saveXFDF
public void saveXFDF(String fileName) throws IOException
This will save this document to the filesystem.- Parameters:
fileName- The file to save as.- Throws:
IOException- If there is an error saving the document.
-
saveXFDF
public void saveXFDF(Writer output) throws IOException
This will save the document to an output stream and close the stream.- Parameters:
output- The stream to write to.- Throws:
IOException- If there is an error writing the document.
-
close
public void close() throws IOExceptionThis will close the underlying COSDocument object.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- If there is an error releasing resources.
-
-