Skip to content

Commit

Permalink
Merge pull request #8 from adaerr/master
Browse files Browse the repository at this point in the history
PDF-file metadata: Privacy Filtering all metadata
  • Loading branch information
koppor committed Apr 23, 2014
2 parents 0e6f094 + 2360cb7 commit 5454ab4
Showing 1 changed file with 25 additions and 0 deletions.
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

0 comments on commit 5454ab4

Please sign in to comment.