Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/java/net/sf/jabref/util/XMPUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -983,10 +983,35 @@ public static void writeDocumentInformation(PDDocument document,
if (database != null)
entry = database.resolveForStrings(entry, false);

// Query privacy filter settings
JabRefPreferences prefs = JabRefPreferences.getInstance();
boolean useXmpPrivacyFilter =
prefs.getBoolean("useXmpPrivacyFilter");
// Fields for which not to write XMP data later on:
TreeSet<String> filters = new TreeSet<String>(Arrays.asList(prefs.getStringArray(JabRefPreferences.XMP_PRIVACY_FILTERS)));

// Set all the values including key and entryType
Set<String> fields = entry.getAllFields();

for (String field : fields){

if (useXmpPrivacyFilter && filters.contains(field)) {
// erase field instead of adding it
if (field.equals("author")) {
di.setAuthor(null);
} else if (field.equals("title")) {
di.setTitle(null);
} else if (field.equals("keywords")) {
di.setKeywords(null);
} else if (field.equals("abstract")) {
di.setSubject(null);
} else {
di.setCustomMetadataValue("bibtex/" + field,
null);
}
continue;
}

if (field.equals("author")) {
di.setAuthor(entry.getField("author"));
} else if (field.equals("title")) {
Expand Down