Author: jukka
Date: Wed Aug 11 21:44:48 2010
New Revision: 984596

URL: http://svn.apache.org/viewvc?rev=984596&view=rev
Log:
TIKA-476: Add page count to metadata

Use the XMP Paged-text schema for the page count property

Added:
    tika/trunk/tika-core/src/main/java/org/apache/tika/metadata/PagedText.java
Modified:
    
tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pdf/PDFParser.java

Added: 
tika/trunk/tika-core/src/main/java/org/apache/tika/metadata/PagedText.java
URL: 
http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/metadata/PagedText.java?rev=984596&view=auto
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/metadata/PagedText.java 
(added)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/metadata/PagedText.java 
Wed Aug 11 21:44:48 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.metadata;
+
+/**
+ * XMP Paged-text schema. This is a collection of
+ * {...@link Property property definition} constants for the paged text
+ * properties defined in the XMP standard.
+ *
+ * @since Apache Tika 0.8
+ * @see <a 
href="http://www.adobe.com/devnet/xmp/pdfs/XMPSpecificationPart2.pdf";
+ *        >XMP Specification, Part 2: Standard Schemas</a>
+ */
+public interface PagedText {
+
+    /**
+     * "The number of pages in the document (including any in contained
+     * documents)."
+     */
+    Property N_PAGES = Property.internalInteger("xmpTPg:NPages");
+
+}

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=984596&r1=984595&r2=984596&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 
Wed Aug 11 21:44:48 2010
@@ -32,6 +32,7 @@ import org.apache.pdfbox.pdmodel.PDDocum
 import org.apache.pdfbox.pdmodel.PDDocumentInformation;
 import org.apache.tika.exception.TikaException;
 import org.apache.tika.metadata.Metadata;
+import org.apache.tika.metadata.PagedText;
 import org.apache.tika.metadata.Property;
 import org.apache.tika.mime.MediaType;
 import org.apache.tika.parser.ParseContext;
@@ -101,7 +102,7 @@ public class PDFParser implements Parser
     private void extractMetadata(PDDocument document, Metadata metadata)
             throws TikaException {
         PDDocumentInformation info = document.getDocumentInformation();
-        addMetadata(metadata, Metadata.PAGE_COUNT, String.valueOf( 
document.getNumberOfPages() ) );
+        metadata.set(PagedText.N_PAGES, document.getNumberOfPages());
         addMetadata(metadata, Metadata.TITLE, info.getTitle());
         addMetadata(metadata, Metadata.AUTHOR, info.getAuthor());
         addMetadata(metadata, Metadata.CREATOR, info.getCreator());


Reply via email to