svn commit: r1577735 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java

2014-03-14 Thread tilman
Author: tilman
Date: Fri Mar 14 21:39:06 2014
New Revision: 1577735

URL: http://svn.apache.org/r1577735
Log:
PDFBOX-1969: activate second JPEGFactory test

Modified:

pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java

Modified: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java?rev=1577735&r1=1577734&r2=1577735&view=diff
==
--- 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java
 Fri Mar 14 21:39:06 2014
@@ -75,16 +75,16 @@ public class JPEGFactoryTest extends Tes
 {
 
 //TODO enable this test when JPEGFactory.createFromImage() works
-//PDDocument document = new PDDocument();
-//BufferedImage bim = ImageIO.read(new 
File("src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/jpeg.jpg"));
-//PDImageXObject ximage = JPEGFactory.createFromImage(document, bim);
-//assertNotNull(ximage);
-//assertNotNull(ximage.getCOSStream());
-//assertTrue(ximage.getCOSStream().getFilteredLength() > 0);
-//assertEquals(8, ximage.getBitsPerComponent());
-//assertEquals(344, ximage.getWidth());
-//assertEquals(287, ximage.getHeight());
-//assertEquals("jpg", ximage.getSuffix());
+PDDocument document = new PDDocument();
+BufferedImage bim = ImageIO.read(new 
File("src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/jpeg.jpg"));
+PDImageXObject ximage = JPEGFactory.createFromImage(document, bim);
+assertNotNull(ximage);
+assertNotNull(ximage.getCOSStream());
+assertTrue(ximage.getCOSStream().getFilteredLength() > 0);
+assertEquals(8, ximage.getBitsPerComponent());
+assertEquals(344, ximage.getWidth());
+assertEquals(287, ximage.getHeight());
+assertEquals("jpg", ximage.getSuffix());
 
 //TODO shouldn't ximage.getImage() return a real image?
 //assertNotNull(ximage.getImage());




svn commit: r1577734 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java

2014-03-14 Thread tilman
Author: tilman
Date: Fri Mar 14 21:38:35 2014
New Revision: 1577734

URL: http://svn.apache.org/r1577734
Log:
PDFBOX-1969: fix JPEGFactory bug

Modified:

pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java?rev=1577734&r1=1577733&r2=1577734&view=diff
==
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
 Fri Mar 14 21:38:35 2014
@@ -18,12 +18,12 @@ package org.apache.pdfbox.pdmodel.graphi
 
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Iterator;
 
-import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.filter.MissingImageReaderException;
 import org.apache.pdfbox.io.IOUtils;
@@ -40,6 +40,7 @@ import javax.imageio.metadata.IIOMetadat
 import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
 import javax.imageio.stream.ImageInputStream;
 import javax.imageio.stream.ImageOutputStream;
+import org.apache.pdfbox.cos.COSStream;
 
 /**
  * Factory for creating a PDImageXObject containing a JPEG compressed image.
@@ -170,40 +171,15 @@ public final class JPEGFactory extends I
 {
 return createJPEG(document, image, quality, dpi);
 }
-
-// Creates an Image XObject from a Buffered Image using JAI Image I/O
-private static PDImageXObject createJPEG(PDDocument document, 
BufferedImage image,
- float quality, int dpi) throws 
IOException
+
+private static void encodeImageToJPEGStream(BufferedImage image, float 
quality, int dpi, OutputStream out) 
+throws IOException
 {
-// extract alpha channel (if any)
-BufferedImage awtColor = getColorImage(image);
-BufferedImage awtAlpha = getAlphaImage(image);
-
-// create XObject
-PDImageXObject pdImage = new PDImageXObject(new PDStream(document), 
null);
-
-// add DCT filter
-COSDictionary dict = pdImage.getCOSStream();
-pdImage.getCOSStream().setItem(COSName.FILTER, COSName.DCT_DECODE);
-
-// alpha -> soft mask
-if (awtAlpha != null)
-{
-PDImage xAlpha = JPEGFactory.createFromImage(document, awtAlpha, 
quality);
-dict.setItem(COSName.SMASK, xAlpha);
-}
-
-// set properties (width, height, depth, color space, etc.)
-setPropertiesFromAWT(awtColor, pdImage);
-
 // encode to JPEG
-OutputStream out = null;
 ImageOutputStream ios = null;
 ImageWriter imageWriter = null;
 try
 {
-out = pdImage.getCOSStream().createFilteredStream();
-
 // find JAI writer
 imageWriter = ImageIO.getImageWritersBySuffix("jpeg").next();
 ios = ImageIO.createImageOutputStream(out);
@@ -239,6 +215,36 @@ public final class JPEGFactory extends I
 imageWriter.dispose();
 }
 }
+}
+
+// Creates an Image XObject from a Buffered Image using JAI Image I/O
+private static PDImageXObject createJPEG(PDDocument document, 
BufferedImage image,
+ float quality, int dpi) throws 
IOException
+{
+// extract alpha channel (if any)
+BufferedImage awtColorImage = getColorImage(image);
+BufferedImage awtAlphaImage = getAlphaImage(image);
+
+// create XObject
+ByteArrayOutputStream bos = new ByteArrayOutputStream();
+encodeImageToJPEGStream(image, quality, dpi, bos);
+ByteArrayInputStream byteStream = new 
ByteArrayInputStream(bos.toByteArray());
+PDImageXObject pdImage = new PDImageXObject(new PDStream(document, 
byteStream, true), null);
+
+// add DCT filter
+COSStream dict = pdImage.getCOSStream();
+dict.setItem(COSName.FILTER, COSName.DCT_DECODE);
+
+// alpha -> soft mask
+if (awtAlphaImage != null)
+{
+encodeImageToJPEGStream(awtAlphaImage, quality, dpi, 
dict.createFilteredStream());
+PDImage xAlpha = JPEGFactory.createFromImage(document, 
awtAlphaImage, quality);
+dict.setItem(COSName.SMASK, xAlpha);
+}
+
+// set properties (width, height, depth, color space, etc.)
+setPropertiesFromAWT(awtColorImage, pdImage);
 
 return pdImage;
 }




svn commit: r1577725 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: cos/COSDictionary.java pdmodel/font/PDFontFactory.java pdmodel/font/PDTrueTypeFont.java util/PDFStreamEngine.java

2014-03-14 Thread jahewson
Author: jahewson
Date: Fri Mar 14 21:26:30 2014
New Revision: 1577725

URL: http://svn.apache.org/r1577725
Log:
PDFBOX-1988: assume Font with missing SubType is Type1

Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java

pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java

pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java

pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=1577725&r1=1577724&r2=1577725&view=diff
==
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java 
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java 
Fri Mar 14 21:26:30 2014
@@ -592,7 +592,7 @@ public class COSDictionary extends COSBa
  * @param key The key to the item in the dictionary.
  * @return The COS name.
  */
-public COSName getName( COSName key )
+public COSName getCOSName(COSName key)
 {
 COSBase name = getDictionaryObject( key );
 if( name != null )
@@ -613,7 +613,7 @@ public class COSDictionary extends COSBa
  * @param defaultValue The value to return if the dictionary item is null.
  * @return The COS name.
  */
-public COSName getName( COSName key, COSName defaultValue )
+public COSName getCOSName(COSName key, COSName defaultValue)
 {
 COSBase name = getDictionaryObject( key );
 if( name != null )

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java?rev=1577725&r1=1577724&r2=1577725&view=diff
==
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
 Fri Mar 14 21:26:30 2014
@@ -17,7 +17,6 @@
 package org.apache.pdfbox.pdmodel.font;
 
 import java.io.IOException;
-import java.util.Map;
 
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
@@ -25,101 +24,67 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
- * This will create the correct type of font based on information in the 
dictionary.
- *
- * @author mailto:b...@benlitchfield.com";>Ben Litchfield
- * @version $Revision: 1.6 $
+ * Creates the appropriate font subtype based on information in the dictionary.
+ * @author Ben Litchfield
  */
 public class PDFontFactory
 {
-/**
- * private constructor, should only use static methods in this class.
- */
-private PDFontFactory()
-{
-}
-
-/**
- * Logger instance.
- */
 private static final Log LOG = LogFactory.getLog(PDFontFactory.class);
-
-/**
- * This will create the correct font based on information in the 
dictionary.
- *
- * @param dic The populated dictionary.
- *
- * @param fontCache A Map to cache already created fonts
- *
- * @return The corrent implementation for the font.
- *
- * @throws IOException If the dictionary is not valid.
- * 
- * @deprecated due to some side effects font caching is no longer 
supported, 
- * use {@link #createFont(COSDictionary)} instead
- */
-public static PDFont createFont(COSDictionary dic, Map fontCache) throws 
IOException
+
+private PDFontFactory()
 {
-return createFont(dic);
 }
 
 /**
- * This will create the correct font based on information in the 
dictionary.
+ * Creates a new PDFont instance with the appropriate subclass.
  *
- * @param dic The populated dictionary.
- *
- * @return The corrent implementation for the font.
- *
- * @throws IOException If the dictionary is not valid.
+ * @param dictionary a font dictionary
+ * @return a PDFont instance, based on the SubType entry of the dictionary
+ * @throws IOException
  */
-public static PDFont createFont( COSDictionary dic ) throws IOException
+public static PDFont createFont(COSDictionary dictionary) throws 
IOException
 {
-PDFont retval = null;
-
-COSName type = (COSName)dic.getDictionaryObject( COSName.TYPE );
-if( type != null && !COSName.FONT.equals( type ) )
+COSName type = dictionary.getCOSName(COSName.TYPE, COSName.FONT);
+if (!COSName.FONT.equals(type))
 {
-throw new IOException( "Cannot create font if /Type is not /Font.  
Actual=" +type );
+throw new IOException("

svn commit: r1577728 - in /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox: pdmodel/font/PDFontFactory.java util/PDFStreamEngine.java

2014-03-14 Thread jahewson
Author: jahewson
Date: Fri Mar 14 21:29:23 2014
New Revision: 1577728

URL: http://svn.apache.org/r1577728
Log:
PDFBOX-1988: assume Font with missing SubType is Type1

Modified:

pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java

pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java

Modified: 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java?rev=1577728&r1=1577727&r2=1577728&view=diff
==
--- 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
 (original)
+++ 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
 Fri Mar 14 21:29:23 2014
@@ -117,8 +117,10 @@ public class PDFontFactory
 }
 else
 {
-LOG.warn("Substituting TrueType for unknown font subtype=" + 
subType.getName());
-retval = new PDTrueTypeFont( dic );
+// assuming Type 1 font (see PDFBOX-1988) because it seems that 
Adobe Reader does this
+// however, we may need more sophisticated logic perhaps looking 
at the FontFile
+LOG.warn( "Invalid font subtype '" + subType.getName() + "'" );
+return new PDType1Font( dic );
 }
 return retval;
 }

Modified: 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java?rev=1577728&r1=1577727&r2=1577728&view=diff
==
--- 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java
 (original)
+++ 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java
 Fri Mar 14 21:29:23 2014
@@ -348,18 +348,15 @@ public class PDFStreamEngine
 glyphSpaceToTextSpaceFactor = 1f/fontMatrix.getValue( 0, 0 );
 }
 float spaceWidthText=0;
-if (font != null) // PDFBOX-1946 font might still be null if in applet
+try
 {
-try
-{
-// to avoid crash as described in PDFBOX-614
-// lets see what the space displacement should be
-spaceWidthText = (font.getSpaceWidth() * 
glyphSpaceToTextSpaceFactor);
-}
-catch (Throwable exception)
-{
-LOG.warn(exception, exception);
-}
+// to avoid crash as described in PDFBOX-614
+// lets see what the space displacement should be
+spaceWidthText = (font.getSpaceWidth() * 
glyphSpaceToTextSpaceFactor);
+}
+catch (Throwable exception)
+{
+LOG.warn(exception, exception);
 }
 
 if (spaceWidthText == 0)




svn commit: r1577683 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java

2014-03-14 Thread jahewson
Author: jahewson
Date: Fri Mar 14 19:54:56 2014
New Revision: 1577683

URL: http://svn.apache.org/r1577683
Log:
PDFBOX-1988: add getName to COSDictionary

Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=1577683&r1=1577682&r2=1577683&view=diff
==
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java 
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java 
Fri Mar 14 19:54:56 2014
@@ -585,6 +585,47 @@ public class COSDictionary extends COSBa
 setInt(field, currentFlags);
 }
 
+/**
+ * This is a convenience method that will get the dictionary object that
+ * is expected to be a name. Null is returned if the entry does not exist 
in the dictionary.
+ *
+ * @param key The key to the item in the dictionary.
+ * @return The COS name.
+ */
+public COSName getName( COSName key )
+{
+COSBase name = getDictionaryObject( key );
+if( name != null )
+{
+if ( name instanceof COSName )
+{
+return (COSName) name;
+}
+}
+return null;
+}
+
+/**
+ * This is a convenience method that will get the dictionary object that
+ * is expected to be a name. Default is returned if the entry does not 
exist in the dictionary.
+ *
+ * @param key The key to the item in the dictionary.
+ * @param defaultValue The value to return if the dictionary item is null.
+ * @return The COS name.
+ */
+public COSName getName( COSName key, COSName defaultValue )
+{
+COSBase name = getDictionaryObject( key );
+if( name != null )
+{
+if ( name instanceof COSName )
+{
+return (COSName) name;
+}
+}
+return defaultValue;
+}
+
/**
 * This is a convenience method that will get the dictionary object that
 * is expected to be a name and convert it to a string.  Null is 
returned




svn commit: r1577682 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java

2014-03-14 Thread jahewson
Author: jahewson
Date: Fri Mar 14 19:53:06 2014
New Revision: 1577682

URL: http://svn.apache.org/r1577682
Log:
PDFBOX-1988: clean up COSName, add empty name

Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=1577682&r1=1577681&r2=1577682&view=diff
==
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java 
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java Fri 
Mar 14 19:53:06 2014
@@ -25,1601 +25,433 @@ import java.util.concurrent.ConcurrentHa
 import org.apache.pdfbox.persistence.util.COSHEXTable;
 
 /**
- * This class represents a PDF named object.
- * 
- * @author mailto:b...@benlitchfield.com";>Ben Litchfield
- * 
+ * A PDF named object.
+ * @author Ben Litchfield
  */
 public final class COSName extends COSBase implements Comparable
 {
-/**
- * Note: This is a ConcurrentHashMap because a HashMap must be 
synchronized if accessed by multiple threads.
- */
+// using ConcurrentHashMap because this can be accessed by multiple threads
 private static Map nameMap = new 
ConcurrentHashMap(8192);
 
-/**
- * All common COSName values are stored in a simple HashMap. They are 
already defined as static constants and don't
- * need to be synchronized for multithreaded environments.
- */
+// all common COSName values are stored in this HashMap
+// hey are already defined as static constants and don't need to be 
synchronized
 private static Map commonNameMap = new HashMap();
 
-/**
- * A common COSName value.
- */
+/** The prefix to a PDF name. */
+public static final byte[] NAME_PREFIX = new byte[] { 47 }; // The / 
character
+
+/** The escape character for a name. */
+public static final byte[] NAME_ESCAPE = new byte[] { 35 }; // The # 
character
+
+//
+// IMPORTANT: this list is *alphabetized* and does not need any JavaDoc
+//
+
+// A
 public static final COSName A = new COSName("A");
-/**
- * A common COSName value.
- */
 public static final COSName AA = new COSName("AA");
-/**
- * A common COSName value.
- */
 public static final COSName ACRO_FORM = new COSName("AcroForm");
-/**
- * A common COSName value.
- */
 public static final COSName ACTUAL_TEXT = new COSName("ActualText");
-/**
- * A common COSName value.
- */
+public static final COSName ADBE_PKCS7_DETACHED = new 
COSName("adbe.pkcs7.detached");
+public static final COSName ADBE_PKCS7_SHA1 = new 
COSName("adbe.pkcs7.sha1");
+public static final COSName ADBE_X509_RSA_SHA1 = new 
COSName("adbe.x509.rsa_sha1");
+public static final COSName ADOBE_PPKLITE = new COSName("Adobe.PPKLite");
 public static final COSName AIS = new COSName("AIS");
-/**
- * A common COSName value.
- */
 public static final COSName ALT = new COSName("Alt");
-/**
- * A common COSName value.
- */
 public static final COSName ALTERNATE = new COSName("Alternate");
-/**
- * A common COSName value.
- */
 public static final COSName ANNOT = new COSName("Annot");
-/**
- * A common COSName value.
- */
 public static final COSName ANNOTS = new COSName("Annots");
-/**
- * A common COSName value.
- */
 public static final COSName ANTI_ALIAS = new COSName("AntiAlias");
-/**
- * A common COSName value.
- */
+public static final COSName AP = new COSName("AP");
 public static final COSName AP_REF = new COSName("APRef");
-/**
- * A common COSName value.
- */
-public static final COSName ARTIFACT = new COSName("Artifact");
-/**
- * A common COSName value.
- */
+public static final COSName APP = new COSName("App");
 public static final COSName ART_BOX = new COSName("ArtBox");
-/**
- * A common COSName value.
- */
+public static final COSName ARTIFACT = new COSName("Artifact");
 public static final COSName AS = new COSName("AS");
-/**
- * A common COSName value.
- */
-public static final COSName ASCII85_DECODE = new COSName("ASCII85Decode");
-/**
- * A common COSName value.
- */
-public static final COSName ASCII85_DECODE_ABBREVIATION = new 
COSName("A85");
-/**
- * A common COSName value.
- */
-public static final COSName ATTACHED = new COSName("Attached");
-/**
- * A common COSName value.
- */
 public static final COSName ASCENT = new COSName("Ascent");
-/**
- * A common COSName value.
- */
 public static final COSName ASCII_HEX_DECODE = new 
COSName("ASCIIHexDecode");
-/**
- * A common COSName value.
- */
 public static final COSName AS

svn commit: r1577661 - in /pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil: JPXTestCMYK.pdf JPXTestGrey.pdf JPXTestRGB.pdf

2014-03-14 Thread tilman
Author: tilman
Date: Fri Mar 14 18:58:05 2014
New Revision: 1577661

URL: http://svn.apache.org/r1577661
Log:
PDFBOX-1975: add three JPX test files

Added:
pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestCMYK.pdf   
(with props)
pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestGrey.pdf   
(with props)
pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestRGB.pdf   
(with props)

Added: pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestCMYK.pdf
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestCMYK.pdf?rev=1577661&view=auto
==
Binary file - no diff available.

Propchange: 
pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestCMYK.pdf
--
svn:mime-type = application/pdf

Added: pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestGrey.pdf
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestGrey.pdf?rev=1577661&view=auto
==
Binary file - no diff available.

Propchange: 
pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestGrey.pdf
--
svn:mime-type = application/pdf

Added: pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestRGB.pdf
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestRGB.pdf?rev=1577661&view=auto
==
Binary file - no diff available.

Propchange: 
pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestRGB.pdf
--
svn:mime-type = application/pdf




svn commit: r1577658 - in /pdfbox/trunk: parent/pom.xml pdfbox/pom.xml

2014-03-14 Thread tilman
Author: tilman
Date: Fri Mar 14 18:51:18 2014
New Revision: 1577658

URL: http://svn.apache.org/r1577658
Log:
PDFBOX-1975: use a different repository to get a better version of jai_imageio

Modified:
pdfbox/trunk/parent/pom.xml
pdfbox/trunk/pdfbox/pom.xml

Modified: pdfbox/trunk/parent/pom.xml
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/parent/pom.xml?rev=1577658&r1=1577657&r2=1577658&view=diff
==
--- pdfbox/trunk/parent/pom.xml (original)
+++ pdfbox/trunk/parent/pom.xml Fri Mar 14 18:51:18 2014
@@ -1,346 +1,346 @@
 
 
 
+! 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.
+!-->
 
 http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-  4.0.0
+4.0.0
 
-  
-org.apache
-apache
-13
-
-  
+
+org.apache
+apache
+13
+
+
 
-  org.apache.pdfbox
-  pdfbox-parent
-  2.0.0-SNAPSHOT
-  pom
+org.apache.pdfbox
+pdfbox-parent
+2.0.0-SNAPSHOT
+pom
 
-  PDFBox parent
-  2002
+PDFBox parent
+2002
 
-  
-The Apache Software Foundation
-http://pdfbox.apache.org
-  
+
+The Apache Software Foundation
+http://pdfbox.apache.org
+
   
-  
-jira
-https://issues.apache.org/jira/browse/PDFBOX
-  
+
+jira
+https://issues.apache.org/jira/browse/PDFBOX
+
 
-  
-ISO-8859-1
-  
+
+ISO-8859-1
+
 
-  
-  
-  
-  junit
-  junit
-  4.11
-  test
-  
-  
-  commons-logging
-  commons-logging
-  1.1.3
-  
-  
-  commons-io
-  commons-io
-  2.4
-  
-  
-  org.bouncycastle
-  bcprov-jdk15on
-  1.49
-  
-  
-  org.bouncycastle
-  bcmail-jdk15on
-  1.49
-  
-  
-  com.ibm.icu
-  icu4j
-  52.1
-  
+
+
+
+junit
+junit
+4.11
+test
+
+
+commons-logging
+commons-logging
+1.1.3
+
+
+commons-io
+commons-io
+2.4
+
+
+org.bouncycastle
+bcprov-jdk15on
+1.49
+
+
+org.bouncycastle
+bcmail-jdk15on
+1.49
+
+
+com.ibm.icu
+icu4j
+52.1
+
   
-  
-  
-  com.levigo.jbig2
-  levigo-jbig2-imageio
-  1.6.2
-  test
-  
-  
-  javax.media
-  jai_imageio
-  1.1
-  test
-  
-  
-  
+
+
+com.levigo.jbig2
+levigo-jbig2-imageio
+1.6.2
+test
+
+
+net.java.dev.jai-imageio
+jai-imageio-core-standalone
+1.2-pre-dr-b04-2011-07-04
+test
+
+
+
   
-  
-  
-  jbig2.googlecode
-  JBIG2 ImageIO-Plugin repository at googlecode.com
-  http://jbig2-imageio.googlecode.com/svn/maven-repository/
-  
-  
-  osgeo
-  Open Source Geospatial Foundation Repository
-  http://download.osgeo.org/webdav/geotools/
-
-  
+
+
+jbig2.googlecode
+JBIG2 ImageIO-Plugin repository at googlecode.com
+
http://jbig2-imageio.googlecode.com/svn/maven-repository/
+
+
+mygrid-repository
+myGrid Repository
+http://www.mygrid.org.uk/maven/repository
+
+
   
-  
-
-  pedantic
-  
+

svn commit: r1577653 - /pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/ccitt4-cib-test.pdf

2014-03-14 Thread tilman
Author: tilman
Date: Fri Mar 14 18:42:37 2014
New Revision: 1577653

URL: http://svn.apache.org/r1577653
Log:
PDFBOX-1975: added a CCITT G4 compressed file as test

Added:

pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/ccitt4-cib-test.pdf   
(with props)

Added: 
pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/ccitt4-cib-test.pdf
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/ccitt4-cib-test.pdf?rev=1577653&view=auto
==
Binary file - no diff available.

Propchange: 
pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/ccitt4-cib-test.pdf
--
svn:mime-type = application/pdf




svn commit: r1577622 - in /pdfbox/trunk/pdfbox/src/test: java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java resources/org/apache/pdfbox/pdmodel/graphics/image/jpeg.jpg

2014-03-14 Thread tilman
Author: tilman
Date: Fri Mar 14 17:49:32 2014
New Revision: 1577622

URL: http://svn.apache.org/r1577622
Log:
PDFBOX-1969: added a test for JPEGFactory

Added:

pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java
   (with props)

pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/jpeg.jpg
   (with props)

Added: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java?rev=1577622&view=auto
==
--- 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java
 (added)
+++ 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java
 Fri Mar 14 17:49:32 2014
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.pdfbox.pdmodel.graphics.image;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import javax.imageio.ImageIO;
+import junit.framework.TestCase;
+import static junit.framework.TestCase.assertEquals;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Tilman Hausherr
+ */
+public class JPEGFactoryTest extends TestCase
+{
+
+/** {@inheritDoc} */
+@Override
+public void setUp() throws Exception
+{
+super.setUp();
+}
+
+
+/**
+ * Test of createFromStream method, of class JPEGFactory.
+ */
+@Test
+public void testCreateFromStream() throws Exception
+{
+PDDocument document = new PDDocument();
+InputStream stream = new FileInputStream(new 
File("src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/jpeg.jpg"));
+PDImageXObject ximage = JPEGFactory.createFromStream(document, stream);
+assertNotNull(ximage);
+assertNotNull(ximage.getCOSStream());
+assertTrue(ximage.getCOSStream().getFilteredLength() > 0);
+assertEquals(8, ximage.getBitsPerComponent());
+assertEquals(344, ximage.getWidth());
+assertEquals(287, ximage.getHeight());
+assertEquals("jpg", ximage.getSuffix());
+
+//TODO shouldn't ximage.getImage() return a real image?
+//assertNotNull(ximage.getImage());
+//assertEquals(344, ximage.getImage().getWidth());
+//assertEquals(287, ximage.getImage().getHeight());
+
+document.close();
+}
+
+/**
+ * Test of createFromImage method, of class JPEGFactory.
+ */
+@Test
+public void testCreateFromImage() throws Exception
+{
+
+//TODO enable this test when JPEGFactory.createFromImage() works
+//PDDocument document = new PDDocument();
+//BufferedImage bim = ImageIO.read(new 
File("src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/jpeg.jpg"));
+//PDImageXObject ximage = JPEGFactory.createFromImage(document, bim);
+//assertNotNull(ximage);
+//assertNotNull(ximage.getCOSStream());
+//assertTrue(ximage.getCOSStream().getFilteredLength() > 0);
+//assertEquals(8, ximage.getBitsPerComponent());
+//assertEquals(344, ximage.getWidth());
+//assertEquals(287, ximage.getHeight());
+//assertEquals("jpg", ximage.getSuffix());
+
+//TODO shouldn't ximage.getImage() return a real image?
+//assertNotNull(ximage.getImage());
+//assertEquals(344, ximage.getImage().getWidth());
+//assertEquals(287, ximage.getImage().getHeight());
+
+//document.close();
+}
+
+
+}

Propchange: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactoryTest.java
--
svn:eol-style = native

Added: 
pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/jpeg.jpg
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/jpeg.jpg?rev=1577622&view=auto
==
Binary file - 

svn commit: r1577619 - in /pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics: ./ image/ image/ccittg4.tif

2014-03-14 Thread tilman
Author: tilman
Date: Fri Mar 14 17:33:51 2014
New Revision: 1577619

URL: http://svn.apache.org/r1577619
Log:
PDFBOX-1983: added a test for CCITTFactory

Added:
pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/

pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/

pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg4.tif
   (with props)

Added: 
pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg4.tif
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg4.tif?rev=1577619&view=auto
==
Binary file - no diff available.

Propchange: 
pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg4.tif
--
svn:mime-type = image/tiff




svn commit: r1577618 - in /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image: ./ CCITTFactoryTest.java

2014-03-14 Thread tilman
Author: tilman
Date: Fri Mar 14 17:30:43 2014
New Revision: 1577618

URL: http://svn.apache.org/r1577618
Log:
PDFBOX-1983: added a test for CCITTFactory

Added:
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/

pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
   (with props)

Added: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java?rev=1577618&view=auto
==
--- 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
 (added)
+++ 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
 Fri Mar 14 17:30:43 2014
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.pdfbox.pdmodel.graphics.image;
+
+import java.io.File;
+import junit.framework.TestCase;
+import static junit.framework.TestCase.assertEquals;
+import org.apache.pdfbox.io.RandomAccess;
+import org.apache.pdfbox.io.RandomAccessFile;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Tilman Hausherr
+ */
+public class CCITTFactoryTest extends TestCase
+{
+/**
+ * {@inheritDoc}
+ */
+@Override
+public void setUp() throws Exception
+{
+super.setUp();
+}
+
+/**
+ * Test of createFromRandomAccess method, of class CCITTFactory.
+ */
+@Test
+public void testCreateFromRandomAccess() throws Exception
+{
+PDDocument document = new PDDocument();
+RandomAccess reader = new RandomAccessFile(new 
File("src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg4.tif"),
 "r");
+PDImageXObject ximage = CCITTFactory.createFromRandomAccess(document, 
reader);
+assertNotNull(ximage);
+assertNotNull(ximage.getCOSStream());
+assertTrue(ximage.getCOSStream().getFilteredLength() > 0);
+assertEquals(1, ximage.getBitsPerComponent());
+assertEquals(344, ximage.getWidth());
+assertEquals(287, ximage.getHeight());
+assertEquals("tiff", ximage.getSuffix());
+
+//TODO shouldn't ximage.getImage() return a real image?
+//assertNotNull(ximage.getImage());
+//assertEquals(344, ximage.getImage().getWidth());
+//assertEquals(287, ximage.getImage().getHeight());
+document.close();
+}
+
+}

Propchange: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
--
svn:eol-style = native