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 2017/03/17 18:48:09 UTC
[tika] branch 2.x updated: TIKA-2236 upgrade PDFBox to 2.0.5 and
JempBox to 1.8.13
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/2.x by this push:
new 51cc80d TIKA-2236 upgrade PDFBox to 2.0.5 and JempBox to 1.8.13
51cc80d is described below
commit 51cc80d24616b84914efa9c7d478e6f25c0a985e
Author: tballison <ta...@mitre.org>
AuthorDate: Fri Mar 17 14:48:00 2017 -0400
TIKA-2236 upgrade PDFBox to 2.0.5 and JempBox to 1.8.13
---
CHANGES.txt | 2 ++
tika-parser-modules/pom.xml | 4 +--
.../java/org/apache/tika/parser/pdf/PDF2XHTML.java | 30 ++++++++++------------
.../org/apache/tika/parser/pdf/PDFParserTest.java | 9 +++----
4 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index f876807..857a2a4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -17,6 +17,8 @@ Release 2.0 - ???
Release 1.15 -???
+ * Upgrade PDFBox to 2.0.5 and JempBox to 1.8.13 (TIKA-2236).
+
* Extract images and thumbnails from ODT via Sam Bayer (TIKA-2295).
* Enabled configuration of the EncodingDetector used by
diff --git a/tika-parser-modules/pom.xml b/tika-parser-modules/pom.xml
index e6c1952..04c44de 100644
--- a/tika-parser-modules/pom.xml
+++ b/tika-parser-modules/pom.xml
@@ -38,8 +38,8 @@
<poi.version>3.16-beta2</poi.version>
<!-- NOTE: sync codec version with POI -->
<codec.version>1.10</codec.version>
- <pdfbox.version>2.0.4</pdfbox.version>
- <jempbox.version>1.8.12</jempbox.version>
+ <pdfbox.version>2.0.5</pdfbox.version>
+ <jempbox.version>1.8.13</jempbox.version>
<!-- used by POI, PDFBox and Jackcess ...try to sync -->
<bouncycastle.version>1.54</bouncycastle.version>
<commons.exec>1.3</commons.exec>
diff --git a/tika-parser-modules/tika-parser-multimedia-module/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java b/tika-parser-modules/tika-parser-multimedia-module/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java
index 26aa635..1b946bb 100644
--- a/tika-parser-modules/tika-parser-multimedia-module/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java
+++ b/tika-parser-modules/tika-parser-multimedia-module/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java
@@ -71,6 +71,8 @@ class PDF2XHTML extends AbstractPDF2XHTML {
private static final List<String> JP2 =
Arrays.asList(COSName.JPX_DECODE.getName());
+ private static final List<String> JB2 = Arrays.asList(
+ COSName.JBIG2_DECODE.getName());
/**
* This keeps track of the pdf object ids for inline
* images that have been processed.
@@ -214,23 +216,12 @@ class PDF2XHTML extends AbstractPDF2XHTML {
extension = "tif";
} else if (extension.equals("jpx")) {
embeddedMetadata.set(Metadata.CONTENT_TYPE, "image/jp2");
- }
-
- // PDFBox does not yet return JBIG2 extension and extracting
- // inline JBIG2 images fails with test file testPDF_JBIG2.pdf
- // if we explicitely set the content type to image/x-jbig2
- // (no "pages" are found when image is embedded).
- // It works when it thinks it is PNG so we do not force it to
- // jb2 for parsing until this issue is addressed in PDFBox and
- // Levigo jbig2-imageio. Will result in bad content-type in
- // metadata for now, but that's better than not being able to
- // handle JBIG2 in PDFs at all.
- // } else if (extension.equals("jb2")) {
- // embeddedMetadata.set(
- // Metadata.CONTENT_TYPE, "image/x-jbig2");
- else {
+ } else if (extension.equals("jb2")) {
+ embeddedMetadata.set(
+ Metadata.CONTENT_TYPE, "image/x-jbig2");
+ } else {
//TODO: determine if we need to add more image types
- //throw new RuntimeException("EXTEN:" + extension);
+// throw new RuntimeException("EXTEN:" + extension);
}
Integer imageNumber = processedInlineImages.get(cosStream);
@@ -307,13 +298,18 @@ class PDF2XHTML extends AbstractPDF2XHTML {
InputStream data = pdImage.createInputStream(JP2);
org.apache.pdfbox.io.IOUtils.copy(data, out);
org.apache.pdfbox.io.IOUtils.closeQuietly(data);
- } else {
+ } else if ("jb2".equals(suffix)) {
+ InputStream data = pdImage.createInputStream(JB2);
+ org.apache.pdfbox.io.IOUtils.copy(data, out);
+ org.apache.pdfbox.io.IOUtils.closeQuietly(data);
+ } else{
ImageIOUtil.writeImage(image, suffix, out);
}
}
out.flush();
}
+
@Override
protected void writeParagraphStart() throws IOException {
super.writeParagraphStart();
diff --git a/tika-parser-modules/tika-parser-multimedia-module/src/test/java/org/apache/tika/parser/pdf/PDFParserTest.java b/tika-parser-modules/tika-parser-multimedia-module/src/test/java/org/apache/tika/parser/pdf/PDFParserTest.java
index e0890ce..3e655dc 100644
--- a/tika-parser-modules/tika-parser-multimedia-module/src/test/java/org/apache/tika/parser/pdf/PDFParserTest.java
+++ b/tika-parser-modules/tika-parser-multimedia-module/src/test/java/org/apache/tika/parser/pdf/PDFParserTest.java
@@ -652,7 +652,7 @@ public class PDFParserTest extends TikaTest {
context.set(PDFParserConfig.class, config);
List<Metadata> metadatas = getRecursiveMetadata("testPDF_JBIG2.pdf", context);
-
+ debug(metadatas);
assertContains("test images compressed using JBIG2",
metadatas.get(0).get(RecursiveParserWrapper.TIKA_CONTENT));
@@ -664,12 +664,9 @@ public class PDFParserTest extends TikaTest {
assertEquals("Invalid width.", "352", metadatas.get(1).get("width"));
assertNull(metadatas.get(0).get(Metadata.RESOURCE_NAME_KEY));
-
- //TODO mime/extension should be tested against JBIG2 once better
- //supported by PDFBox and Levigo jbig2-imageio
- assertEquals("image0.png",
+ assertEquals("image0.jb2",
metadatas.get(1).get(Metadata.RESOURCE_NAME_KEY));
- assertEquals(MediaType.image("png").toString(),
+ assertEquals(MediaType.image("x-jbig2").toString(),
metadatas.get(1).get(Metadata.CONTENT_TYPE));
}
--
To stop receiving notification emails like this one, please contact
['"commits@tika.apache.org" <co...@tika.apache.org>'].