You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/08/30 04:22:52 UTC

svn commit: r1621410 [1/2] - in /pdfbox/branches/no-awt: ./ app/src/main/appended-resources/META-INF/ examples/ examples/src/main/appended-resources/META-INF/ examples/src/main/java/org/apache/pdfbox/examples/fdf/ examples/src/main/java/org/apache/pdfb...

Author: jahewson
Date: Sat Aug 30 02:22:51 2014
New Revision: 1621410

URL: http://svn.apache.org/r1621410
Log:
PDFBOX-2262: Merge trunk into no-awt branch

Removed:
    pdfbox/branches/no-awt/jempbox/
Modified:
    pdfbox/branches/no-awt/   (props changed)
    pdfbox/branches/no-awt/LICENSE.txt
    pdfbox/branches/no-awt/NOTICE.txt
    pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/LICENSE
    pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/NOTICE
    pdfbox/branches/no-awt/examples/pom.xml
    pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/LICENSE
    pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/NOTICE
    pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
    pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java
    pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddMetadataFromDocInfo.java
    pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractMetadata.java
    pdfbox/branches/no-awt/pdfbox/build.xml
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFileOutputStream.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDCheckbox.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDComboBox.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDListBox.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDNonTerminalField.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTextField.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/util/MetaUtil.java
    pdfbox/branches/no-awt/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestFDF.java
    pdfbox/branches/no-awt/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
    pdfbox/branches/no-awt/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
    pdfbox/branches/no-awt/pom.xml
    pdfbox/branches/no-awt/preflight-app/src/main/appended-resources/META-INF/LICENSE
    pdfbox/branches/no-awt/preflight-app/src/main/appended-resources/META-INF/NOTICE
    pdfbox/branches/no-awt/xmpbox/src/main/java/org/apache/xmpbox/schema/DublinCoreSchema.java
    pdfbox/branches/no-awt/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPBasicSchema.java
    pdfbox/branches/no-awt/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPRightsManagementSchema.java

Propchange: pdfbox/branches/no-awt/
------------------------------------------------------------------------------
    svn:mergeinfo = /pdfbox/trunk:1618514-1621409

Modified: pdfbox/branches/no-awt/LICENSE.txt
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/LICENSE.txt?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/LICENSE.txt (original)
+++ pdfbox/branches/no-awt/LICENSE.txt Sat Aug 30 02:22:51 2014
@@ -207,10 +207,9 @@ Apache PDFBox includes a number of compo
 and license terms. Your use of these components is subject to the terms and
 conditions of the following licenses.
 
-Contributions made to the original PDFBox, JempBox and FontBox projects:
+Contributions made to the original PDFBox and FontBox projects:
 
    Copyright (c) 2002-2007, www.pdfbox.org
-   Copyright (c) 2006-2007, www.jempbox.org
    All rights reserved.
 
    Redistribution and use in source and binary forms, with or without

Modified: pdfbox/branches/no-awt/NOTICE.txt
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/NOTICE.txt?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/NOTICE.txt (original)
+++ pdfbox/branches/no-awt/NOTICE.txt Sat Aug 30 02:22:51 2014
@@ -4,10 +4,10 @@ Copyright 2014 The Apache Software Found
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).
 
-Based on source code originally developed in the PDFBox, JempBox and
+Based on source code originally developed in the PDFBox and 
 FontBox projects.
+
 Copyright (c) 2002-2007, www.pdfbox.org
-Copyright (c) 2006-2007, www.jempbox.org
 
 Based on source code originally developed in the PaDaF project.
 Copyright (c) 2010 Atos Worldline SAS

Modified: pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/LICENSE
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/LICENSE?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/LICENSE (original)
+++ pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/LICENSE Sat Aug 30 02:22:51 2014
@@ -5,10 +5,9 @@ Apache PDFBox includes a number of compo
 and license terms. Your use of these components is subject to the terms and
 conditions of the following licenses.
 
-Contributions made to the original PDFBox, JempBox and FontBox projects:
+Contributions made to the original PDFBox and FontBox projects:
 
    Copyright (c) 2002-2007, www.pdfbox.org
-   Copyright (c) 2006-2007, www.jempbox.org
    All rights reserved.
 
    Redistribution and use in source and binary forms, with or without
@@ -135,36 +134,3 @@ Glyphlist (http://www.adobe.com/devnet/o
    non-infringement of any third party rights regarding the Adobe
    materials.
 
-The International Components for Unicode library (http://site.icu-project.org/)
-
-   ICU License - ICU 1.8.1 and later
-
-   COPYRIGHT AND PERMISSION NOTICE
-
-   Copyright (c) 1995-2009 International Business Machines Corporation and others
-
-   All rights reserved.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, and/or sell
-   copies of the Software, and to permit persons to whom  the Software is
-   furnished to do so, provided that the above copyright notice(s) and this
-   permission notice appear in all copies of the Software and that both the
-   above copyright notice(s) and this permission notice appear in supporting
-   documentation.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
-   IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
-   BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
-   OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-   WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-   ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-   Except as contained in this notice, the name of a copyright holder shall
-   not be used in advertising or otherwise to promote the sale, use or other
-   dealings in this Software without prior written authorization of the
-   copyright holder.

Modified: pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/NOTICE?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/NOTICE (original)
+++ pdfbox/branches/no-awt/app/src/main/appended-resources/META-INF/NOTICE Sat Aug 30 02:22:51 2014
@@ -1,4 +1,2 @@
-Based on source code originally developed in the PDFBox, JempBox and
-FontBox projects.
+Based on source code originally developed in the PDFBox and FontBox projects.
 Copyright (c) 2002-2007, www.pdfbox.org
-Copyright (c) 2006-2007, www.jempbox.org

Modified: pdfbox/branches/no-awt/examples/pom.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/examples/pom.xml?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/examples/pom.xml (original)
+++ pdfbox/branches/no-awt/examples/pom.xml Sat Aug 30 02:22:51 2014
@@ -54,9 +54,10 @@
         <version>${project.version}</version>
     </dependency>
     <dependency>
-		<groupId>org.apache.pdfbox</groupId>
-        <artifactId>jempbox</artifactId>
-        <version>${project.version}</version>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>xmpbox</artifactId>
+      <version>${project.version}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
         <groupId>org.apache.lucene</groupId>

Modified: pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/LICENSE
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/LICENSE?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/LICENSE (original)
+++ pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/LICENSE Sat Aug 30 02:22:51 2014
@@ -5,10 +5,9 @@ Apache PDFBox includes a number of compo
 and license terms. Your use of these components is subject to the terms and
 conditions of the following licenses.
 
-Contributions made to the original PDFBox, JempBox and FontBox projects:
+Contributions made to the original PDFBox and FontBox projects:
 
    Copyright (c) 2002-2007, www.pdfbox.org
-   Copyright (c) 2006-2007, www.jempbox.org
    All rights reserved.
 
    Redistribution and use in source and binary forms, with or without

Modified: pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/NOTICE?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/NOTICE (original)
+++ pdfbox/branches/no-awt/examples/src/main/appended-resources/META-INF/NOTICE Sat Aug 30 02:22:51 2014
@@ -1,4 +1,2 @@
-Based on source code originally developed in the PDFBox, JempBox and
-FontBox projects.
+Based on source code originally developed in the PDFBox and FontBox projects.
 Copyright (c) 2002-2007, www.pdfbox.org
-Copyright (c) 2006-2007, www.jempbox.org

Modified: pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java (original)
+++ pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java Sat Aug 30 02:22:51 2014
@@ -99,7 +99,14 @@ public class PrintFields
             }
             else
             {
-                fieldValue = field.getValue();
+                if (field.getValue() != null)
+                {
+                    fieldValue = field.getValue().toString();
+                }
+                else
+                {
+                    fieldValue = "";
+                }
             }
             String outputString = sLevel + sParent + "." + partialName + " = " + fieldValue + ",  type="
                     + field.getClass().getName();

Modified: pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java (original)
+++ pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java Sat Aug 30 02:22:51 2014
@@ -16,12 +16,11 @@
  */
 package org.apache.pdfbox.examples.pdfa;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.jempbox.xmp.XMPMetadata;
-import org.apache.jempbox.xmp.pdfa.XMPSchemaPDFAId;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
 import org.apache.pdfbox.pdmodel.PDPage;
@@ -30,6 +29,11 @@ import org.apache.pdfbox.pdmodel.edit.PD
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont;
 import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
+import org.apache.xmpbox.XMPMetadata;
+import org.apache.xmpbox.schema.PDFAIdentificationSchema;
+import org.apache.xmpbox.type.BadFieldValueException;
+import org.apache.xmpbox.xml.XmpSerializationException;
+import org.apache.xmpbox.xml.XmpSerializer;
 
 import javax.xml.transform.TransformerException;
 
@@ -91,16 +95,26 @@ public class CreatePDFA
             PDMetadata metadata = new PDMetadata(doc);
             cat.setMetadata(metadata);
 
-            // jempbox version
-            XMPMetadata xmp = new XMPMetadata();
-            XMPSchemaPDFAId pdfaid = new XMPSchemaPDFAId(xmp);
-            xmp.addSchema(pdfaid);
-            pdfaid.setConformance("B");
-            pdfaid.setPart(1);
-            pdfaid.setAbout("");
-            
-            metadata.importXMPMetadata( xmp.asByteArray() );
-            
+            XMPMetadata xmp = XMPMetadata.createXMPMetadata();
+            try
+            {
+                PDFAIdentificationSchema pdfaid = xmp.createAndAddPFAIdentificationSchema();
+                pdfaid.setConformance("B");
+                pdfaid.setPart(1);
+                pdfaid.setAboutAsSimple("PDFBox PDFA sample");
+                XmpSerializer serializer = new XmpSerializer();
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                serializer.serialize(xmp, baos, false);
+                metadata.importXMPMetadata( baos.toByteArray() );
+            }
+            catch(BadFieldValueException badFieldexception)
+            {
+                // can't happen here, as the provided value is valid
+            }
+            catch(XmpSerializationException xmpException)
+            {
+                System.err.println(xmpException.getMessage());
+            }
             InputStream colorProfile = CreatePDFA.class.getResourceAsStream("/org/apache/pdfbox/resources/pdfa/sRGB Color Space Profile.icm");
             // create output intent
             PDOutputIntent oi = new PDOutputIntent(doc, colorProfile); 

Modified: pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddMetadataFromDocInfo.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddMetadataFromDocInfo.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddMetadataFromDocInfo.java (original)
+++ pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddMetadataFromDocInfo.java Sat Aug 30 02:22:51 2014
@@ -16,16 +16,17 @@
  */
 package org.apache.pdfbox.examples.pdmodel;
 
-import org.apache.jempbox.xmp.XMPMetadata;
-import org.apache.jempbox.xmp.XMPSchemaBasic;
-import org.apache.jempbox.xmp.XMPSchemaDublinCore;
-import org.apache.jempbox.xmp.XMPSchemaPDF;
-
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
 import org.apache.pdfbox.pdmodel.PDDocumentInformation;
 import org.apache.pdfbox.pdmodel.common.PDMetadata;
+import org.apache.xmpbox.XMPMetadata;
+import org.apache.xmpbox.schema.AdobePDFSchema;
+import org.apache.xmpbox.schema.DublinCoreSchema;
+import org.apache.xmpbox.schema.XMPBasicSchema;
+import org.apache.xmpbox.xml.XmpSerializer;
 
+import java.io.ByteArrayOutputStream;
 import java.util.GregorianCalendar;
 
 /**
@@ -33,8 +34,8 @@ import java.util.GregorianCalendar;
  *
  * Usage: java org.apache.pdfbox.examples.pdmodel.AddMetadataToDocument &lt;input-pdf&gt; &lt;output-pdf&gt;
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.4 $
+ * @author Ben Litchfield
+ * 
  */
 public class AddMetadataFromDocInfo
 {
@@ -71,26 +72,30 @@ public class AddMetadataFromDocInfo
                 PDDocumentCatalog catalog = document.getDocumentCatalog();
                 PDDocumentInformation info = document.getDocumentInformation();
                 
-                XMPMetadata metadata = new XMPMetadata();
+                XMPMetadata metadata = XMPMetadata.createXMPMetadata();
 
-                XMPSchemaPDF pdfSchema = metadata.addPDFSchema();
+                AdobePDFSchema pdfSchema = metadata.createAndAddAdobePDFSchema();
                 pdfSchema.setKeywords( info.getKeywords() );
                 pdfSchema.setProducer( info.getProducer() );
 
-                XMPSchemaBasic basicSchema = metadata.addBasicSchema();
+                XMPBasicSchema basicSchema = metadata.createAndAddXMPBasicSchema();
                 basicSchema.setModifyDate( info.getModificationDate() );
                 basicSchema.setCreateDate( info.getCreationDate() );
                 basicSchema.setCreatorTool( info.getCreator() );
                 basicSchema.setMetadataDate( new GregorianCalendar() );
 
-                XMPSchemaDublinCore dcSchema = metadata.addDublinCoreSchema();
+                DublinCoreSchema dcSchema = metadata.createAndAddDublinCoreSchema();
                 dcSchema.setTitle( info.getTitle() );
                 dcSchema.addCreator( "PDFBox" );
                 dcSchema.setDescription( info.getSubject() );
 
                 PDMetadata metadataStream = new PDMetadata(document);
-                metadataStream.importXMPMetadata( metadata.asByteArray() );
                 catalog.setMetadata( metadataStream );
+                
+                XmpSerializer serializer = new XmpSerializer();
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                serializer.serialize(metadata, baos, false);
+                metadataStream.importXMPMetadata( baos.toByteArray() );
 
                 document.save( args[1] );
             }

Modified: pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractMetadata.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractMetadata.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractMetadata.java (original)
+++ pdfbox/branches/no-awt/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractMetadata.java Sat Aug 30 02:22:51 2014
@@ -16,11 +16,6 @@
  */
 package org.apache.pdfbox.examples.pdmodel;
 
-import org.apache.jempbox.xmp.XMPMetadata;
-import org.apache.jempbox.xmp.XMPSchemaBasic;
-import org.apache.jempbox.xmp.XMPSchemaDublinCore;
-import org.apache.jempbox.xmp.XMPSchemaPDF;
-
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
 import org.apache.pdfbox.pdmodel.PDDocumentInformation;
@@ -32,24 +27,25 @@ import java.util.Calendar;
 import java.util.Iterator;
 import java.util.List;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
 import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
-import org.w3c.dom.Document;
+import org.apache.xmpbox.XMPMetadata;
+import org.apache.xmpbox.schema.AdobePDFSchema;
+import org.apache.xmpbox.schema.DublinCoreSchema;
+import org.apache.xmpbox.schema.XMPBasicSchema;
+import org.apache.xmpbox.xml.DomXmpParser;
+import org.apache.xmpbox.xml.XmpParsingException;
 
 /**
  * This is an example on how to extract metadata from a PDF document.
- * <p>
+ * 
  * Usage: java org.apache.pdfbox.examples.pdmodel.ExtractDocument &lt;input-pdf&gt;
  *
- * @version $Revision$
  */
 public class ExtractMetadata
 {
     private ExtractMetadata()
     {
-        //utility class
+        // utility class
     }
 
     /**
@@ -59,9 +55,9 @@ public class ExtractMetadata
      *
      * @throws Exception If there is an error parsing the document.
      */
-    public static void main( String[] args ) throws Exception
+    public static void main(String[] args) throws Exception
     {
-        if( args.length != 1 )
+        if (args.length != 1)
         {
             usage();
             System.exit(1);
@@ -72,68 +68,75 @@ public class ExtractMetadata
 
             try
             {
-                document = PDDocument.load( args[0] );
-                if (document.isEncrypted()) 
+                document = PDDocument.load(args[0]);
+                if (document.isEncrypted())
                 {
                     try
                     {
                         StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
                         document.openProtection(sdm);
                     }
-                    catch( InvalidPasswordException e )
+                    catch (InvalidPasswordException e)
                     {
-                        System.err.println( "Error: The document is encrypted." );
+                        System.err.println("Error: The document is encrypted.");
                     }
                 }
                 PDDocumentCatalog catalog = document.getDocumentCatalog();
                 PDMetadata meta = catalog.getMetadata();
-                if ( meta != null)
+                if (meta != null)
                 {
-                	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-                    DocumentBuilder documentBuilder = dbf.newDocumentBuilder();
-                	Document xmpDocument = documentBuilder.parse(meta.createInputStream());
-                    XMPMetadata metadata = new XMPMetadata(xmpDocument);
-    
-                    XMPSchemaDublinCore dc = metadata.getDublinCoreSchema();
-                    if (dc != null)
-                    {
-                        display("Title:", dc.getTitle());
-                        display("Description:", dc.getDescription());
-                        list("Creators: ", dc.getCreators());
-                        list("Dates:", dc.getDates());
-                        list("Subjects:", dc.getSubjects());
-                    }
-    
-                    XMPSchemaPDF pdf = metadata.getPDFSchema();
-                    if (pdf != null)
+                    DomXmpParser xmpParser = new DomXmpParser();
+                    try
                     {
-                        display("Keywords:", pdf.getKeywords());
-                        display("PDF Version:", pdf.getPDFVersion());
-                        display("PDF Producer:", pdf.getProducer());
+                        XMPMetadata metadata = xmpParser.parse(meta.createInputStream());
+
+                        DublinCoreSchema dc = metadata.getDublinCoreSchema();
+                        if (dc != null)
+                        {
+                            display("Title:", dc.getTitle());
+                            display("Description:", dc.getDescription());
+                            listString("Creators: ", dc.getCreators());
+                            listCalendar("Dates:", dc.getDates());
+                            listString("Subjects:", dc.getSubjects());
+                        }
+
+                        AdobePDFSchema pdf = metadata.getAdobePDFSchema();
+                        if (pdf != null)
+                        {
+                            display("Keywords:", pdf.getKeywords());
+                            display("PDF Version:", pdf.getPDFVersion());
+                            display("PDF Producer:", pdf.getProducer());
+                        }
+
+                        XMPBasicSchema basic = metadata.getXMPBasicSchema();
+                        if (basic != null)
+                        {
+                            display("Create Date:", basic.getCreateDate());
+                            display("Modify Date:", basic.getModifyDate());
+                            display("Creator Tool:", basic.getCreatorTool());
+                        }
                     }
-    
-                    XMPSchemaBasic basic = metadata.getBasicSchema();
-                    if (basic != null)
+                    catch (XmpParsingException e)
                     {
-                        display("Create Date:", basic.getCreateDate());
-                        display("Modify Date:", basic.getModifyDate());
-                        display("Creator Tool:", basic.getCreatorTool());
+                        System.err.println("An error ouccred when parsing the meta data: "
+                                + e.getMessage());
                     }
                 }
                 else
                 {
-                    // The pdf doesn't contain any metadata, try to use the document information instead
+                    // The pdf doesn't contain any metadata, try to use the
+                    // document information instead
                     PDDocumentInformation information = document.getDocumentInformation();
-                    if ( information != null)
+                    if (information != null)
                     {
                         showDocumentInformation(information);
                     }
                 }
-                
+
             }
             finally
             {
-                if( document != null )
+                if (document != null)
                 {
                     document.close();
                 }
@@ -149,19 +152,34 @@ public class ExtractMetadata
         display("Creator:", information.getCreator());
         display("Producer:", information.getProducer());
     }
-    
-    private static void list(String title, List list)
+
+    private static void listString(String title, List<String> list)
+    {
+        if (list == null)
+        {
+            return;
+        }
+        System.out.println(title);
+        Iterator<String> iter = list.iterator();
+        while (iter.hasNext())
+        {
+            String string = iter.next();
+            System.out.println("  " + string);
+        }
+    }
+
+    private static void listCalendar(String title, List<Calendar> list)
     {
         if (list == null)
         {
             return;
         }
         System.out.println(title);
-        Iterator iter = list.iterator();
+        Iterator<Calendar> iter = list.iterator();
         while (iter.hasNext())
         {
-            Object o = iter.next();
-            System.out.println("  " + format(o));
+            Calendar calendar = iter.next();
+            System.out.println("  " + format(calendar));
         }
     }
 
@@ -169,7 +187,7 @@ public class ExtractMetadata
     {
         if (o instanceof Calendar)
         {
-            Calendar cal = (Calendar)o;
+            Calendar cal = (Calendar) o;
             return DateFormat.getDateInstance().format(cal.getTime());
         }
         else
@@ -191,6 +209,6 @@ public class ExtractMetadata
      */
     private static void usage()
     {
-        System.err.println( "Usage: java " + ExtractMetadata.class.getName() + " <input-pdf>" );
+        System.err.println("Usage: java " + ExtractMetadata.class.getName() + " <input-pdf>");
     }
 }

Modified: pdfbox/branches/no-awt/pdfbox/build.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/build.xml?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/build.xml (original)
+++ pdfbox/branches/no-awt/pdfbox/build.xml Sat Aug 30 02:22:51 2014
@@ -49,16 +49,6 @@
     <property name="fontbox.test.dir" value="../${fontbox.project.name}/src/test/java" />
     <property name="fontbox.testfiles.dir" value="../${fontbox.project.name}/src/test/resources" />
 
-    <!-- jempbox -->
-    <property name="jempbox.project.name" value="jempbox"/>
-    <property name="jempbox.release.name" value="${jempbox.project.name}-${project.version}" />
-    <property name="jempbox.src.dir" value="../${jempbox.project.name}/src/main/java" />
-    <property name="jempbox.target.dir" value="../${jempbox.project.name}/target" />
-    <property name="jempbox.jar" value="${jempbox.target.dir}/${jempbox.release.name}.jar" />
-    <property name="jempbox.dest.dir" value="${jempbox.target.dir}/classes" />
-    <property name="jempbox.test.dir" value="../${jempbox.project.name}/src/test/java" />
-    <property name="jempbox.testfiles.dir" value="../${jempbox.project.name}/src/test/resources" />
-
     <property name="maven.repo1" value="http://repo1.maven.org/maven2" />
     <property name="maven.repo2" value="http://repo2.maven.org/maven2" />
 
@@ -99,7 +89,6 @@
         <pathelement path="${logging.jar}" />
         <pathelement path="${junit.jar}" />
         <pathelement path="${fontbox.jar}" />
-        <pathelement path="${jempbox.jar}" />
         <pathelement path="${pdfbox.dest.dir}" />
         <pathelement path="${pdfbox.resources.dir}" />
     </path>
@@ -111,13 +100,6 @@
         <pathelement path="${fontbox.resources.dir}" />
     </path>
 
-    <path id="jempbox.build.classpath">
-        <pathelement path="${logging.jar}" />
-        <pathelement path="${junit.jar}" />
-        <pathelement path="${jempbox.dest.dir}" />
-        <pathelement path="${jempbox.resources.dir}" />
-    </path>
-
     <target name="pdfbox.clean" description="Remove all generated files">
         <delete dir="${pdfbox.target.dir}"/>
         <delete dir="${bin.dir}"/>
@@ -129,10 +111,6 @@
         <delete dir="${fontbox.target.dir}"/>
     </target>
 
-    <target name="jempbox.clean" description="Remove all generated files">
-        <delete dir="${jempbox.target.dir}"/>
-    </target>
-
     <target name="pdfbox.init">
         <mkdir dir="${pdfbox.dest.dir}"/>
         <mkdir dir="${bin.dir}" />
@@ -146,11 +124,7 @@
         <mkdir dir="${fontbox.dest.dir}"/>
     </target>
 
-    <target name="jempbox.init">
-        <mkdir dir="${jempbox.dest.dir}"/>
-    </target>
-
-    <target name="pdfbox.compile" depends="fontbox.package,jempbox.package,pdfbox.init"
+    <target name="pdfbox.compile" depends="fontbox.package,pdfbox.init"
             description="Compile Java source files">
         <!-- required encoding flag to be able to build using ibm-jdk on redhat ES-->
         <javac srcdir="${pdfbox.src.dir}" destdir="${pdfbox.dest.dir}"
@@ -172,17 +146,6 @@
                classpathref="fontbox.build.classpath" encoding="ISO-8859-1"/>
     </target>
 
-    <target name="jempbox.compile" depends="jempbox.init"
-            description="Compile Java source files">
-        <!-- required encoding flag to be able to build using ibm-jdk on redhat ES-->
-        <javac srcdir="${jempbox.src.dir}" destdir="${jempbox.dest.dir}"
-               target="1.6" source="1.6" debug="on" deprecation="on"
-               classpathref="jempbox.build.classpath" encoding="ISO-8859-1"/>
-        <javac srcdir="${jempbox.test.dir}" destdir="${jempbox.dest.dir}"
-               target="1.6" source="1.6" debug="on" deprecation="on"
-               classpathref="jempbox.build.classpath" encoding="ISO-8859-1"/>
-    </target>
-
     <target name="test" depends="testextract,test-junit,testimage" description="Run all the junit tests"/>
 
     <target name="testextract" depends="clean,pdfbox.compile" description="Test text extraction">
@@ -201,7 +164,6 @@
                 <pathelement path="${pdfbox.dest.dir}"/>
                 <pathelement path="${pdfbox.resources.dir}" />
                 <pathelement path="${fontbox.dest.dir}"/>
-                <pathelement path="${jempbox.dest.dir}"/>
             </classpath>
             <formatter usefile="false" type="plain" />
             <test name="org.apache.pdfbox.util.TestTextStripper" />
@@ -225,7 +187,6 @@
                 <pathelement path="${pdfbox.dest.dir}"/>
                 <pathelement path="${pdfbox.resources.dir}" />
                 <pathelement path="${fontbox.dest.dir}"/>
-                <pathelement path="${jempbox.dest.dir}"/>
             </classpath>
             <formatter usefile="false" type="plain" />
             <test name="org.apache.pdfbox.util.TestPDFToImage" />
@@ -245,7 +206,6 @@
                 <pathelement path="${pdfbox.dest.dir}"/>
                 <pathelement path="${pdfbox.resources.dir}" />
                 <pathelement path="${fontbox.dest.dir}"/>
-                <pathelement path="${jempbox.dest.dir}"/>
             </classpath>
             <formatter usefile="false" type="plain" />
             <test name="org.apache.pdfbox.TestAll" />
@@ -296,17 +256,6 @@
         </antcall>
     </target>
 
-    <target name="get.externallibs.jempbox">
-        <antcall target="downloadfile">
-            <param name="sourcefile" value="${junit.url}"/>
-            <param name="destfile" value="${junit.jar}"/>
-        </antcall>
-        <antcall target="downloadfile">
-            <param name="sourcefile" value="${logging.url}"/>
-            <param name="destfile" value="${logging.jar}"/>
-        </antcall>
-    </target>
-
     <target name="pdfbox.package" depends="get.externallibs.pdfbox,pdfbox.compile" description="Package pdfbox into a jar file">
         <propertyfile file="${pdfbox.resources.dir}/org/apache/pdfbox/resources/pdfbox.version">
             <entry  key="pdfbox.version" value="${pdfbox.release.name}"/>
@@ -340,25 +289,11 @@
         </jar>
     </target>
 
-    <target name="jempbox.package" depends="get.externallibs.jempbox,jempbox.compile" description="Package jempbox into a jar file">
-        <jar jarfile="${jempbox.jar}">
-            <fileset dir="${jempbox.dest.dir}"/>
-            <metainf dir="." includes="*.txt"/>
-            <manifest>
-                <attribute name="Built-By" value="${user.name}"/>
-                <attribute name="Implementation-Title" value="Apache JempBox"/>
-                <attribute name="Implementation-Version" value="${project.version}"/>
-                <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
-                <attribute name="Implementation-URL" value="http://pdfbox.apache.org/"/>
-            </manifest>
-        </jar>
-    </target>
-
     <!-- We use Maven to create the release packages. Keep this target for -->
     <!-- now for backwards compatibility with old build scripts and habits -->
     <target name="dist" depends="pdfbox.clean,pdfbox.package,build.NET"/>
 
-    <target name="clean" depends="fontbox.clean,jempbox.clean,pdfbox.clean"/>
+    <target name="clean" depends="fontbox.clean,pdfbox.clean"/>
 
     <target name="checkForIKVM">
         <condition property="IKVMAvailable">
@@ -447,22 +382,6 @@
             <arg value="-out:${bin.dir}\${fontbox.release.name}.dll" />
             <arg value="${fontbox.jar}" />
         </exec>
-        <echo>Building JempBox</echo>
-        <exec executable="${ikvmc}">
-            <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Util.dll" />
-            <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Charsets.dll" />
-            <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Text.dll" />
-            <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Core.dll" />
-            <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Media.dll" />
-            <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Misc.dll" />
-            <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Security.dll" />
-            <arg value="-reference:bin/junit.dll" />
-            <arg value="-target:library" />
-            <arg value="-compressresources" />
-            <arg value="-version:${project.version}.0" />
-            <arg value="-out:${bin.dir}\${jempbox.release.name}.dll" />
-            <arg value="${jempbox.jar}" />
-        </exec>
         <echo>Building Commons Logging</echo>
         <exec executable="${ikvmc}">
             <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Util.dll" />
@@ -491,7 +410,6 @@
             <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.Security.dll" />
             <arg value="-reference:${ikvm.dir}/bin/IKVM.OpenJDK.SwingAWT.dll" />
             <arg value="-reference:bin/${fontbox.release.name}.dll" />
-            <arg value="-reference:bin/${jempbox.release.name}.dll" />
             <arg value="-reference:bin/${bcprov.name}.dll" />
             <arg value="-reference:bin/${bcmail.name}.dll" />
             <arg value="-reference:bin/junit.dll" />

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java Sat Aug 30 02:22:51 2014
@@ -431,6 +431,7 @@ public final class COSName extends COSBa
     public static final COSName T = new COSName("T");
     public static final COSName TARGET = new COSName("Target");
     public static final COSName THREADS = new COSName("Threads");
+    public static final COSName TI = new COSName("TI");
     public static final COSName TILING_TYPE = new COSName("TilingType");
     public static final COSName TIME_STAMP = new COSName("TimeStamp");
     public static final COSName TITLE = new COSName("Title");

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java Sat Aug 30 02:22:51 2014
@@ -479,12 +479,9 @@ public class COSStream extends COSDictio
      */
     public OutputStream createFilteredStream( COSBase expectedLength ) throws IOException
     {
-        IOUtils.closeQuietly(unFilteredStream);
-        unFilteredStream = null;
-        IOUtils.closeQuietly(filteredStream);
-        filteredStream = new RandomAccessFileOutputStream( file );
-        filteredStream.setExpectedLength( expectedLength );
-        return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
+        OutputStream out = createFilteredStream();
+        filteredStream.setExpectedLength(expectedLength);
+        return out;
     }
 
     /**
@@ -496,6 +493,11 @@ public class COSStream extends COSDictio
      */
     public void setFilters(COSBase filters) throws IOException
     {
+        if (unFilteredStream == null)
+        {
+            // don't lose stream contents
+            doDecode();
+        }
         setItem(COSName.FILTER, filters);
         // kill cached filtered streams
         IOUtils.closeQuietly(filteredStream);

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFileOutputStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFileOutputStream.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFileOutputStream.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFileOutputStream.java Sat Aug 30 02:22:51 2014
@@ -75,12 +75,14 @@ public class RandomAccessFileOutputStrea
     }
 
     /**
-     * The number of bytes written to the stream.
+     * The number of bytes written or expected in the stream.
      *
-     * @return The number of bytes read to the stream.
+     * @return The number of bytes written or expected in the stream.
      */
     public long getLength()
     {
+        //FIXME this is really dangerous, as it returns a wrong value if
+        // the actual length isn't the expected length
         long length = -1;
         if( expectedLength instanceof COSNumber )
         {

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java Sat Aug 30 02:22:51 2014
@@ -566,7 +566,7 @@ public abstract class BaseParser
                         }
                         // close and create new filtered stream
                         IOUtils.closeQuietly(out);
-                        out = stream.createFilteredStream( streamLength );
+                        out = stream.createFilteredStream();
                         // scan until we find endstream:
                         readUntilEndStream( new EndstreamOutputStream(out) );
                     }
@@ -995,7 +995,7 @@ public abstract class BaseParser
      *
      * @throws IOException If there is an error reading from the stream.
      */
-    private final COSString parseCOSHexString() throws IOException
+    private COSString parseCOSHexString() throws IOException
     {
         final StringBuilder sBuf = new StringBuilder();
         while( true )

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java Sat Aug 30 02:22:51 2014
@@ -117,8 +117,8 @@ public class NonSequentialPDFParser exte
      */
     protected SecurityHandler securityHandler = null;
 
-    private String keyStoreFilename = null;
-    private String alias = null;
+    private final String keyStoreFilename = null;
+    private final String alias = null;
     private String password = "";
     private int readTrailBytes = DEFAULT_TRAIL_BYTECOUNT; // how many trailing
                                                           // bytes to read for
@@ -129,7 +129,7 @@ public class NonSequentialPDFParser exte
      * needed; cons: some information of catalog might not be available (e.g. outline). Catalog parsing without pages is
      * not an option since a number of entries will also refer to page objects (like OpenAction).
      */
-    private boolean parseMinimalCatalog = "true".equals(System.getProperty(SYSPROP_PARSEMINIMAL));
+    private final boolean parseMinimalCatalog = "true".equals(System.getProperty(SYSPROP_PARSEMINIMAL));
 
     private boolean initialParseDone = false;
     private boolean allPagesParsed = false;
@@ -266,11 +266,10 @@ public class NonSequentialPDFParser exte
      */
     private File createTmpFile(InputStream input) throws IOException
     {
-        File tmpFile = null;
         FileOutputStream fos = null;
         try
         {
-            tmpFile = File.createTempFile(TMP_FILE_PREFIX, ".pdf");
+            File tmpFile = File.createTempFile(TMP_FILE_PREFIX, ".pdf");
             fos = new FileOutputStream(tmpFile);
             IOUtils.copy(input, fos);
             isTmpPDFFile = true;
@@ -520,7 +519,7 @@ public class NonSequentialPDFParser exte
 
     // ------------------------------------------------------------------------
     /** Get current offset in file at which next byte would be read. */
-    private final long getPdfSourceOffset()
+    private long getPdfSourceOffset()
     {
         return pdfSource.getOffset();
     }
@@ -557,7 +556,7 @@ public class NonSequentialPDFParser exte
         // pdfSource.close();
     }
 
-    private final void closeFileStream() throws IOException
+    private void closeFileStream() throws IOException
     {
         if (pdfSource != null)
         {
@@ -985,7 +984,7 @@ public class NonSequentialPDFParser exte
     /**
      * Creates a unique object id using object number and object generation number. (requires object number &lt; 2^31))
      */
-    private final long getObjectId(final COSObject obj)
+    private long getObjectId(final COSObject obj)
     {
         return (obj.getObjectNumber().longValue() << 32) | obj.getGenerationNumber().longValue();
     }
@@ -994,7 +993,7 @@ public class NonSequentialPDFParser exte
      * Adds all from newObjects to toBeParsedList if it is not an COSObject or we didn't add this COSObject already
      * (checked via addedObjects).
      */
-    private final void addNewToList(final Queue<COSBase> toBeParsedList,
+    private void addNewToList(final Queue<COSBase> toBeParsedList,
             final Collection<COSBase> newObjects, final Set<Long> addedObjects)
     {
         for (COSBase newObject : newObjects)
@@ -1102,7 +1101,7 @@ public class NonSequentialPDFParser exte
                         Long fileOffset = xrefTrailerResolver.getXrefTable().get(objKey);
                         // it is allowed that object references point to null,
                         // thus we have to test
-                        if (fileOffset != null)
+                        if (fileOffset != null && fileOffset != 0)
                         {
                             if (fileOffset > 0)
                             {
@@ -1118,7 +1117,7 @@ public class NonSequentialPDFParser exte
                                 if ((fileOffset == null) || (fileOffset <= 0))
                                 {
                                     throw new IOException(
-                                            "Invalid object stream xref object reference: "
+                                            "Invalid object stream xref object reference for key '" + objKey + "': "
                                                     + fileOffset);
                                 }
 
@@ -1561,7 +1560,7 @@ public class NonSequentialPDFParser exte
             }
             if (useReadUntilEnd)
             {
-                out = stream.createFilteredStream(streamLengthObj);
+                out = stream.createFilteredStream();
                 readUntilEndStream(new EndstreamOutputStream(out));
             }
             String endStream = readString();
@@ -1830,7 +1829,7 @@ public class NonSequentialPDFParser exte
             return 0;
         }
         // the offset seems to be wrong -> seek backward to find the object we are looking for
-        long currentOffset = objectOffset;
+        long currentOffset;
         for (int i = 1; i < 20; i++)
         {
             currentOffset = objectOffset - (i * 10);

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java Sat Aug 30 02:22:51 2014
@@ -312,10 +312,10 @@ public class PDFParser extends BaseParse
         // read first line
         String header = readLine();
         // some pdf-documents are broken and the pdf-version is in one of the following lines
-        if ((header.indexOf( PDF_HEADER ) == -1) && (header.indexOf( FDF_HEADER ) == -1))
+        if (!header.contains(PDF_HEADER) && !header.contains(FDF_HEADER))
         {
             header = readLine();
-            while ((header.indexOf( PDF_HEADER ) == -1) && (header.indexOf( FDF_HEADER ) == -1))
+            while (!header.contains(PDF_HEADER) && !header.contains(FDF_HEADER))
             {
                 // if a line starts with a digit, it has to be the first one with data in it
                 if ((header.length() > 0) && (Character.isDigit(header.charAt(0))))
@@ -733,7 +733,17 @@ public class PDFParser extends BaseParse
         {
             return false;
         }
-
+        
+        // check for trailer after xref
+        String str = readString();
+        byte[] b = str.getBytes("ISO-8859-1");
+        pdfSource.unread(b, 0, b.length);
+        if (str.startsWith("trailer"))
+        {
+            LOG.warn("skipping empty xref table");
+            return false;
+        }
+        
         // signal start of new XRef
         xrefTrailerResolver.nextXrefObj( startByteOffset, XRefType.TABLE );
 

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Sat Aug 30 02:22:51 2014
@@ -850,7 +850,6 @@ public class PDDocument implements Close
     {
         StandardDecryptionMaterial m = new StandardDecryptionMaterial(password);
         openProtection(m);
-        document.dereferenceObjectStreams();
     }
 
     /**
@@ -1397,6 +1396,7 @@ public class PDDocument implements Close
             getEncryption().getSecurityHandler().decryptDocument(this, decryptionMaterial);
             document.dereferenceObjectStreams();
             document.setEncryptionDictionary(null);
+            getDocumentCatalog();
         }
         else
         {

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java Sat Aug 30 02:22:51 2014
@@ -252,11 +252,19 @@ public class PDResources implements COSO
                     PDXObject xobject = null;
                     try
                     {
-                        String name = objName.getName() + "#";
-                        COSObject cosObject = (COSObject)dict.getItem(objName);
-                        // add the object number to create an unique identifier
-                        name += cosObject.getObjectNumber().intValue();
-                        xobject = PDXObject.createXObject(cosObject.getObject(), name, this);
+                        String name = objName.getName();
+                        COSBase item = dict.getItem(objName);
+                        if (item instanceof COSObject)
+                        {
+                            COSObject cosObject = (COSObject) item;
+                            // add the object number to create an unique identifier
+                            name += "#" + cosObject.getObjectNumber().intValue();
+                            xobject = PDXObject.createXObject(cosObject.getObject(), name, this);
+                        }
+                        else
+                        {
+                            xobject = PDXObject.createXObject(item, name, this);
+                        }
                     }
                     catch (IOException exception)
                     {

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java Sat Aug 30 02:22:51 2014
@@ -79,7 +79,7 @@ public final class PDAppearanceString
      * @param field the field which you wish to control the appearance of
      * @throws IOException If there is an error creating the appearance.
      */
-    public PDAppearanceString(PDAcroForm theAcroForm, PDVariableText field) throws IOException
+    public PDAppearanceString(PDAcroForm theAcroForm, PDVariableText field)
     {
         acroForm = theAcroForm;
         parent = field;
@@ -90,10 +90,7 @@ public final class PDAppearanceString
             widgets = new ArrayList<COSObjectable>();
             widgets.add( field.getWidget() );
         }
-
         defaultAppearance = getDefaultAppearance();
-
-
     }
 
     /**
@@ -199,7 +196,7 @@ public final class PDAppearanceString
     /**
      * This is the public method for setting the appearance stream.
      *
-     * @param apValue the String value which the apperance shoud represent
+     * @param apValue the String value which the appearance should represent
      *
      * @throws IOException If there is an error creating the stream.
      */
@@ -243,8 +240,8 @@ public final class PDAppearanceString
                     widget.setAppearance( appearance );
                 }
 
-                Map normalAppearance = appearance.getNormalAppearance();
-                PDAppearanceStream appearanceStream = (PDAppearanceStream)normalAppearance.get( "default" );
+                Map<String,PDAppearanceStream> normalAppearance = appearance.getNormalAppearance();
+                PDAppearanceStream appearanceStream = normalAppearance.get( "default" );
                 if( appearanceStream == null )
                 {
                     COSStream cosStream = acroForm.getDocument().getDocument().createCOSStream();
@@ -253,8 +250,8 @@ public final class PDAppearanceString
                     appearance.setNormalAppearance( appearanceStream );
                 }
 
-                List tokens = getStreamTokens( appearanceStream );
-                List daTokens = getStreamTokens( getDefaultAppearance() );
+                List<Object> tokens = getStreamTokens( appearanceStream );
+                List<Object> daTokens = getStreamTokens( getDefaultAppearance() );
                 PDFont pdFont = getFontAndUpdateResources( tokens, appearanceStream );
 
                 if (!containsMarkedContent( tokens ))
@@ -341,7 +338,7 @@ public final class PDAppearanceString
     }
 
     private void insertGeneratedAppearance( PDAnnotationWidget fieldWidget, OutputStream output,
-        PDFont pdFont, List tokens, PDAppearanceStream appearanceStream ) throws IOException
+        PDFont pdFont, List<Object> tokens, PDAppearanceStream appearanceStream ) throws IOException
     {
         PrintWriter printWriter = new PrintWriter( output, true );
         float fontSize = 0.0f;
@@ -409,7 +406,7 @@ public final class PDAppearanceString
         printWriter.flush();
     }
 
-    private PDFont getFontAndUpdateResources( List tokens, PDAppearanceStream appearanceStream ) throws IOException
+    private PDFont getFontAndUpdateResources( List<Object> tokens, PDAppearanceStream appearanceStream ) throws IOException
     {
         PDFont retval = null;
         PDResources streamResources = appearanceStream.getResources();
@@ -467,7 +464,7 @@ public final class PDAppearanceString
      * w in an appearance stream represents the lineWidth.
      * @return the linewidth
      */
-    private float getLineWidth( List tokens )
+    private float getLineWidth( List<Object> tokens )
     {
 
         float retval = 1;
@@ -484,7 +481,7 @@ public final class PDAppearanceString
         return retval;
     }
 
-    private PDRectangle getSmallestDrawnRectangle( PDRectangle boundingBox, List tokens )
+    private PDRectangle getSmallestDrawnRectangle( PDRectangle boundingBox, List<Object> tokens )
     {
         PDRectangle smallest = boundingBox;
         for( int i=0; i<tokens.size(); i++ )
@@ -520,14 +517,13 @@ public final class PDAppearanceString
      *
      * @throws IOException If there is an error getting the font height.
      */
-    private float calculateFontSize( PDFont pdFont, PDRectangle boundingBox, List tokens, List daTokens )
+    private float calculateFontSize( PDFont pdFont, PDRectangle boundingBox, List<Object> tokens, List<Object> daTokens )
         throws IOException
     {
         float fontSize = 0;
         if( daTokens != null )
         {
             //daString looks like   "BMC /Helv 3.4 Tf EMC"
-
             int fontIndex = daTokens.indexOf( Operator.getOperator("Tf") );
             if(fontIndex != -1 )
             {
@@ -576,7 +572,7 @@ public final class PDAppearanceString
      *
      * @throws IOException If there is an error calculating the text position.
      */
-    private String getTextPosition( PDRectangle boundingBox, PDFont pdFont, float fontSize, List tokens )
+    private String getTextPosition( PDRectangle boundingBox, PDFont pdFont, float fontSize, List<Object> tokens )
         throws IOException
     {
         float lineWidth = getLineWidth( tokens );

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java Sat Aug 30 02:22:51 2014
@@ -20,7 +20,6 @@ import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSString;
-
 import org.apache.pdfbox.pdmodel.common.COSArrayList;
 
 import java.util.ArrayList;
@@ -93,4 +92,19 @@ public abstract class PDButton extends P
     {
         getDictionary().setItem(COSName.OPT, COSArrayList.converterToCOSArray( options ) );
     }
+    
+    @Override
+    public Object getDefaultValue()
+    {
+        // Button fields don't support the "DV" entry.
+        return null;
+    }
+
+    @Override
+    public void setDefaultValue(Object value)
+    {
+        // Button fields don't support the "DV" entry.
+        throw new RuntimeException( "Button fields don't support the \"DV\" entry." );
+    }
+
 }

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDCheckbox.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDCheckbox.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDCheckbox.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDCheckbox.java Sat Aug 30 02:22:51 2014
@@ -20,8 +20,6 @@ import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 
-import java.io.IOException;
-
 /**
  * A check box toggles between two states, on and off.
  *
@@ -101,22 +99,6 @@ public final class PDCheckbox extends PD
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public void setValue(String newValue)
-    {
-        getDictionary().setName( COSName.V, newValue );
-        if( newValue == null )
-        {
-            getDictionary().setItem( COSName.AS, COSName.OFF );
-        }
-        else
-        {
-            getDictionary().setName( COSName.AS, newValue );
-        }
-    }
-
-    /**
      * This will get the value of the radio button.
      *
      * @return The value of the radio button.
@@ -151,16 +133,29 @@ public final class PDCheckbox extends PD
         return retval;
     }
 
-    /**
-     * getValue gets the fields value to as a string.
-     *
-     * @return The string value of this field.
-     *
-     * @throws IOException If there is an error getting the value.
-     */
-    public String getValue() throws IOException
+    @Override
+    public COSName getValue()
     {
-        return getDictionary().getNameAsString( COSName.V );
+        return getDictionary().getCOSName( COSName.V );
     }
 
+    @Override
+    public void setValue(Object value)
+    {
+        if (value == null)
+        {
+            getDictionary().removeItem(COSName.V);
+            getDictionary().setItem( COSName.AS, COSName.OFF );
+        }
+        else if (value instanceof COSName)
+        {
+            getDictionary().setItem(COSName.V, (COSName)value);
+            getDictionary().setItem( COSName.AS, (COSName)value);
+        }
+        else
+        {
+            throw new RuntimeException( "The value of a checkbox has to be a name object." );
+        }
+    }
+    
 }

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java Sat Aug 30 02:22:51 2014
@@ -24,17 +24,43 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSString;
 
 /**
- * A choice field contains several text items,
- * one or more of which shall be selected as the field value.
+ * A choice field contains several text items, one or more of which shall be selected as the field value.
+ * 
  * @author sug
  * @author John Hewson
  */
 public abstract class PDChoice extends PDVariableText
 {
+
+    /**
+     * A Ff flag.
+     */
+    public static final int FLAG_COMBO = 1 << 17;
+    /**
+     * A Ff flag.
+     */
+    public static final int FLAG_EDIT = 1 << 18;
+    /**
+     * A Ff flag.
+     */
+    public static final int FLAG_SORT = 1 << 19;
+    /**
+     * A Ff flag.
+     */
+    public static final int FLAG_MULTI_SELECT = 1 << 21;
+    /**
+     * A Ff flag.
+     */
+    public static final int FLAG_DO_NOT_SPELL_CHECK = 1 << 22;
+    /**
+     * A Ff flag.
+     */
+    public static final int FLAG_COMMIT_ON_SEL_CHANGE = 1 << 26;
+
     /**
      * Constructor.
      * 
-     * @param theAcroForm The form that this field is part of.
+     * @param acroForm The form that this field is part of.
      * @param field the PDF object to represent as a field.
      * @param parentNode the parent node of the node to be created
      */
@@ -43,12 +69,168 @@ public abstract class PDChoice extends P
         super(acroForm, field, parentNode);
     }
 
+    /**
+     * This will get the option values "Opt".
+     *
+     * @return COSArray containing all options.
+     */
+    public COSArray getOptions()
+    {
+        return (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
+    }
+
+    /**
+     * This will set the options.
+     *
+     * @param values COSArray containing all possible options.
+     */
+    public void setOptions(COSArray values)
+    {
+        if (values != null)
+        {
+            getDictionary().setItem(COSName.OPT, values);
+        }
+        else
+        {
+            getDictionary().removeItem(COSName.OPT);
+        }
+    }
+
+    /**
+     * This will get the indices of the selected options "I".
+     *
+     * @return COSArray containing the indices of all selected options.
+     */
+    public COSArray getSelectedOptions()
+    {
+        return (COSArray) getDictionary().getDictionaryObject(COSName.I);
+    }
+
+    /**
+     * This will set the indices of the selected options "I".
+     *
+     * @param values COSArray containing the indices of all selected options.
+     */
+    public void setSelectedOptions(COSArray values)
+    {
+        if (values != null)
+        {
+            getDictionary().setItem(COSName.I, values);
+        }
+        else
+        {
+            getDictionary().removeItem(COSName.I);
+        }
+    }
+
+    /**
+     * Determines if Sort is set.
+     * 
+     * @return true if the options are sorted.
+     */
+    public boolean isSort()
+    {
+        return getDictionary().getFlag( COSName.FF, FLAG_SORT );
+    }
+
+    /**
+     * Set the Sort bit.
+     *
+     * @param sort The value for Sort.
+     */
+    public void setSort( boolean sort )
+    {
+        getDictionary().setFlag( COSName.FF, FLAG_SORT, sort );
+    }
+
+    /**
+     * Determines if MultiSelect is set.
+     * 
+     * @return true if multi select is allowed.
+     */
+    public boolean isMultiSelect()
+    {
+        return getDictionary().getFlag( COSName.FF, FLAG_MULTI_SELECT );
+    }
+
+    /**
+     * Set the MultiSelect bit.
+     *
+     * @param multiSelect The value for MultiSelect.
+     */
+    public void setMultiSelect( boolean multiSelect )
+    {
+        getDictionary().setFlag( COSName.FF, FLAG_MULTI_SELECT, multiSelect );
+    }
+
+    /**
+     * Determines if DoNotSpellCheck is set.
+     * 
+     * @return true if spell checker is disabled.
+     */
+    public boolean isDoNotSpellCheck()
+    {
+        return getDictionary().getFlag( COSName.FF, FLAG_DO_NOT_SPELL_CHECK );
+    }
+
+    /**
+     * Set the DoNotSpellCheck bit.
+     *
+     * @param doNotSpellCheck The value for DoNotSpellCheck.
+     */
+    public void setDoNotSpellCheck( boolean doNotSpellCheck )
+    {
+        getDictionary().setFlag( COSName.FF, FLAG_DO_NOT_SPELL_CHECK, doNotSpellCheck );
+    }
+
+    /**
+     * Determines if CommitOnSelChange is set.
+     * 
+     * @return true if value shall be committed as soon as a selection is made.
+     */
+    public boolean isCommitOnSelChange()
+    {
+        return getDictionary().getFlag( COSName.FF, FLAG_COMMIT_ON_SEL_CHANGE );
+    }
+
+    /**
+     * Set the CommitOnSelChange bit.
+     *
+     * @param commitOnSelChange The value for CommitOnSelChange.
+     */
+    public void setCommitOnSelChange( boolean commitOnSelChange )
+    {
+        getDictionary().setFlag( COSName.FF, FLAG_COMMIT_ON_SEL_CHANGE, commitOnSelChange );
+    }
+
+    /**
+     * getValue gets the value of the "V" entry.
+     * 
+     * @return The value of this entry.
+     * 
+     */
+    @Override
+    public COSArray getValue()
+    {
+        COSBase value = getDictionary().getDictionaryObject( COSName.V);
+        if (value instanceof COSString)
+        {
+            COSArray array = new COSArray();
+            array.add(value);
+            return array;
+        }
+        else if (value instanceof COSArray)
+        {
+            return (COSArray)value;
+        }
+        return null;
+    }
+
     // returns the "Opt" index for the given string
     protected int getSelectedIndex(String optionValue)
     {
         int indexSelected = -1;
-        COSArray options = (COSArray)getDictionary().getDictionaryObject(COSName.OPT);
-
+        COSArray options = getOptions();
         // YXJ: Changed the order of the loops. Acrobat produces PDF's
         // where sometimes there is 1 string and the rest arrays.
         // This code works either way.
@@ -57,34 +239,30 @@ public abstract class PDChoice extends P
             COSBase option = options.getObject(i);
             if (option instanceof COSArray)
             {
-                COSArray keyValuePair = (COSArray)option;
-                COSString key = (COSString)keyValuePair.getObject(0);
-                COSString value = (COSString)keyValuePair.getObject(1);
+                COSArray keyValuePair = (COSArray) option;
+                COSString key = (COSString) keyValuePair.getObject(0);
+                COSString value = (COSString) keyValuePair.getObject(1);
                 if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
                 {
-                    // have the parent draw the appearance stream with the value
-                    // but then use the key as the V entry
-                    getDictionary().setItem(COSName.V, key);
                     indexSelected = i;
                 }
             }
             else
             {
-                COSString value = (COSString)option;
+                COSString value = (COSString) option;
                 if (optionValue.equals(value.getString()))
                 {
                     indexSelected = i;
                 }
             }
         }
-
         return indexSelected;
     }
 
     // implements "MultiSelect"
     protected void selectMultiple(int selectedIndex)
     {
-        COSArray indexArray = (COSArray)getDictionary().getDictionaryObject(COSName.I);
+        COSArray indexArray = getSelectedOptions();
         if (indexArray != null)
         {
             indexArray.clear();

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDComboBox.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDComboBox.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDComboBox.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDComboBox.java Sat Aug 30 02:22:51 2014
@@ -16,9 +16,10 @@
  */
 package org.apache.pdfbox.pdmodel.interactive.form;
 
+import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
-
-import java.io.IOException;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSString;
 
 /**
  * A combo box consisting of a drop-down list.
@@ -27,7 +28,6 @@ import java.io.IOException;
  */
 public final class PDComboBox extends PDChoice
 {
-    private static final int FLAG_EDIT = 0x40000;
 
     /**
      * Constructor.
@@ -41,18 +41,52 @@ public final class PDComboBox extends PD
         super(acroForm, field, parentNode);
     }
 
+    /**
+     * setValue sets the entry "V" to the given value.
+     * 
+     * @param value the value
+     * 
+     */
     @Override
-    public void setValue(String optionValue) throws IOException
+    public void setValue(Object value)
     {
-        boolean isEditable = (getFieldFlags() & FLAG_EDIT) != 0;
-        int index = getSelectedIndex(optionValue);
-
-        if (index == -1 && !isEditable)
+        // TODO move to superclass PDCoice??
+        if ((getFieldFlags() & FLAG_EDIT) != 0)
         {
-            throw new IllegalArgumentException("Combo box does not contain the given value");
+            throw new IllegalArgumentException("The combo box isn't editable.");
         }
-
-        super.setValue(optionValue);
-        selectMultiple(index);
+        if (value != null)
+        {
+            if (value instanceof String)
+            {
+                getDictionary().setString(COSName.V, (String)value);
+                int index = getSelectedIndex((String)value);
+                if (index == -1)
+                {
+                    throw new IllegalArgumentException("The combo box does not contain the given value.");
+                }
+                selectMultiple(index);
+            }
+            if (value instanceof String[])
+            {
+                if (!isMultiSelect())
+                {
+                    throw new IllegalArgumentException("The combo box does allow multiple selection.");
+                }
+                String[] stringValues = (String[])value;
+                COSArray stringArray = new COSArray();
+                for (int i =0; i<stringValues.length;i++)
+                {
+                    stringArray.add(new COSString(stringValues[i]));
+                }
+                getDictionary().setItem(COSName.V, stringArray);
+            }
+        }
+        else
+        {
+            getDictionary().removeItem(COSName.V);
+        }
+        // TODO create/update appearance
     }
+
 }

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeNode.java Sat Aug 30 02:22:51 2014
@@ -107,24 +107,37 @@ public abstract class PDFieldTreeNode im
      */
     public abstract String getFieldType();
 
+    /**
+     * getValue gets the value of the "V" entry.
+     * 
+     * @return The value of this entry.
+     * 
+     */
+    public abstract Object getValue();
+
+    /**
+     * setValue sets the entry "V" to the given value.
+     * 
+     * @param value the value
+     * 
+     */
+    public abstract void setValue(Object value);
 
     /**
-     * setValue sets the fields value to a given string.
+     * getDefaultValue gets the value of the "DV" entry.
      * 
-     * @param value the string value
+     * @return The value of this field.
      * 
-     * @throws IOException If there is an error creating the appearance stream.
      */
-    public abstract void setValue(String value) throws IOException;
+    public abstract Object getDefaultValue();
 
     /**
-     * getValue gets the fields value to as a string.
+     * setDefaultValue sets the entry "DV" to the given value.
      * 
-     * @return The string value of this field.
+     * @param value the value
      * 
-     * @throws IOException If there is an error getting the value.
      */
-    public abstract String getValue() throws IOException;
+    public abstract void setDefaultValue(Object value);
 
     /**
      * sets the field to be read-only.
@@ -553,7 +566,7 @@ public abstract class PDFieldTreeNode im
      */
     public String getFullyQualifiedName() throws IOException
     {
-        String parentName = parent.getFullyQualifiedName();
+        String parentName = getParent() != null ? getParent().getFullyQualifiedName() : null;
         String finalName = getPartialName();
         if (parentName != null)
         {

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDListBox.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDListBox.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDListBox.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDListBox.java Sat Aug 30 02:22:51 2014
@@ -19,12 +19,11 @@ package org.apache.pdfbox.pdmodel.intera
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
-
-import java.io.IOException;
+import org.apache.pdfbox.cos.COSString;
 
 /**
- * A scrollable list box.
- * Contains several text items, one or more of which shall be selected as the field value.
+ * A scrollable list box. Contains several text items, one or more of which shall be selected as the field value.
+ * 
  * @author John Hewson
  */
 public final class PDListBox extends PDChoice
@@ -32,7 +31,7 @@ public final class PDListBox extends PDC
     /**
      * Constructor.
      * 
-     * @param theAcroForm The form that this field is part of.
+     * @param acroForm The form that this field is part of.
      * @param field the PDF object to represent as a field.
      * @param parentNode the parent node of the node to be created
      */
@@ -41,24 +40,80 @@ public final class PDListBox extends PDC
         super(acroForm, field, parentNode);
     }
 
+    /**
+     * setValue sets the entry "V" to the given value.
+     * 
+     * @param value the value
+     * 
+     */
     @Override
-    public void setValue(String optionValue) throws IOException
+    public void setValue(Object value)
     {
-        COSArray options = (COSArray)getDictionary().getDictionaryObject(COSName.OPT);
-        if(options.size() == 0)
+        // TODO move to superclass PDCoice??
+        if ((getFieldFlags() & FLAG_EDIT) != 0)
+        {
+            throw new IllegalArgumentException("The list box isn't editable.");
+        }
+        if (value != null)
+        {
+            if (value instanceof String)
+            {
+                getDictionary().setString(COSName.V, (String)value);
+                int index = getSelectedIndex((String) value);
+                if (index == -1)
+                {
+                    throw new IllegalArgumentException(
+                            "The list box does not contain the given value.");
+                }
+                selectMultiple(index);
+            }
+            if (value instanceof String[])
+            {
+                if (!isMultiSelect())
+                {
+                    throw new IllegalArgumentException("The list box does allow multiple selection.");
+                }
+                String[] stringValues = (String[])value;
+                COSArray stringArray = new COSArray();
+                for (int i =0; i<stringValues.length;i++)
+                {
+                    stringArray.add(new COSString(stringValues[i]));
+                }
+                getDictionary().setItem(COSName.V, stringArray);
+            }
+        }
+        else
         {
-            throw new IllegalArgumentException("List box does not contain the given value");
+            getDictionary().removeItem(COSName.V);
         }
+        // TODO create/update appearance
+    }
+
+    /**
+     * This will get the top index "TI" value.
+     *
+     * @return the top index, default value 0.
+     */
+    public int getTopIndex()
+    {
+        return getDictionary().getInt(COSName.TI, 0);
+    }
 
-        int index = getSelectedIndex(optionValue);
-        if (index == -1)
+    /**
+     * This will set top index "TI" value.
+     *
+     * @param topIndex the value for the top index, null will remove the value.
+     */
+    public void setTopIndex(Integer topIndex)
+    {
+        if (topIndex != null)
         {
-            throw new IllegalArgumentException("List box does not contain the given value");
+            getDictionary().setInt(COSName.TI, topIndex);
         }
         else
         {
-            super.setValue(optionValue);
-            selectMultiple(index);
+            getDictionary().removeItem(COSName.TI);
         }
     }
+
 }

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDNonTerminalField.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDNonTerminalField.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDNonTerminalField.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDNonTerminalField.java Sat Aug 30 02:22:51 2014
@@ -16,8 +16,6 @@
  */
 package org.apache.pdfbox.pdmodel.interactive.form;
 
-import java.io.IOException;
-
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSName;
@@ -78,16 +76,31 @@ public class PDNonTerminalField extends 
     }
 
     @Override
-    public void setValue(String value) throws IOException
+    public Object getValue()
     {
-        // non terminal fields don't have a value
+        // Nonterminal fields don't support the "V" entry.
+        return null;
     }
-
+    
+    @Override
+    public void setValue(Object value)
+    {
+        // Nonterminal fields don't support the "V" entry.
+        throw new RuntimeException( "Nonterminal fields don't support the \"V\" entry." );
+    }
+    
     @Override
-    public String getValue() throws IOException
+    public Object getDefaultValue()
     {
-        // non terminal fields don't have a value
+        // Nonterminal fields don't support the "DV" entry.
         return null;
     }
-
+    
+    @Override
+    public void setDefaultValue(Object value)
+    {
+        // Nonterminal fields don't support the "DV" entry.
+        throw new RuntimeException( "Nonterminal fields don't support the \"DV\" entry." );
+    }
+    
 }

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java?rev=1621410&r1=1621409&r2=1621410&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java Sat Aug 30 02:22:51 2014
@@ -17,10 +17,6 @@
 package org.apache.pdfbox.pdmodel.interactive.form;
 
 import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.cos.COSString;
-
-import java.io.IOException;
 
 /**
  * A pushbutton is a purely interactive control that responds immediately to user
@@ -43,29 +39,18 @@ public class PDPushButton extends PDButt
         super(theAcroForm, field, parentNode);
     }
 
-    /**
-     * @see PDField#setValue(java.lang.String)
-     *
-     * @param value The new value for the field.
-     *
-     * @throws IOException If there is an error creating the appearance stream.
-     */
-    public void setValue(String value) throws IOException
+    @Override
+    public Object getValue()
     {
-        COSString fieldValue = new COSString(value);
-        getDictionary().setItem( COSName.getPDFName( "V" ), fieldValue );
-        getDictionary().setItem( COSName.getPDFName( "DV" ), fieldValue );
+        // PushButton fields don't support the "V" entry.
+        return null;
     }
 
-    /**
-     * getValue gets the fields value to as a string.
-     *
-     * @return The string value of this field.
-     *
-     * @throws IOException If there is an error getting the value.
-     */
-    public String getValue() throws IOException
+    @Override
+    public void setValue(Object value)
     {
-        return getDictionary().getString( "V" );
+        // PushButton fields don't support the "V" entry.
+        throw new RuntimeException( "PushButton fields don't support the \"V\" entry." );
     }
+
 }