-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First approach for implementing PDF Exporter
Remove code that produces NPE
- Loading branch information
1 parent
9be770c
commit bd508ad
Showing
4 changed files
with
40 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/org/jabref/logic/exporter/PdfFileExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.jabref.logic.exporter; | ||
|
||
import java.nio.charset.Charset; | ||
import java.util.List; | ||
import org.jabref.logic.TypedBibEntry; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.ParsedFileField; | ||
|
||
public class PdfFileExporter extends ExportFormat { | ||
|
||
public PdfFileExporter() { | ||
super("PDF files", "PDF", null, null, ".pdf"); | ||
} | ||
@Override | ||
public void performExport(final BibDatabaseContext databaseContext, String file, final Charset encoding, | ||
List<BibEntry> entries) throws Exception { | ||
|
||
for (BibEntry entry : entries) { | ||
TypedBibEntry typedEntry = new TypedBibEntry(entry, databaseContext); | ||
|
||
List<ParsedFileField> files = typedEntry.getFiles(); | ||
for (ParsedFileField fileEntry : files) { | ||
String fileName = fileEntry.getLink(); | ||
|
||
// databaseContext.getFileDirectories(preferences) | ||
// Optional<File> oldFile = FileUtil.expandFilename(fileName, | ||
// databaseContext.getFileDirectories(Globals.prefs.getFileDirectoryPreferences())); | ||
|
||
System.out.println("Export pdfs"); | ||
// FileUtil.copyFile(oldFile.get().toPath(), file, false); | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |