Verified Owner
Top Description Constructors Methods
org.jabref.logic.importer.fileformat.pdf

public abstract Class PdfImporter

extends Importer
Class Inheritance
Known Direct Subclasses
org.jabref.logic.importer.fileformat.pdf.PdfMergeMetadataImporter, org.jabref.logic.importer.fileformat.pdf.PdfVerbatimBibtexImporter, org.jabref.logic.importer.fileformat.pdf.PdfXmpImporter, org.jabref.logic.importer.fileformat.pdf.BibliographyFromPdfImporter, org.jabref.logic.importer.fileformat.pdf.PdfContentImporter, org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedBibFileImporter
Annotations
@NullMarked
Imports
java.io.BufferedReader, .IOException, .Reader, java.nio.file.Path, org.jabref.logic.importer.Importer, .ParseException, .ParserResult, org.jabref.logic.l10n.Localization, org.jabref.logic.util.StandardFileType, org.jabref.logic.xmp.EncryptedPdfsNotSupportedException, .XmpUtilReader, org.apache.pdfbox.pdmodel.PDDocument, org.jspecify.annotations.NullMarked

Intermediate class to bundle all PDF analysis steps. PdfImporters are also org.jabref.logic.importer.Importers, which allows user for more fine-grained control of how org.jabref.model.entry.BibEntry is extracted from a PDF file.

PdfImporters are used in two places in JabRef:

  1. PdfMergeMetadataImporter: uses several PdfImporter and automatically merges them into 1 org.jabref.model.entry.BibEntry.
  2. org.jabref.gui.externalfiles.PdfMergeDialog also uses several PdfImporter, but it shows a merge dialog (instead of automatic merging).

Note, that this step should not add PDF file to org.jabref.model.entry.BibEntry, it will be finally added either in importDatabase(Path) or PdfMergeMetadataImporter.

The result might be the metadata of the given PDF or the list of references in the references section (also called "citations"). Each implementation should denote which of these two it supports.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public StandardFileType
getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

public ParserResult
importDatabase(BufferedReader reader)

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

public ParserResult
importDatabase(String data)

Overrides org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the specified string.

public ParserResult
importDatabase(Path filePath)

Overrides org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the specified file.

public abstract ParserResult
importDatabase(Path filePath, PDDocument document)

Note

The "throws" clause is for "developer convenience" - it is turned into a ParserResult at importDatabase(Path).

public boolean
isRecognizedFormat(Reader input)

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

#isRecognizedFormat(BufferedReader) without the requirement to reset

public boolean
isRecognizedFormat(BufferedReader input)

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

Inherited from org.jabref.logic.importer.Importer:
compareToequalsgetCharsetgetDescriptiongetIdgetNamegetReadergetReaderhashCodeisRecognizedFormatisRecognizedFormatsupportsFileExtensiontoString

Constructor Detail

PdfImporterback to summary
public PdfImporter()

Method Detail

getFileTypeback to summary
public StandardFileType getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Doc from org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

Annotations
@Override
importDatabaseback to summary
public ParserResult importDatabase(BufferedReader reader) throws IOException

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Doc from org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

This method can be called in two different contexts - either when importing in a specified format, or when importing in unknown format. In the latter case, JabRef cycles through all available import formats. No error messages or feedback is displayed from individual import formats in this case.

If importing in a specified format and an empty library is returned, JabRef reports that no entries were found.

If your format is binary-based (PDF, ZIP-based, or others), then you should not solely override this method. For binary formats do this:

  1. Throw UnsupportedOperationException in this method.
  2. Override the method Importer#importDatabase(Path). Example of this workaround is in: org.jabref.logic.importer.fileformat.pdf.PdfImporter.
Annotations
@Override
importDatabaseback to summary
public ParserResult importDatabase(String data) throws IOException

Overrides org.jabref.logic.importer.Importer.importDatabase.

Doc from org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the specified string.

Importer having the facilities to detect the correct encoding of a string should overwrite this method, determine the encoding and then call importDatabase(BufferedReader).

Annotations
@Override
Exceptions
IOException:
Signals that an I/O exception has occurred.
importDatabaseback to summary
public ParserResult importDatabase(Path filePath)

Overrides org.jabref.logic.importer.Importer.importDatabase.

Doc from org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the specified file.

Annotations
@Override
importDatabaseback to summary
public abstract ParserResult importDatabase(Path filePath, PDDocument document) throws IOException, ParseException

Note

The "throws" clause is for "developer convenience" - it is turned into a ParserResult at importDatabase(Path).

isRecognizedFormatback to summary
public boolean isRecognizedFormat(Reader input) throws IOException

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Doc from org.jabref.logic.importer.Importer.isRecognizedFormat.

#isRecognizedFormat(BufferedReader) without the requirement to reset

Annotations
@Override
isRecognizedFormatback to summary
public boolean isRecognizedFormat(BufferedReader input) throws IOException

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Doc from org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

All implementations need to reset the input stream to the beginning again - to enable importing at subsequent calls.

The effect of this method is primarily to avoid unnecessary processing of files when searching for a suitable import format. If this method returns false, the import routine will move on to the next import format.

Thus, the correct behavior is to return false if it is certain that the file is not of the suitable type, and true otherwise. Returning true is the safe choice if not certain.

Annotations
@Override