Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.xmp

public Class XmpUtilReader

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, java.nio.file.Path, java.util.ArrayList, .LinkedHashSet, .List, .Optional, .SequencedCollection, org.jabref.logic.bibtex.comparator.BibEntryCompare, org.jabref.model.entry.BibEntry, .LinkedFile, org.jabref.model.schema.DublinCoreSchemaCustom, org.apache.pdfbox.Loader, org.apache.pdfbox.pdmodel.PDDocument, .PDDocumentCatalog, .PDDocumentInformation, org.apache.pdfbox.pdmodel.common.PDMetadata, org.apache.xmpbox.XMPMetadata, org.apache.xmpbox.schema.DublinCoreSchema, org.slf4j.Logger, .LoggerFactory

Readings on XMP are available at docs/code-howtos/xmp-parsing.md

See also org.jabref.logic.xmp.XmpUtilWriter#writeDocumentInformation

Field Summary

Modifier and TypeField and Description
private static final String
private static final Logger
private static final String
private static final XmpUtilShared

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private List<XMPMetadata>

Returns:

empty List if no metadata has been found, or cannot properly find start or end tag in metadata
getXmpMetadata
(PDDocument document)

This method is a hack to generate multiple XMPMetadata objects, because the implementation of the pdfbox does not support methods for reading multiple DublinCoreSchemas from a single metadata entry.

public PDDocument
loadWithAutomaticDecryption(Path
The path to load.
path
)

Loads the specified file with the basic pdfbox functionality and uses an empty string as default password.

public List<XMPMetadata>

Returns:

The XMPMetadata object found in the file
readRawXmp
(Path
The path to read the XMPMetadata from.
path
)

Will read the XMPMetadata from the given pdf file, closing the file afterwards.

public List<BibEntry>
readXmp(Path
The path to read from.
path
,
XmpPreferences xmpPreferences)

Returns: list of a single BibEntry retrieved by merging the data from the stream

public List<BibEntry>
readXmp(Path
the path to the PDF file
path
,
PDDocument
the PDF document to read from (should have been created from path
document
,
XmpPreferences xmpPreferences)

Merges all XMP data together in one entry.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

END_TAGback to summary
private static final String END_TAG
LOGGERback to summary
private static final Logger LOGGER
START_TAGback to summary
private static final String START_TAG
XMP_UTIL_SHAREDback to summary
private static final XmpUtilShared XMP_UTIL_SHARED

Constructor Detail

XmpUtilReaderback to summary
public XmpUtilReader()

Method Detail

getXmpMetadataback to summary
private List<XMPMetadata> getXmpMetadata(PDDocument document)

This method is a hack to generate multiple XMPMetadata objects, because the implementation of the pdfbox does not support methods for reading multiple DublinCoreSchemas from a single metadata entry.

Moreover, DomXmpParser does not handle unknown namespaces

Returns:List<XMPMetadata>

empty List if no metadata has been found, or cannot properly find start or end tag in metadata

loadWithAutomaticDecryptionback to summary
public PDDocument loadWithAutomaticDecryption(Path path) throws IOException

Loads the specified file with the basic pdfbox functionality and uses an empty string as default password.

Parameters
path:Path

The path to load.

Exceptions
IOException:
from the underlying @link PDDocument#load(File)
readRawXmpback to summary
public List<XMPMetadata> readRawXmp(Path path) throws IOException

Will read the XMPMetadata from the given pdf file, closing the file afterwards.

Parameters
path:Path

The path to read the XMPMetadata from.

Returns:List<XMPMetadata>

The XMPMetadata object found in the file

readXmpback to summary
public List<BibEntry> readXmp(Path path, XmpPreferences xmpPreferences) throws IOException
Parameters
path:Path

The path to read from.

Returns:List<BibEntry>

list of a single BibEntry retrieved by merging the data from the stream

readXmpback to summary
public List<BibEntry> readXmp(Path path, PDDocument document, XmpPreferences xmpPreferences)

Merges all XMP data together in one entry.

Try to read the given BibTexEntry from the given PDF file.

Looks at the DocumentInformation and the XMP metadata. Regarding the XMP metadata, only Dublin Core is supported.

Parameters
path:Path

the path to the PDF file

document:PDDocument

the PDF document to read from (should have been created from path