You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ju...@apache.org on 2010/11/01 00:09:17 UTC

svn commit: r1029510 - in /tika/trunk/tika-parsers: pom.xml src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java src/main/java/org/apache/tika/parser/pdf/PDFParser.java

Author: jukka
Date: Sun Oct 31 23:09:17 2010
New Revision: 1029510

URL: http://svn.apache.org/viewvc?rev=1029510&view=rev
Log:
TIKA-446: Upgrade to PDFBox 1.3.1

Modified:
    tika/trunk/tika-parsers/pom.xml
    tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java
    tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java

Modified: tika/trunk/tika-parsers/pom.xml
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/pom.xml?rev=1029510&r1=1029509&r2=1029510&view=diff
==============================================================================
--- tika/trunk/tika-parsers/pom.xml (original)
+++ tika/trunk/tika-parsers/pom.xml Sun Oct 31 23:09:17 2010
@@ -72,7 +72,7 @@
     <dependency>
       <groupId>org.apache.pdfbox</groupId>
       <artifactId>pdfbox</artifactId>
-      <version>1.2.1</version>
+      <version>1.3.1</version>
     </dependency>
     <!-- TIKA-370: PDFBox declares the Bouncy Castle dependencies
          as optional, but we prefer to have them always to avoid

Modified: tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java?rev=1029510&r1=1029509&r2=1029510&view=diff
==============================================================================
--- tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java (original)
+++ tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDF2XHTML.java Sun Oct 31 23:09:17 2010
@@ -65,6 +65,8 @@ class PDF2XHTML extends PDFTextStripper 
     private PDF2XHTML(ContentHandler handler, Metadata metadata)
             throws IOException {
         this.handler = new XHTMLContentHandler(handler, metadata);
+        setForceParsing(true);
+        setSortByPosition(true);
     }
 
     @Override
@@ -125,47 +127,4 @@ class PDF2XHTML extends PDFTextStripper 
         }
     }
 
-    // Two methods added to work around lack of support for processWordSeparator
-    // and processLineSeparator in PDFBox-0.7.3. This is fixed in CVS Head (PDFBox-0.7.4)
-    @Override
-    public String getWordSeparator()
-    {
-        try
-        {
-            handler.characters(" ");
-        } catch(SAXException e) {
-
-        }
-        return super.getWordSeparator();    //To change body of overridden methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public String getLineSeparator()
-    {
-        try
-        {
-            handler.characters("\n");
-        } catch(SAXException e) {
-
-        }
-        return super.getLineSeparator();
-    }
-
-//    protected void processLineSeparator(TextPosition p) throws IOException {
-//        try {
-//            handler.characters("\n");
-//        } catch (SAXException e) {
-//            throw new IOExceptionWithCause("Unable to write a newline", e);
-//        }
-//    }
-//
-//    protected void processWordSeparator(TextPosition a, TextPosition b)
-//            throws IOException {
-//        try {
-//            handler.characters(" ");
-//        } catch (SAXException e) {
-//            throw new IOExceptionWithCause("Unable to write a space", e);
-//        }
-//    }
-
 }

Modified: tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java?rev=1029510&r1=1029509&r2=1029510&view=diff
==============================================================================
--- tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java (original)
+++ tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java Sun Oct 31 23:09:17 2010
@@ -50,6 +50,9 @@ import org.xml.sax.SAXException;
  */
 public class PDFParser implements Parser {
 
+    /** Serial version UID */
+    private static final long serialVersionUID = -752276948656079347L;
+
     /**
      * Metadata key for giving the document password to the parser.
      *
@@ -68,7 +71,7 @@ public class PDFParser implements Parser
             InputStream stream, ContentHandler handler,
             Metadata metadata, ParseContext context)
             throws IOException, SAXException, TikaException {
-        PDDocument pdfDocument = PDDocument.load(stream);
+        PDDocument pdfDocument = PDDocument.load(stream, true);
         try {
             if (pdfDocument.isEncrypted()
                     && !pdfDocument.getCurrentAccessPermission().canExtractContent()) {