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

public Class PdfMergeMetadataImporter

extends PdfImporter
Class Inheritance
Known Direct Subclasses
org.jabref.logic.importer.fileformat.pdf.PdfMergeMetadataImporter.EntryBasedFetcherWrapper
Imports
java.io.IOException, java.nio.file.Path, java.util.ArrayList, .Arrays, .HashSet, .List, .Optional, .Set, java.util.regex.Pattern, java.util.stream.Collectors, org.jabref.logic.FilePreferences, org.jabref.logic.cleanup.RelativePathsCleanup, org.jabref.logic.importer.EntryBasedFetcher, .FetcherException, .IdBasedFetcher, .ImportFormatPreferences, .ParseException, .ParserResult, org.jabref.logic.importer.fetcher.ArXivFetcher, .DoiFetcher, org.jabref.logic.importer.fetcher.isbntobibtex.IsbnFetcher, org.jabref.logic.l10n.Localization, org.jabref.logic.util.StandardFileType, org.jabref.logic.util.io.FileUtil, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, .LinkedFile, org.jabref.model.entry.field.StandardField, org.apache.pdfbox.pdmodel.PDDocument, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

Tries to import BibTeX data trying multiple PdfImporters and merging the results. See PdfMergeMetadataImporter#metadataImporters for the list of importers used.

After all importers are applied, this importer tries to fetch additional metadata for the entry using the DOI and ISBN.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final ArXivFetcher
private final DoiFetcher
private static final Pattern
private final IsbnFetcher
private static final Logger
private final List<PdfImporter>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Pattern
private List<BibEntry>
private void
fetchData(BibEntry
The BibEntry to look for the field
candidate
,
StandardField
The field to look for
field
,
IdBasedFetcher
The fetcher to use
fetcher
,
Set<String>
The already fetched ids (will be updated)
fetchedIds
,
List<BibEntry>
New candidate (will be updated)
fetchedCandidates
)

private List<BibEntry>
public String
getDescription()

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

Returns the description of the import format.

public String
getId()

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

Returns a slug, which identifies this importer.

public String
getName()

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

Returns the name of this import format.

public ParserResult
importDatabase(Path filePath, PDDocument document)

Implements abstract org.jabref.logic.importer.fileformat.pdf.PdfImporter.importDatabase.

Makes BibEntry out of PDF file via merging results of several PDF analysis steps (PdfImporter).

public ParserResult
importDatabase(Path filePath, @NonNull BibDatabaseContext context, @NonNull FilePreferences filePreferences)

Imports the BibTeX data from the given PDF file and relativized the paths of each linked file based on the context and the file preferences.

private static boolean
private static BibEntry
Inherited from org.jabref.logic.importer.fileformat.pdf.PdfImporter:
getFileTypeimportDatabaseimportDatabaseimportDatabaseisRecognizedFormatisRecognizedFormat

Field Detail

arXivFetcherback to summary
private final ArXivFetcher arXivFetcher
doiFetcherback to summary
private final DoiFetcher doiFetcher
FILENAME_TITLE_PATTERNback to summary
private static final Pattern FILENAME_TITLE_PATTERN
isbnFetcherback to summary
private final IsbnFetcher isbnFetcher
LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.logic.importer.Importer.LOGGER.

metadataImportersback to summary
private final List<PdfImporter> metadataImporters

Constructor Detail

PdfMergeMetadataImporterback to summary
public PdfMergeMetadataImporter(ImportFormatPreferences importFormatPreferences)

Method Detail

buildFilenameTitlePatternback to summary
private static Pattern buildFilenameTitlePattern()
extractCandidatesFromPdfback to summary
private List<BibEntry> extractCandidatesFromPdf(Path filePath, PDDocument document)
fetchDataback to summary
private void fetchData(BibEntry candidate, StandardField field, IdBasedFetcher fetcher, Set<String> fetchedIds, List<BibEntry> fetchedCandidates)
Parameters
candidate:BibEntry

The BibEntry to look for the field

field:StandardField

The field to look for

fetcher:IdBasedFetcher

The fetcher to use

fetchedIds:Set<String>

The already fetched ids (will be updated)

fetchedCandidates:List<BibEntry>

New candidate (will be updated)

fetchIdsOfCandidatesback to summary
private List<BibEntry> fetchIdsOfCandidates(List<BibEntry> candidates)
getDescriptionback to summary
public String getDescription()

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

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

Returns the description of the import format.

The description should specify
what kind of entries from what sources and based on what specification it is able to import

by what criteria it isRecognizedFormat(BufferedReader) recognizes an import format

Annotations
@Override
getIdback to summary
public String getId()

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

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

Returns a slug, which identifies this importer. Used, for example, to identify the importer in CLI.

Typically, this name should be short, in English, and should not contain special characters like #, %, etc.

Annotations
@Override
getNameback to summary
public String getName()

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

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

Returns the name of this import format. Typically, this is a string that denotes file type or format. It can also be localized, like "XMP-annotated PDF".

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

Implements abstract org.jabref.logic.importer.fileformat.pdf.PdfImporter.importDatabase.

Makes BibEntry out of PDF file via merging results of several PDF analysis steps (PdfImporter).

Algorithm:

  1. Store all candidates (possible BibEntryies) in a list. First elements in this list will have higher priority for merging, which means that more fields will be stored for first entries, rather than last.
  2. Run PdfImporters, and store extracted candidates in the list.
Annotations
@Override
importDatabaseback to summary
public ParserResult importDatabase(Path filePath, @NonNull BibDatabaseContext context, @NonNull FilePreferences filePreferences) throws IOException

Imports the BibTeX data from the given PDF file and relativized the paths of each linked file based on the context and the file preferences.

isTitleLikelyFilenameback to summary
private static boolean isTitleLikelyFilename(String title)
mergeCandidatesback to summary
private static BibEntry mergeCandidates(List<BibEntry> candidates)
org.jabref.logic.importer.fileformat.pdf back to summary

public Class PdfMergeMetadataImporter.EntryBasedFetcherWrapper

extends PdfMergeMetadataImporter
implements EntryBasedFetcher
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.EntryBasedFetcher, org.jabref.logic.importer.WebFetcher

Field Summary

Modifier and TypeField and Description
private final BibDatabaseContext
private final FilePreferences

Constructor Summary

AccessConstructor and Description
public
EntryBasedFetcherWrapper(ImportFormatPreferences importFormatPreferences, FilePreferences filePreferences, BibDatabaseContext context)

Method Summary

Modifier and TypeMethod and Description
public List<BibEntry>
performSearch(@NonNull BibEntry entry)

Implements org.jabref.logic.importer.EntryBasedFetcher.performSearch.

Looks for hits which are matched by the given BibEntry.

Inherited from org.jabref.logic.importer.fileformat.pdf.PdfMergeMetadataImporter:
getDescriptiongetIdgetNameimportDatabaseimportDatabase

Field Detail

databaseContextback to summary
private final BibDatabaseContext databaseContext
filePreferencesback to summary
private final FilePreferences filePreferences

Constructor Detail

EntryBasedFetcherWrapperback to summary
public EntryBasedFetcherWrapper(ImportFormatPreferences importFormatPreferences, FilePreferences filePreferences, BibDatabaseContext context)

Method Detail

performSearchback to summary
public List<BibEntry> performSearch(@NonNull BibEntry entry) throws FetcherException

Implements org.jabref.logic.importer.EntryBasedFetcher.performSearch.

Doc from org.jabref.logic.importer.EntryBasedFetcher.performSearch.

Looks for hits which are matched by the given BibEntry.

Annotations
@Override