This is the in-memory representation of the FDF document. You need to call
close() on this object when you are done using it!!
Method from org.apache.pdfbox.pdmodel.fdf.FDFDocument Detail: |
public void close() throws IOException {
document.close();
}
This will close the underlying COSDocument object. |
public FDFCatalog getCatalog() {
FDFCatalog retval = null;
COSDictionary trailer = document.getTrailer();
COSDictionary root = (COSDictionary)trailer.getDictionaryObject( COSName.ROOT );
if( root == null )
{
retval = new FDFCatalog();
setCatalog( retval );
}
else
{
retval = new FDFCatalog( root );
}
return retval;
}
This will get the FDF Catalog. This is guaranteed to not return null. |
public COSDocument getDocument() {
return document;
}
This will get the low level document. |
public static FDFDocument load(String filename) throws IOException {
return load( new BufferedInputStream( new FileInputStream( filename ) ) );
}
This will load a document from a file. |
public static FDFDocument load(File file) throws IOException {
return load( new BufferedInputStream( new FileInputStream( file ) ) );
}
This will load a document from a file. |
public static FDFDocument load(InputStream input) throws IOException {
PDFParser parser = new PDFParser( input );
parser.parse();
return parser.getFDFDocument();
}
This will load a document from an input stream. |
public static FDFDocument loadXFDF(String filename) throws IOException {
return loadXFDF( new BufferedInputStream( new FileInputStream( filename ) ) );
}
This will load a document from a file. |
public static FDFDocument loadXFDF(File file) throws IOException {
return loadXFDF( new BufferedInputStream( new FileInputStream( file ) ) );
}
This will load a document from a file. |
public static FDFDocument loadXFDF(InputStream input) throws IOException {
Document doc = XMLUtil.parse( input );
return new FDFDocument( doc );
}
This will load a document from an input stream. |
public void save(File fileName) throws IOException, COSVisitorException {
save( new FileOutputStream( fileName ) );
}
This will save this document to the filesystem. |
public void save(String fileName) throws IOException, COSVisitorException {
save( new FileOutputStream( fileName ) );
}
This will save this document to the filesystem. |
public void save(OutputStream output) throws IOException, COSVisitorException {
COSWriter writer = null;
try
{
writer = new COSWriter( output );
writer.write( document );
writer.close();
}
finally
{
if( writer != null )
{
writer.close();
}
}
}
This will save the document to an output stream. |
public void saveXFDF(File fileName) throws IOException, COSVisitorException {
saveXFDF( new BufferedWriter( new FileWriter( fileName ) ) );
}
This will save this document to the filesystem. |
public void saveXFDF(String fileName) throws IOException, COSVisitorException {
saveXFDF( new BufferedWriter( new FileWriter( fileName ) ) );
}
This will save this document to the filesystem. |
public void saveXFDF(Writer output) throws IOException, COSVisitorException {
try
{
writeXML( output );
}
finally
{
if( output != null )
{
output.close();
}
}
}
This will save the document to an output stream and close the stream. |
public void setCatalog(FDFCatalog cat) {
COSDictionary trailer = document.getTrailer();
trailer.setItem( COSName.ROOT, cat );
}
This will set the FDF catalog for this FDF document. |
public void writeXML(Writer output) throws IOException {
output.write( "< ?xml version=\"1.0\" encoding=\"UTF-8\"? >\n" );
output.write( "< xfdf xmlns=\"http://ns.adobe.com/xfdf/\" xml:space=\"preserve\" >\n" );
getCatalog().writeXML( output );
output.write( "< /xfdf >\n" );
}
This will write this element as an XML document. |