public class XMPUtil
extends java.lang.Object
Constructor and Description |
---|
XMPUtil() |
Modifier and Type | Method and Description |
---|---|
static BibtexEntry |
getBibtexEntryFromDocumentInformation(org.apache.pdfbox.pdmodel.PDDocumentInformation di)
Helper function for retrieving a BibtexEntry from the
PDDocumentInformation in a PDF file.
|
static BibtexEntry |
getBibtexEntryFromDublinCore(org.apache.jempbox.xmp.XMPSchemaDublinCore dcSchema)
Helper function for retrieving a BibtexEntry from the DublinCore metadata
in a PDF file.
|
static boolean |
hasMetadata(java.io.InputStream is)
Will try to read XMP metadata from the given file, returning whether
metadata was found.
|
static void |
main(java.lang.String[] args)
Command-line tool for working with XMP-data.
|
static org.apache.jempbox.xmp.XMPMetadata |
readRawXMP(java.io.File file)
Will read the XMPMetadata from the given pdf file, closing the file
afterwards.
|
static org.apache.jempbox.xmp.XMPMetadata |
readRawXMP(java.io.InputStream inputStream)
Will read the XMPMetadata from the given pdf file, closing the file
afterwards.
|
static java.util.List<BibtexEntry> |
readXMP(java.io.File file)
Try to read the BibTexEntries from the XMP-stream of the given PDF-file.
|
static java.util.List<BibtexEntry> |
readXMP(java.io.InputStream inputStream)
Try to read the given BibTexEntry from the XMP-stream of the given
inputstream containing a PDF-file.
|
static java.util.List<BibtexEntry> |
readXMP(java.lang.String filename)
Convenience method for readXMP(File).
|
static java.lang.String |
toXMP(java.util.Collection<BibtexEntry> bibtexEntries,
BibtexDatabase database)
Convenience method for toXMP(Collection
|
static void |
toXMP(java.util.Collection<BibtexEntry> bibtexEntries,
BibtexDatabase database,
java.io.OutputStream outputStream)
Write the given BibtexEntries as XMP-metadata text to the given stream.
|
protected static void |
usage()
Print usage information for the command line tool xmpUtil.
|
static void |
writeDocumentInformation(org.apache.pdfbox.pdmodel.PDDocument document,
BibtexEntry entry,
BibtexDatabase database)
Try to write the given BibTexEntry in the Document Information (the
properties of the pdf).
|
static void |
writeDublinCore(org.apache.pdfbox.pdmodel.PDDocument document,
BibtexEntry entry,
BibtexDatabase database)
Try to write the given BibTexEntry as a DublinCore XMP Schema
Existing DublinCore schemas in the document are not modified.
|
static void |
writeDublinCore(org.apache.pdfbox.pdmodel.PDDocument document,
java.util.Collection<BibtexEntry> entries,
BibtexDatabase database)
Try to write the given BibTexEntries as DublinCore XMP Schemas
Existing DublinCore schemas in the document are removed
|
static void |
writeXMP(java.io.File file,
BibtexEntry entry,
BibtexDatabase database)
Try to write the given BibTexEntry in the XMP-stream of the given
PDF-file.
|
static void |
writeXMP(java.io.File file,
java.util.Collection<BibtexEntry> bibtexEntries,
BibtexDatabase databasee,
boolean writePDFInfo)
Try to write the given BibTexEntry in the XMP-stream of the given
PDF-file.
|
static void |
writeXMP(java.lang.String filename,
BibtexEntry entry,
BibtexDatabase database)
Try to write the given BibTexEntry in the XMP-stream of the given
PDF-file.
|
public static java.util.List<BibtexEntry> readXMP(java.lang.String filename) throws java.io.IOException
filename
- The filename from which to open the file.java.io.IOException
public static void writeXMP(java.lang.String filename, BibtexEntry entry, BibtexDatabase database) throws java.io.IOException, javax.xml.transform.TransformerException
filename
- The filename from which to open the file.entry
- The entry to write.database
- maybenull An optional database which the given bibtex entries
belong to, which will be used to resolve strings. If the
database is null the strings will not be resolved.javax.xml.transform.TransformerException
- If the entry was malformed or unsupported.java.io.IOException
- If the file could not be written to or could not be found.public static java.util.List<BibtexEntry> readXMP(java.io.File file) throws java.io.IOException
file
- The file to read from.java.io.IOException
- Throws an IOException if the file cannot be read, so the user
than remove a lock or cancel the operation.public static java.util.List<BibtexEntry> readXMP(java.io.InputStream inputStream) throws java.io.IOException
file
- The inputstream to read from.java.io.IOException
- Throws an IOException if the file cannot be read, so the user
than remove a lock or cancel the operation.public static BibtexEntry getBibtexEntryFromDocumentInformation(org.apache.pdfbox.pdmodel.PDDocumentInformation di)
di
- The document information from which to build a BibtexEntry.public static BibtexEntry getBibtexEntryFromDublinCore(org.apache.jempbox.xmp.XMPSchemaDublinCore dcSchema)
di
- The document information from which to build a BibtexEntry.public static void writeXMP(java.io.File file, BibtexEntry entry, BibtexDatabase database) throws java.io.IOException, javax.xml.transform.TransformerException
file
- The file to write to.entry
- The entry to write.database
- maybenull An optional database which the given bibtex entries
belong to, which will be used to resolve strings. If the
database is null the strings will not be resolved.javax.xml.transform.TransformerException
- If the entry was malformed or unsupported.java.io.IOException
- If the file could not be written to or could not be found.public static void toXMP(java.util.Collection<BibtexEntry> bibtexEntries, BibtexDatabase database, java.io.OutputStream outputStream) throws java.io.IOException, javax.xml.transform.TransformerException
bibtexEntries
- The BibtexEntries to write XMP-metadata for.database
- maybenull An optional database which the given bibtex entries
belong to, which will be used to resolve strings. If the
database is null the strings will not be resolved.javax.xml.transform.TransformerException
- Thrown if the bibtexEntries could not transformed to XMP.java.io.IOException
- Thrown if an IOException occured while writing to the stream.if you don't need strings to be
resolved.
public static java.lang.String toXMP(java.util.Collection<BibtexEntry> bibtexEntries, BibtexDatabase database) throws javax.xml.transform.TransformerException
bibtexEntries
- The BibtexEntries to return XMP-metadata for.database
- maybenull An optional database which the given bibtex entries
belong to, which will be used to resolve strings. If the
database is null the strings will not be resolved.javax.xml.transform.TransformerException
- Thrown if the bibtexEntries could not transformed to XMP.public static org.apache.jempbox.xmp.XMPMetadata readRawXMP(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- The inputStream representing a PDF-file to read the
XMPMetadata from.java.io.IOException
public static org.apache.jempbox.xmp.XMPMetadata readRawXMP(java.io.File file) throws java.io.IOException
file
- The file to read the XMPMetadata from.java.io.IOException
public static void writeDublinCore(org.apache.pdfbox.pdmodel.PDDocument document, BibtexEntry entry, BibtexDatabase database) throws java.io.IOException, javax.xml.transform.TransformerException
document
- The pdf document to write to.entry
- The Bibtex entry that is written as a schema.database
- maybenull An optional database which the given bibtex entries
belong to, which will be used to resolve strings. If the
database is null the strings will not be resolved.java.io.IOException
javax.xml.transform.TransformerException
public static void writeDublinCore(org.apache.pdfbox.pdmodel.PDDocument document, java.util.Collection<BibtexEntry> entries, BibtexDatabase database) throws java.io.IOException, javax.xml.transform.TransformerException
document
- The pdf document to write to.entries
- The Bibtex entries that are written as schemasdatabase
- maybenull An optional database which the given bibtex entries
belong to, which will be used to resolve strings. If the
database is null the strings will not be resolved.java.io.IOException
javax.xml.transform.TransformerException
public static void writeDocumentInformation(org.apache.pdfbox.pdmodel.PDDocument document, BibtexEntry entry, BibtexDatabase database)
document
- The pdf document to write to.entry
- The Bibtex entry that is written into the PDF properties. *database
- maybenull An optional database which the given bibtex entries
belong to, which will be used to resolve strings. If the
database is null the strings will not be resolved.public static void writeXMP(java.io.File file, java.util.Collection<BibtexEntry> bibtexEntries, BibtexDatabase databasee, boolean writePDFInfo) throws java.io.IOException, javax.xml.transform.TransformerException
file
- The file to write the entries to.bibtexEntries
- The entries to write to the file. *database
- maybenull An optional database which the given bibtex entries
belong to, which will be used to resolve strings. If the
database is null the strings will not be resolved.writePDFInfo
- Write information also in PDF document propertiesjavax.xml.transform.TransformerException
- If the entry was malformed or unsupported.java.io.IOException
- If the file could not be written to or could not be found.protected static void usage()
main(String[])
public static void main(java.lang.String[] args) throws java.io.IOException, javax.xml.transform.TransformerException
args
- Command line strings passed to utility.java.io.IOException
- If any of the given files could not be read or written.javax.xml.transform.TransformerException
- If the given BibtexEntry is malformed.public static boolean hasMetadata(java.io.InputStream is)
is
- The inputstream to read the PDF from.