You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2018/03/29 19:40:17 UTC
[tika] branch branch_1x updated: TIKA-2620 allow configuration of
setting KCMS
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/branch_1x by this push:
new fc718f4 TIKA-2620 allow configuration of setting KCMS
fc718f4 is described below
commit fc718f436b2d9676321a65c4f2d6009e23303ef6
Author: tballison <ta...@mitre.org>
AuthorDate: Thu Mar 29 15:39:17 2018 -0400
TIKA-2620 allow configuration of setting KCMS
---
.../java/org/apache/tika/parser/pdf/PDFParser.java | 8 +++++++
.../apache/tika/parser/pdf/PDFParserConfig.java | 27 ++++++++++++++++++++++
.../apache/tika/parser/pdf/PDFParser.properties | 2 ++
3 files changed, 37 insertions(+)
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java b/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java
index b69274e..406bbd3 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java
@@ -132,6 +132,9 @@ public class PDFParser extends AbstractParser implements Initializable {
throws IOException, SAXException, TikaException {
PDFParserConfig localConfig = context.get(PDFParserConfig.class, defaultConfig);
+ if (localConfig.getSetKCMS()) {
+ System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider");
+ }
PDDocument pdfDocument = null;
@@ -703,6 +706,11 @@ public class PDFParser extends AbstractParser implements Initializable {
}
@Field
+ void setSetKCMS(boolean setKCMS) {
+ defaultConfig.setSetKCMS(setKCMS);
+ }
+
+ @Field
void setInitializableProblemHander(String name) {
if ("ignore".equals(name)) {
setInitializableProblemHandler(InitializableProblemHandler.IGNORE);
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParserConfig.java b/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParserConfig.java
index 5fc9a7b..a305c4c 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParserConfig.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParserConfig.java
@@ -137,6 +137,8 @@ public class PDFParserConfig implements Serializable {
private long maxMainMemoryBytes = -1;
+ private boolean setKCMS = false;
+
public PDFParserConfig() {
init(this.getClass().getResourceAsStream("PDFParser.properties"));
}
@@ -215,6 +217,7 @@ public class PDFParserConfig implements Serializable {
setExtractActions(getBooleanProp(props.getProperty("extractActions"), false));
+ setSetKCMS(getBooleanProp(props.getProperty("setKCMS"), false));
boolean checkExtractAccessPermission = getBooleanProp(props.getProperty("checkExtractAccessPermission"), false);
boolean allowExtractionForAccessibility = getBooleanProp(props.getProperty("allowExtractionForAccessibility"), true);
@@ -688,6 +691,30 @@ public class PDFParserConfig implements Serializable {
this.maxMainMemoryBytes = maxMainMemoryBytes;
}
+ /**
+ * <p>
+ * Whether to call <code>System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider")</code>.
+ * KCMS is the unmaintained, legacy provider and is far faster than the newer replacement.
+ * However, there are stability and security risks with using the unmaintained legacy provider.
+ * </p>
+ * <p>
+ * Note, of course, that this is <b>not</b> thread safe. If the value is <code>false</code>
+ * in your first thread, and the second thread changes this to <code>true</code>,
+ * the system property in the first thread will now be <code>true</code>.
+ * </p>
+ * <p>
+ * Default is <code>false</code>.
+ * </p>
+ * @param setKCMS whether or not to set KCMS
+ */
+ public void setSetKCMS(boolean setKCMS) {
+ this.setKCMS = setKCMS;
+ }
+
+ public boolean getSetKCMS() {
+ return setKCMS;
+ }
+
private ImageType parseImageType(String ocrImageType) {
for (ImageType t : ImageType.values()) {
if (ocrImageType.equalsIgnoreCase(t.toString())) {
diff --git a/tika-parsers/src/main/resources/org/apache/tika/parser/pdf/PDFParser.properties b/tika-parsers/src/main/resources/org/apache/tika/parser/pdf/PDFParser.properties
index 88b1623..f2d3db6 100644
--- a/tika-parsers/src/main/resources/org/apache/tika/parser/pdf/PDFParser.properties
+++ b/tika-parsers/src/main/resources/org/apache/tika/parser/pdf/PDFParser.properties
@@ -37,3 +37,5 @@ ocrImageType gray
ocrImageScale 2.0
# Use up to 500MB when loading a pdf into a PDDocument
maxMainMemoryBytes 524288000
+#whether or not to set KCMS for faster (but legacy/unsupported) image rendering
+setKCMS false
--
To stop receiving notification emails like this one, please contact
tallison@apache.org.