Skip to content

Commit 77907c8

Browse files
authored
find the title from second page (#12157)
* find the title from second page find the title from second page * fix method name fix method name * add a unit test file with a test cover page add a unit test file with a test cover page * change unit test cover page file change unit test cover page file * fix the pdf file with consistency cover fix the pdf file with consistency cover
1 parent a86adbb commit 77907c8

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public ParserResult importDatabase(Path filePath) {
218218

219219
private static String extractTitleFromDocument(PDDocument document) throws IOException {
220220
TitleExtractorByFontSize stripper = new TitleExtractorByFontSize();
221-
return stripper.getTitleFromFirstPage(document);
221+
return stripper.getTitle(document);
222222
}
223223

224224
private static class TitleExtractorByFontSize extends PDFTextStripper {
@@ -230,9 +230,9 @@ public TitleExtractorByFontSize() {
230230
this.textPositionsList = new ArrayList<>();
231231
}
232232

233-
public String getTitleFromFirstPage(PDDocument document) throws IOException {
233+
public String getTitle(PDDocument document) throws IOException {
234234
this.setStartPage(1);
235-
this.setEndPage(1);
235+
this.setEndPage(2);
236236
this.writeText(document, new StringWriter());
237237
return findLargestFontText(textPositionsList);
238238
}

src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ void pdfTitleExtraction(String expectedTitle, String filePath) throws Exception
140140
private static Stream<Arguments> providePdfData() {
141141
return Stream.of(
142142
Arguments.of("Fundamentals of Distributed Computing: A Practical Tour of Vector Clock Systems", "/pdfs/PdfContentImporter/Baldoni2002.pdf"),
143+
Arguments.of("JabRef Example for Reference Parsing", "/pdfs/IEEE/ieee-paper-cover.pdf"),
143144
Arguments.of("On How We Can Teach – Exploring New Ways in Professional Software Development for Students", "/pdfs/PdfContentImporter/Kriha2018.pdf"),
144145
Arguments.of("JabRef Example for Reference Parsing", "/pdfs/IEEE/ieee-paper.pdf"),
145146
Arguments.of("Paper Title", "/org/jabref/logic/importer/util/LNCS-minimal.pdf"),
114 KB
Binary file not shown.

0 commit comments

Comments
 (0)