diff -Nru libpdfbox-java-1.8.12/ant/pom.xml libpdfbox-java-1.8.13/ant/pom.xml --- libpdfbox-java-1.8.12/ant/pom.xml 2016-04-22 16:33:20.000000000 +0000 +++ libpdfbox-java-1.8.13/ant/pom.xml 2016-12-05 19:30:10.000000000 +0000 @@ -23,7 +23,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml diff -Nru libpdfbox-java-1.8.12/app/pom.xml libpdfbox-java-1.8.13/app/pom.xml --- libpdfbox-java-1.8.12/app/pom.xml 2016-04-22 16:33:14.000000000 +0000 +++ libpdfbox-java-1.8.13/app/pom.xml 2016-12-05 19:30:10.000000000 +0000 @@ -23,7 +23,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml Binary files /tmp/tmpT_zeuE/tFRGiOsxad/libpdfbox-java-1.8.12/cacerts_jdk8u101 and /tmp/tmpT_zeuE/CJBrZKnOmH/libpdfbox-java-1.8.13/cacerts_jdk8u101 differ diff -Nru libpdfbox-java-1.8.12/debian/changelog libpdfbox-java-1.8.13/debian/changelog --- libpdfbox-java-1.8.12/debian/changelog 2016-06-01 08:58:30.000000000 +0000 +++ libpdfbox-java-1.8.13/debian/changelog 2017-07-26 20:13:10.000000000 +0000 @@ -1,3 +1,16 @@ +libpdfbox-java (1:1.8.13-1) unstable; urgency=medium + + * Team upload. + * New upstream version 1.8.13. + * Switch to compat level 10. + * Declare compliance with Debian Policy 4.0.0. + * Use https for Format field. + * get-orig-source: Use --download-current-version option. + * Ignore com.github.jai-imageio artifacts. + * Refresh 01-bouncycastle-compatibility.patch. + + -- Markus Koschany Wed, 26 Jul 2017 22:13:10 +0200 + libpdfbox-java (1:1.8.12-1) unstable; urgency=high * New upstream release diff -Nru libpdfbox-java-1.8.12/debian/compat libpdfbox-java-1.8.13/debian/compat --- libpdfbox-java-1.8.12/debian/compat 2016-06-01 08:52:43.000000000 +0000 +++ libpdfbox-java-1.8.13/debian/compat 2017-07-26 20:13:10.000000000 +0000 @@ -1 +1 @@ -9 +10 diff -Nru libpdfbox-java-1.8.12/debian/control libpdfbox-java-1.8.13/debian/control --- libpdfbox-java-1.8.12/debian/control 2016-06-01 08:52:43.000000000 +0000 +++ libpdfbox-java-1.8.13/debian/control 2017-07-26 20:13:10.000000000 +0000 @@ -5,7 +5,7 @@ Uploaders: tony mancill , gregor herrmann , Emmanuel Bourg -Build-Depends: debhelper (>= 9), maven-debian-helper +Build-Depends: debhelper (>= 10), maven-debian-helper Build-Depends-Indep: default-jdk, htmldoc-common, javahelper, @@ -19,7 +19,7 @@ libicu4j-java, libmaven-javadoc-plugin-java, poppler-data -Standards-Version: 3.9.8 +Standards-Version: 4.0.0 Vcs-Git: https://anonscm.debian.org/git/pkg-java/libpdfbox-java.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/libpdfbox-java.git Homepage: http://pdfbox.apache.org diff -Nru libpdfbox-java-1.8.12/debian/copyright libpdfbox-java-1.8.13/debian/copyright --- libpdfbox-java-1.8.12/debian/copyright 2016-06-01 08:52:43.000000000 +0000 +++ libpdfbox-java-1.8.13/debian/copyright 2017-07-26 20:13:10.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Apache PDFBox Upstream-Contact: The Apache Software Foundation Source: https://pdfbox.apache.org/downloads.html @@ -65,7 +65,7 @@ otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot - org. + org. . http://www.bitstream.com @@ -74,7 +74,7 @@ License: Apache-2.0 Files: debian/* -Copyright: +Copyright: 2007-2016, gregor herrmann 2007-2016, tony mancill License: GPL-2+ @@ -98,7 +98,7 @@ License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) + the Free Software Foundation; either version 2, or (at your option) any later version. . On Debian systems, the complete text of version 2 of the GNU General Public diff -Nru libpdfbox-java-1.8.12/debian/maven.ignoreRules libpdfbox-java-1.8.13/debian/maven.ignoreRules --- libpdfbox-java-1.8.12/debian/maven.ignoreRules 2016-06-01 08:52:43.000000000 +0000 +++ libpdfbox-java-1.8.13/debian/maven.ignoreRules 2017-07-26 20:13:10.000000000 +0000 @@ -15,3 +15,5 @@ org.apache.rat apache-rat-plugin * * * * org.codehaus.mojo cobertura-maven-plugin * * * * org.codehaus.mojo taglist-maven-plugin * * * * +com.github.jai-imageio jai-imageio-core * * * * +com.github.jai-imageio jai-imageio-jpeg2000 * * * * diff -Nru libpdfbox-java-1.8.12/debian/patches/01-bouncycastle-compatibility.patch libpdfbox-java-1.8.13/debian/patches/01-bouncycastle-compatibility.patch --- libpdfbox-java-1.8.12/debian/patches/01-bouncycastle-compatibility.patch 2016-06-01 08:52:43.000000000 +0000 +++ libpdfbox-java-1.8.13/debian/patches/01-bouncycastle-compatibility.patch 2017-07-26 20:13:10.000000000 +0000 @@ -5,7 +5,7 @@ Author: Gregor Herrmann , Tony Mancill --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java -@@ -27,6 +27,7 @@ +@@ -27,6 +27,7 @@ import java.security.KeyStoreException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; @@ -13,7 +13,7 @@ import java.security.SecureRandom; import java.security.cert.X509Certificate; import java.util.Iterator; -@@ -38,8 +39,8 @@ +@@ -38,8 +39,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.bouncycastle.asn1.ASN1InputStream; @@ -24,7 +24,7 @@ import org.bouncycastle.asn1.DEROctetString; import org.bouncycastle.asn1.DEROutputStream; import org.bouncycastle.asn1.DERSet; -@@ -56,6 +57,7 @@ +@@ -56,6 +57,7 @@ import org.bouncycastle.asn1.x509.TBSCer import org.bouncycastle.cms.CMSEnvelopedData; import org.bouncycastle.cms.CMSException; import org.bouncycastle.cms.RecipientInformation; @@ -32,7 +32,7 @@ import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSString; import org.apache.pdfbox.exceptions.CryptographyException; -@@ -185,7 +187,7 @@ +@@ -185,7 +187,7 @@ public class PublicKeySecurityHandler ex if (ri.getRID().match(material.getCertificate()) && !foundRecipient) { foundRecipient = true; @@ -41,7 +41,7 @@ break; } } -@@ -239,10 +241,6 @@ +@@ -239,10 +241,6 @@ public class PublicKeySecurityHandler ex { throw new CryptographyException(e); } @@ -52,7 +52,7 @@ catch (NoSuchAlgorithmException e) { throw new CryptographyException(e); -@@ -311,7 +309,7 @@ +@@ -311,7 +309,7 @@ public class PublicKeySecurityHandler ex pkcs7input[22] = two; pkcs7input[23] = one; @@ -61,7 +61,7 @@ ByteArrayOutputStream baos = new ByteArrayOutputStream(); -@@ -378,7 +376,7 @@ +@@ -378,7 +376,7 @@ public class PublicKeySecurityHandler ex } @@ -70,16 +70,16 @@ throws IOException, GeneralSecurityException { -@@ -389,7 +387,7 @@ +@@ -389,7 +387,7 @@ public class PublicKeySecurityHandler ex AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters(); ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1")); ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream); - DERObject derobject = asn1inputstream.readObject(); + ASN1Primitive derobject = asn1inputstream.readObject(); - KeyGenerator keygenerator = KeyGenerator.getInstance(s); - keygenerator.init(128); - SecretKey secretkey = keygenerator.generateKey(); -@@ -399,13 +397,13 @@ + KeyGenerator keygenerator; + try + { +@@ -409,13 +407,13 @@ public class PublicKeySecurityHandler ex DEROctetString deroctetstring = new DEROctetString(abyte1); KeyTransRecipientInfo keytransrecipientinfo = computeRecipientInfo(cert, secretkey.getEncoded()); DERSet derset = new DERSet(new RecipientInfo(keytransrecipientinfo)); diff -Nru libpdfbox-java-1.8.12/debian/rules libpdfbox-java-1.8.13/debian/rules --- libpdfbox-java-1.8.12/debian/rules 2016-06-01 08:52:43.000000000 +0000 +++ libpdfbox-java-1.8.13/debian/rules 2017-07-26 20:13:10.000000000 +0000 @@ -38,4 +38,4 @@ dh_gencontrol -- "-Vmisc:Built-Using=$(htmldoc-common_source)$(lcdf-typetools_source)$(poppler-data_source)" get-orig-source: - uscan --force-download --repack --rename --compression xz + uscan --download-current-version --force-download --repack --rename --compression xz diff -Nru libpdfbox-java-1.8.12/examples/pom.xml libpdfbox-java-1.8.13/examples/pom.xml --- libpdfbox-java-1.8.12/examples/pom.xml 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/examples/pom.xml 2016-12-05 19:30:10.000000000 +0000 @@ -23,7 +23,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml @@ -74,6 +74,17 @@ true + + + org.apache.rat + apache-rat-plugin + + + src/main/resources/org/apache/pdfbox/resources/pdfa/sRGB.* + + + + diff -Nru libpdfbox-java-1.8.12/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java libpdfbox-java-1.8.13/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java --- libpdfbox-java-1.8.12/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java 2016-12-05 19:30:10.000000000 +0000 @@ -112,7 +112,8 @@ System.err.println(xmpException.getMessage()); } - InputStream colorProfile = CreatePDFA.class.getResourceAsStream("/org/apache/pdfbox/resources/pdfa/sRGB Color Space Profile.icm"); + InputStream colorProfile = CreatePDFA.class + .getResourceAsStream("/org/apache/pdfbox/resources/pdfa/sRGB.icc"); // create output intent PDOutputIntent oi = new PDOutputIntent(doc, colorProfile); oi.setInfo("sRGB IEC61966-2.1"); diff -Nru libpdfbox-java-1.8.12/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignature.java libpdfbox-java-1.8.13/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignature.java --- libpdfbox-java-1.8.12/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignature.java 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignature.java 2016-12-05 19:30:10.000000000 +0000 @@ -161,7 +161,7 @@ try { // load document - PDDocument doc = PDDocument.load(document, randomAccessFile); + PDDocument doc = PDDocument.loadNonSeq(document, randomAccessFile); // create signature dictionary PDSignature signature = new PDSignature(); diff -Nru libpdfbox-java-1.8.12/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java libpdfbox-java-1.8.13/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java --- libpdfbox-java-1.8.12/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java 2016-12-05 19:30:10.000000000 +0000 @@ -73,7 +73,7 @@ private Certificate[] cert; - private SignatureOptions options; + private SignatureOptions options = null; /** * Initialize the signature creator with a keystore (pkcs12) and pin that @@ -146,7 +146,7 @@ fis = new FileInputStream(outputDocument); // load document - PDDocument doc = PDDocument.load(document); + PDDocument doc = PDDocument.loadNonSeq(document, null); // create signature dictionary PDSignature signature = new PDSignature(); @@ -174,6 +174,10 @@ // write incremental (only for signing purpose) doc.saveIncremental(fis, fos); + if (options != null) + { + options.close(); + } return outputDocument; } diff -Nru libpdfbox-java-1.8.12/fontbox/pom.xml libpdfbox-java-1.8.13/fontbox/pom.xml --- libpdfbox-java-1.8.12/fontbox/pom.xml 2016-04-22 16:33:14.000000000 +0000 +++ libpdfbox-java-1.8.13/fontbox/pom.xml 2016-12-05 19:30:10.000000000 +0000 @@ -21,7 +21,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml diff -Nru libpdfbox-java-1.8.12/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java libpdfbox-java-1.8.13/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java --- libpdfbox-java-1.8.12/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java 2016-04-22 16:33:14.000000000 +0000 +++ libpdfbox-java-1.8.13/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java 2016-12-05 19:30:10.000000000 +0000 @@ -210,7 +210,7 @@ } else { - throw new IllegalArgumentException(); + throw new IOException("invalid DICT data b0 byte: " + b0); } } return entry; @@ -325,6 +325,10 @@ // see PDFBOX-1522 sb.append("0"); } + if (sb.length() == 0) + { + return 0d; + } return Double.valueOf(sb.toString()); } diff -Nru libpdfbox-java-1.8.12/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java libpdfbox-java-1.8.13/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java --- libpdfbox-java-1.8.12/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java 2016-04-22 16:33:14.000000000 +0000 +++ libpdfbox-java-1.8.13/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java 2016-12-05 19:30:10.000000000 +0000 @@ -224,6 +224,11 @@ { tokenBytes = (byte[]) nextToken; } + if (tokenBytes.length == 0) + { + // PDFBOX-3450: ignore <> + continue; + } boolean done = false; // don't add 1:1 mappings to reduce the memory footprint if (Arrays.equals(startCode, tokenBytes)) @@ -567,7 +572,7 @@ String value = buffer.toString(); if (value.indexOf('.') >= 0) { - retval = new Double(value); + retval = Double.valueOf(value); } else { diff -Nru libpdfbox-java-1.8.12/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java libpdfbox-java-1.8.13/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java --- libpdfbox-java-1.8.12/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java 2016-04-22 16:33:14.000000000 +0000 +++ libpdfbox-java-1.8.13/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java 2016-12-05 19:30:10.000000000 +0000 @@ -288,7 +288,7 @@ } /** - * Returns the number of glyphs (MaximuProfile.numGlyphs). + * Returns the number of glyphs (MaximumProfile.numGlyphs). * * @return the number of glyphs */ diff -Nru libpdfbox-java-1.8.12/jempbox/pom.xml libpdfbox-java-1.8.13/jempbox/pom.xml --- libpdfbox-java-1.8.12/jempbox/pom.xml 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/jempbox/pom.xml 2016-12-05 19:30:08.000000000 +0000 @@ -21,7 +21,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml diff -Nru libpdfbox-java-1.8.12/jempbox/src/main/java/org/apache/jempbox/impl/DateConverter.java libpdfbox-java-1.8.13/jempbox/src/main/java/org/apache/jempbox/impl/DateConverter.java --- libpdfbox-java-1.8.12/jempbox/src/main/java/org/apache/jempbox/impl/DateConverter.java 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/jempbox/src/main/java/org/apache/jempbox/impl/DateConverter.java 2016-12-05 19:30:08.000000000 +0000 @@ -22,7 +22,9 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.Locale; import java.util.SimpleTimeZone; +import java.util.TimeZone; /** * This class is used to convert dates to strings and back using the PDF @@ -158,6 +160,7 @@ } else { + updateZoneId(zone); retval = new GregorianCalendar( zone ); } retval.clear(); @@ -199,6 +202,43 @@ return retval; } + /** + * Update the zone ID based on the raw offset. This is either GMT, GMT+hh:mm or GMT-hh:mm, where + * n is between 1 and 14. The highest negative hour is -14, the highest positive hour is 12. + * Zones that don't fit in this schema are set to zone ID "unknown". + * + * @param tz the time zone to update. + */ + private static void updateZoneId(TimeZone tz) + { + // https://garygregory.wordpress.com/2013/06/18/what-are-the-java-timezone-ids/ + int offset = tz.getRawOffset(); + char pm = '+'; + if (offset < 0) + { + pm = '-'; + offset = -offset; + } + int hh = offset / 3600000; + int mm = offset % 3600000 / 60000; + if (offset == 0) + { + tz.setID("GMT"); + } + else if (pm == '+' && hh <= 12) + { + tz.setID(String.format(Locale.US, "GMT+%02d:%02d", hh, mm)); + } + else if (pm == '-' && hh <= 14) + { + tz.setID(String.format(Locale.US, "GMT-%02d:%02d", hh, mm)); + } + else + { + tz.setID("unknown"); + } + } + private static final void zeroAppend( StringBuffer out, int number ) { if( number < 10 ) diff -Nru libpdfbox-java-1.8.12/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java libpdfbox-java-1.8.13/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java --- libpdfbox-java-1.8.12/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchemaBasic.java 2016-12-05 19:30:08.000000000 +0000 @@ -210,7 +210,7 @@ */ public String getLabel() { - return getTextProperty( prefix + "p:Label" ); + return getTextProperty( prefix + ":Label" ); } /** diff -Nru libpdfbox-java-1.8.12/lucene/pom.xml libpdfbox-java-1.8.13/lucene/pom.xml --- libpdfbox-java-1.8.12/lucene/pom.xml 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/lucene/pom.xml 2016-12-05 19:30:08.000000000 +0000 @@ -23,7 +23,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml diff -Nru libpdfbox-java-1.8.12/parent/pom.xml libpdfbox-java-1.8.13/parent/pom.xml --- libpdfbox-java-1.8.12/parent/pom.xml 2016-04-22 16:33:24.000000000 +0000 +++ libpdfbox-java-1.8.13/parent/pom.xml 2016-12-05 19:30:08.000000000 +0000 @@ -29,7 +29,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 pom PDFBox parent @@ -145,6 +145,7 @@ release.properties + cacerts_jdk8u101 @@ -303,8 +304,8 @@ - scm:svn:http://svn.apache.org/repos/asf/maven/pom/tags/1.8.12/pdfbox-parent - scm:svn:https://svn.apache.org/repos/asf/maven/pom/tags/1.8.12/pdfbox-parent - http://svn.apache.org/viewvc/maven/pom/tags/1.8.12/pdfbox-parent + scm:svn:http://svn.apache.org/repos/asf/maven/pom/tags/1.8.13/pdfbox-parent + scm:svn:https://svn.apache.org/repos/asf/maven/pom/tags/1.8.13/pdfbox-parent + http://svn.apache.org/viewvc/maven/pom/tags/1.8.13/pdfbox-parent diff -Nru libpdfbox-java-1.8.12/pdfbox/build.xml libpdfbox-java-1.8.13/pdfbox/build.xml --- libpdfbox-java-1.8.12/pdfbox/build.xml 2016-04-22 16:33:20.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/build.xml 2016-12-05 19:30:24.000000000 +0000 @@ -28,7 +28,7 @@ - + diff -Nru libpdfbox-java-1.8.12/pdfbox/pom.xml libpdfbox-java-1.8.13/pdfbox/pom.xml --- libpdfbox-java-1.8.12/pdfbox/pom.xml 2016-04-22 16:33:20.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/pom.xml 2016-12-05 19:30:24.000000000 +0000 @@ -23,7 +23,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml @@ -77,35 +77,28 @@ test - com.levigo.jbig2 levigo-jbig2-imageio - 1.6.2 + 1.6.5 test - net.java.dev.jai-imageio - jai-imageio-core-standalone - 1.2-pre-dr-b04-2011-07-04 + com.github.jai-imageio + jai-imageio-core + 1.3.1 test + + com.github.jai-imageio + jai-imageio-jpeg2000 + 1.3.0 + test + - - - - jbig2.googlecode - JBIG2 ImageIO-Plugin repository at googlecode.com - https://jbig2-imageio.googlecode.com/svn/maven-repository/ - - - mygrid-repository - myGrid Repository - http://www.mygrid.org.uk/maven/repository - - @@ -181,6 +174,7 @@ src/test/resources/org/apache/pdfbox/filter/*.bin src/test/resources/org/apache/pdfbox/encryption/*.der src/test/resources/org/apache/pdfbox/encryption/*.pfx + src/test/resources/org/apache/pdfbox/pdmodel/sRGB.* download/glyphlist.txt release.properties diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java 2016-12-05 19:30:18.000000000 +0000 @@ -60,13 +60,14 @@ } catch( NumberFormatException e ) { - if (aFloat.startsWith("0.00000-")) + if (aFloat.matches("^0\\.0*\\-\\d+")) { // PDFBOX-2990 has 0.00000-33917698 - // Let's wait what other floats will be coming before doing a more general workaround. + // PDFBOX-3369 has 0.00-35095424 + // PDFBOX-3500 has 0.-262 try { - valueAsString = "-0.00000" + aFloat.substring(8); + valueAsString = "-" + valueAsString.replaceFirst("\\-", ""); value = new BigDecimal(valueAsString); checkMinMaxValues(); } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/Decrypt.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/Decrypt.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/Decrypt.java 2016-04-22 16:33:16.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/Decrypt.java 2016-12-05 19:30:18.000000000 +0000 @@ -59,7 +59,7 @@ private void decrypt( String[] args ) throws Exception { - if( args.length < 2 || args.length > 5 ) + if( args.length < 2 || args.length > 8 ) { usage(); } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java 2016-04-22 16:33:16.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java 2016-12-05 19:30:18.000000000 +0000 @@ -160,6 +160,7 @@ read = in.read(buf); inflater.setInput(buf,0,read); } + inflater.end(); } out.close(); } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java 2016-04-22 16:33:16.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java 2016-12-05 19:30:18.000000000 +0000 @@ -35,7 +35,6 @@ import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSBase; import org.apache.pdfbox.cos.COSDictionary; -import org.apache.pdfbox.cos.COSInteger; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSStream; @@ -82,7 +81,7 @@ { decodeParms = (COSDictionary) ((COSArray) decodeP).getObject(filterIndex); } - COSInteger bits = (COSInteger) options.getDictionaryObject(COSName.BITS_PER_COMPONENT); + int bits = options.getInt(COSName.BITS_PER_COMPONENT, 1); COSStream st = null; if (decodeParms != null) { @@ -102,9 +101,9 @@ { // I am assuming since JBIG2 is always black and white // depending on your renderer this might or might be needed - if(bi.getColorModel().getPixelSize() != bits.intValue()) + if (bi.getColorModel().getPixelSize() != bits) { - if(bits.intValue() != 1) + if (bits != 1) { LOG.error("Do not know how to deal with JBIG2 with more than 1 bit"); return; diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java 2016-12-05 19:30:20.000000000 +0000 @@ -542,8 +542,10 @@ long prev = startXrefOffset; // ---- parse whole chain of xref tables/object streams using PREV // reference - while (prev > 0) + long lastPrev = -1; + while (prev > 0 && prev != lastPrev) { + lastPrev = prev; // seek to xref table setPdfSource(prev); @@ -580,12 +582,27 @@ fixedOffset = checkXRefOffset(streamOffset); if (fixedOffset > -1 && fixedOffset != streamOffset) { + LOG.warn("/XRefStm offset " + streamOffset + " is incorrect, corrected to " + fixedOffset); streamOffset = (int)fixedOffset; trailer.setInt(COSName.XREF_STM, streamOffset); } setPdfSource(streamOffset); skipSpaces(); - parseXrefObjStream(prev, false); + try + { + parseXrefObjStream(prev, false); + } + catch (IOException ex) + { + if (isLenient) + { + LOG.error("Failed to parse /XRefStm at offset " + streamOffset, ex); + } + else + { + throw ex; + } + } } prev = trailer.getInt(COSName.PREV); if (prev > 0) @@ -616,6 +633,11 @@ } } } + if (prev == lastPrev) + { + //TODO better idea needed? PDFBOX-3446 + throw new IOException("/Prev loop at offset " + prev); + } // ---- build valid xrefs out of the xref chain xrefTrailerResolver.setStartxref(startXrefOffset); COSDictionary trailer = xrefTrailerResolver.getTrailer(); diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java 2016-04-22 16:33:16.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java 2016-12-05 19:30:18.000000000 +0000 @@ -432,10 +432,22 @@ phaseStart = (int)transformWidth(phaseStart); // empty dash array is illegal - if (dashArray.length == 0) + // avoid also infinite and NaN values (PDFBOX-3360) + if (dashArray.length == 0 || Float.isInfinite(phaseStart) || Float.isNaN(phaseStart)) { dashArray = null; } + else + { + for (int i = 0; i < dashArray.length; ++i) + { + if (Float.isInfinite(dashArray[i]) || Float.isNaN(dashArray[i])) + { + dashArray = null; + break; + } + } + } } currentStroke = new BasicStroke(lineWidth, stroke.getEndCap(), stroke.getLineJoin(), stroke.getMiterLimit(), dashArray, phaseStart); diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java 2016-04-22 16:33:16.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java 2016-12-05 19:30:18.000000000 +0000 @@ -25,6 +25,7 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; @@ -154,11 +155,13 @@ */ public static final byte[] ENDSTREAM = StringUtil.getBytes("endstream"); - private NumberFormat formatXrefOffset = new DecimalFormat("0000000000"); + private NumberFormat formatXrefOffset = new DecimalFormat("0000000000", + new DecimalFormatSymbols(Locale.US)); /** * The decimal format for the xref object generation number data. */ - private NumberFormat formatXrefGeneration = new DecimalFormat("00000"); + private NumberFormat formatXrefGeneration = new DecimalFormat("00000", + new DecimalFormatSymbols(Locale.US)); private NumberFormat formatDecimal = NumberFormat.getNumberInstance( Locale.US ); @@ -1481,8 +1484,17 @@ COSDocument cosDoc = document.getDocument(); COSDictionary trailer = cosDoc.getTrailer(); - COSArray idArray = (COSArray)trailer.getDictionaryObject( COSName.ID ); + COSArray idArray = null; boolean missingID = true; + COSBase base = trailer.getDictionaryObject(COSName.ID); + if (base instanceof COSArray) + { + idArray = (COSArray) base; + if (idArray.size() == 2) + { + missingID = false; + } + } // check for an existing documentID if (idArray != null && idArray.size() == 2) { diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java 2016-12-05 19:30:18.000000000 +0000 @@ -293,19 +293,18 @@ List retval = null; if (floatArray != null) { - List numbers = new ArrayList(); + List numbers = new ArrayList(floatArray.size()); for (int i = 0; i < floatArray.size(); i++) { - COSNumber num; - if (floatArray.get(i) instanceof COSObject) + COSBase base = floatArray.getObject(i); + if (base instanceof COSNumber) { - num = (COSNumber) ((COSObject) floatArray.get(i)).getObject(); + numbers.add(((COSNumber) base).floatValue()); } else { - num = (COSNumber) floatArray.get(i); + numbers.add(null); } - numbers.add(num.floatValue()); } retval = new COSArrayList(numbers, floatArray); } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSDictionaryMap.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSDictionaryMap.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSDictionaryMap.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSDictionaryMap.java 2016-12-05 19:30:18.000000000 +0000 @@ -77,7 +77,7 @@ */ public boolean containsKey(Object key) { - return map.keySet().contains( key ); + return actuals.containsKey( key ); } /** @@ -160,6 +160,7 @@ /** * {@inheritDoc} */ + @Override public boolean equals(Object o) { boolean retval = false; @@ -174,6 +175,7 @@ /** * {@inheritDoc} */ + @Override public String toString() { return actuals.toString(); @@ -182,6 +184,7 @@ /** * {@inheritDoc} */ + @Override public int hashCode() { return map.hashCode(); diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java 2016-12-05 19:30:18.000000000 +0000 @@ -238,8 +238,11 @@ for( int i=0; i= 0 ) + String upperLimit = childNode.getUpperLimit(); + String lowerLimit = childNode.getLowerLimit(); + if (upperLimit == null || lowerLimit == null || + upperLimit.compareTo(lowerLimit) < 0 || + (lowerLimit.compareTo(name) <= 0 && upperLimit.compareTo(name) >= 0)) { retval = childNode.getValue( name ); } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java 2016-12-05 19:30:18.000000000 +0000 @@ -395,14 +395,14 @@ } /** - * A..Z, AA..ZZ, AAA..ZZZ ... labeling as described in PDF32000-1:2008, + * a..z, aa..zz, aaa..zzz ... labeling as described in PDF32000-1:2008, * Table 159, Page 375. */ private static String makeLetterLabel(int num) { StringBuilder buf = new StringBuilder(); int numLetters = num / 26 + Integer.signum(num % 26); - int letter = num % 26 + 26 * (1 - Integer.signum(num % 26)) + 64; + int letter = num % 26 + 26 * (1 - Integer.signum(num % 26)) + 'a' - 1; for (int i = 0; i < numLetters; i++) { buf.appendCodePoint(letter); diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java 2016-12-05 19:30:18.000000000 +0000 @@ -162,7 +162,7 @@ /** * Returns the attributes together with their revision numbers (A). * - * @return the attributes + * @return the attributes as a list, never null. */ public Revisions getAttributes() { @@ -329,7 +329,7 @@ /** * Returns the class names together with their revision numbers (C). * - * @return the class names + * @return the class names as a list, never null. */ public Revisions getClassNames() { diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java 2016-12-05 19:30:18.000000000 +0000 @@ -209,7 +209,8 @@ /** * Set if the user can print. - * This method will have no effect if the object is in read only mode + *

+ * This method will have no effect if the object is in read only mode. * * @param allowPrinting A boolean determining if the user can print. */ @@ -233,7 +234,8 @@ /** * Set if the user can modify the document. - * This method will have no effect if the object is in read only mode + *

+ * This method will have no effect if the object is in read only mode. * * @param allowModifications A boolean determining if the user can modify the document. */ @@ -258,7 +260,8 @@ /** * Set if the user can extract content from the document. - * This method will have no effect if the object is in read only mode + *

+ * This method will have no effect if the object is in read only mode. * * @param allowExtraction A boolean determining if the user can extract content * from the document. @@ -272,7 +275,11 @@ } /** - * This will tell if the user can add/modify text annotations, fill in interactive forms fields. + * This will tell if the user can add or modify text annotations and fill in interactive forms + * fields and, if {@link #canModify() canModify()} returns true, create or modify interactive + * form fields (including signature fields). Note that if + * {@link #canFillInForm() canFillInForm()} returns true, it is still possible to fill in + * interactive forms (including signature fields) even if this method here returns false. * * @return true If supplied with the user password they are allowed to modify annotations. */ @@ -282,10 +289,15 @@ } /** - * Set if the user can modify annotations. - * This method will have no effect if the object is in read only mode + * Set if the user can add or modify text annotations and fill in interactive forms fields and, + * if {@link #canModify() canModify()} returns true, create or modify interactive form fields + * (including signature fields). Note that if {@link #canFillInForm() canFillInForm()} returns + * true, it is still possible to fill in interactive forms (including signature fields) even the + * parameter here is false. + *

+ * This method will have no effect if the object is in read only mode. * - * @param allowAnnotationModification A boolean determining if the user can modify annotations. + * @param allowAnnotationModification A boolean determining the new setting. */ public void setCanModifyAnnotations( boolean allowAnnotationModification ) { @@ -296,7 +308,8 @@ } /** - * This will tell if the user can fill in interactive forms. + * This will tell if the user can fill in interactive form fields (including signature fields) + * even if {@link #canModifyAnnotations() canModifyAnnotations()} returns false. * * @return true If supplied with the user password they are allowed to fill in form fields. */ @@ -306,8 +319,12 @@ } /** - * Set if the user can fill in interactive forms. - * This method will have no effect if the object is in read only mode + * Set if the user can fill in interactive form fields (including signature fields) even if + * {@link #canModifyAnnotations() canModifyAnnotations()} returns false. Therefore, if you want + * to prevent a user from filling in interactive form fields, you need to call + * {@link #setCanModifyAnnotations(boolean) setCanModifyAnnotations(false)} as well. + *

+ * This method will have no effect if the object is in read only mode. * * @param allowFillingInForm A boolean determining if the user can fill in interactive forms. */ @@ -333,7 +350,8 @@ /** * Set if the user can extract content from the document for accessibility purposes. - * This method will have no effect if the object is in read only mode + *

+ * This method will have no effect if the object is in read only mode. * * @param allowExtraction A boolean determining if the user can extract content * from the document. @@ -359,7 +377,8 @@ /** * Set if the user can insert/rotate/delete pages. - * This method will have no effect if the object is in read only mode + *

+ * This method will have no effect if the object is in read only mode. * * @param allowAssembly A boolean determining if the user can assemble the document. */ @@ -384,7 +403,8 @@ /** * Set if the user can print the document in a degraded format. - * This method will have no effect if the object is in read only mode + *

+ * This method will have no effect if the object is in read only mode. * * @param allowAssembly A boolean determining if the user can print the * document in a degraded format. diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java 2016-12-05 19:30:18.000000000 +0000 @@ -390,7 +390,17 @@ ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1")); ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream); DERObject derobject = asn1inputstream.readObject(); - KeyGenerator keygenerator = KeyGenerator.getInstance(s); + KeyGenerator keygenerator; + try + { + keygenerator = KeyGenerator.getInstance(s); + } + catch (NoSuchAlgorithmException e) + { + // happens when using the command line app .jar file + throw new NoSuchAlgorithmException("Could not find a suitable javax.crypto provider for algorithm " + + s + "; possible reason: using an unsigned .jar file", e); + } keygenerator.init(128); SecretKey secretkey = keygenerator.generateKey(); Cipher cipher = Cipher.getInstance(s); diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java 2016-12-05 19:30:18.000000000 +0000 @@ -236,6 +236,7 @@ if( isUserPassword ) { currentAccessPermission = new AccessPermission( dicPermissions ); + currentAccessPermission.setReadOnly(); encryptionKey = computeEncryptedKey( password.getBytes("ISO-8859-1"), diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java 2016-12-05 19:30:20.000000000 +0000 @@ -158,7 +158,7 @@ int arraySize = array.size(); for (int i=0; i 1) + { + LOG.warn("using 1 instead of incorrect Alpha " + alpha); + return 1; + } + return alpha; } } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java 2016-12-05 19:30:20.000000000 +0000 @@ -115,6 +115,16 @@ LOG.debug("color[" + n + "]: " + color + "/" + String.format("%02x", color) + "-> color[" + n + "]: " + colorComponentTab[n]); } + + // "Each set of vertex data shall occupy a whole number of bytes. + // If the total number of bits required is not divisible by 8, the last data byte + // for each vertex is padded at the end with extra bits, which shall be ignored." + int bitOffset = input.getBitOffset(); + if (bitOffset != 0) + { + input.readBits(8 - bitOffset); + } + return new Vertex(tmp, colorComponentTab); } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java 2016-12-05 19:30:20.000000000 +0000 @@ -84,12 +84,13 @@ private final COSDictionary dictionary; - /** + /** * Create the correct annotation from the base COS object. - * + * * @param base The COS object that is the annotation. * @return The correctly typed annotation object. - * @throws IOException If there is an error while creating the annotation. + * + * @throws IOException If the annotation type is unknown. */ public static PDAnnotation createAnnotation(COSBase base) throws IOException { diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java 2016-12-05 19:30:20.000000000 +0000 @@ -23,7 +23,9 @@ import org.apache.pdfbox.pdfparser.VisualSignatureParser; import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSigProperties; - +/** + * This contains the visual signature as a COSDocument, its preferred size and the page. + */ public class SignatureOptions { private COSDocument visualSignature; @@ -113,4 +115,17 @@ preferedSignatureSize = size; } } + + /** + * Closes the visual signature COSDocument, if any. + * + * @throws IOException if the document could not be closed + */ + public void close() throws IOException + { + if (visualSignature != null) + { + visualSignature.close(); + } + } } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java 2016-12-05 19:30:20.000000000 +0000 @@ -68,7 +68,6 @@ * @param properties * @return InputStream * @throws IOException - * @throws COSVisitorException */ public InputStream buildPDF(PDVisibleSignDesigner properties) throws IOException diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java 2016-12-05 19:30:20.000000000 +0000 @@ -19,6 +19,7 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -64,7 +65,7 @@ public PDVisibleSignDesigner(InputStream originalDocumenStream, InputStream imageStream, int page) throws IOException { signatureImageStream(imageStream); - document = PDDocument.load(originalDocumenStream); + document = PDDocument.loadNonSeq(originalDocumenStream, null); calculatePageSize(document, page); } @@ -77,11 +78,11 @@ */ public PDVisibleSignDesigner(String documentPath, InputStream imageStream, int page) throws IOException { - // set visible singature image Input stream + // set visible signature image Input stream signatureImageStream(imageStream); // create PD document - document = PDDocument.load(documentPath); + document = PDDocument.loadNonSeq(new File(documentPath), null); // calculate height an width of document calculatePageSize(document, page); diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java 2016-12-05 19:30:18.000000000 +0000 @@ -1365,7 +1365,6 @@ { writer = new COSWriter( output ); writer.write( this ); - writer.close(); } finally { @@ -1411,7 +1410,6 @@ output.write("\r\n".getBytes("ISO-8859-1")); writer = new COSWriter( output, input ); writer.write( this ); - writer.close(); } finally { diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java 2016-12-05 19:30:20.000000000 +0000 @@ -650,10 +650,11 @@ } /** - * This will get a list of PDThreadBead objects, which are article threads in the - * document. This will return an empty list if there are no thread beads. + * This will get a list of PDThreadBead objects, which are article threads in the document. This + * will return an empty list if there are no thread beads. * - * @return A list of article threads on this page. + * @return A list of article threads on this page, never null. The returned list is backed by + * the beads COSArray, so any adding or deleting in this list will change the document too. */ public List getThreadBeads() { @@ -675,7 +676,6 @@ pdObjects.add( bead ); } return new COSArrayList(pdObjects, beads); - } /** @@ -831,11 +831,12 @@ } /** - * This will return a list of the Annotations for this page. - * - * @return List of the PDAnnotation objects. + * This will return a list of the annotations for this page. * - * @throws IOException If there is an error while creating the annotations. + * @return List of the PDAnnotation objects, never null. The returned list is backed by the + * annotations COSArray, so any adding or deleting in this list will change the document too. + * + * @throws IOException If there is an error while creating the annotation list. */ public List getAnnotations() throws IOException { diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/TextToPDF.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/TextToPDF.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/TextToPDF.java 2016-04-22 16:33:16.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/TextToPDF.java 2016-12-05 19:30:18.000000000 +0000 @@ -24,6 +24,7 @@ import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; +import org.apache.pdfbox.pdmodel.common.PDRectangle; import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; import org.apache.pdfbox.pdmodel.font.PDSimpleFont; @@ -40,6 +41,7 @@ public class TextToPDF { private int fontSize = 10; + private boolean landscape = false; private PDSimpleFont font = PDType1Font.HELVETICA; /** @@ -73,12 +75,17 @@ final int margin = 40; float height = font.getFontDescriptor().getFontBoundingBox().getHeight()/1000; + PDRectangle mediaBox = PDPage.PAGE_SIZE_LETTER; + if (landscape) + { + mediaBox = new PDRectangle(mediaBox.getHeight(), mediaBox.getWidth()); + } //calculate font height and increase by 5 percent. height = height*fontSize*1.05f; BufferedReader data = new BufferedReader( text ); String nextLine = null; - PDPage page = new PDPage(); + PDPage page = new PDPage(mediaBox); PDPageContentStream contentStream = null; float y = -1; float maxStringLength = page.getMediaBox().getWidth() - 2*margin; @@ -94,20 +101,61 @@ // the text. textIsEmpty = false; - String[] lineWords = nextLine.trim().split( " " ); + String[] lineWords = nextLine.replaceAll("[\\n\\r]+$", "").split(" "); int lineIndex = 0; while( lineIndex < lineWords.length ) { - StringBuffer nextLineToDraw = new StringBuffer(); + StringBuilder nextLineToDraw = new StringBuilder(); float lengthIfUsingNextWord = 0; + boolean ff = false; do { - nextLineToDraw.append( lineWords[lineIndex] ); - nextLineToDraw.append( " " ); - lineIndex++; + String word1, word2 = ""; + int indexFF = lineWords[lineIndex].indexOf('\f'); + if (indexFF == -1) + { + word1 = lineWords[lineIndex]; + } + else + { + ff = true; + word1 = lineWords[lineIndex].substring(0, indexFF); + if (indexFF < lineWords[lineIndex].length()) + { + word2 = lineWords[lineIndex].substring(indexFF + 1); + } + } + // word1 is the part before ff, word2 after + // both can be empty + // word1 can also be empty without ff, if a line has many spaces + if (word1.length() > 0 || !ff) + { + nextLineToDraw.append(word1); + nextLineToDraw.append(" "); + } + if (!ff || word2.length() == 0) + { + lineIndex++; + } + else + { + lineWords[lineIndex] = word2; + } + if (ff) + { + break; + } if( lineIndex < lineWords.length ) { - String lineWithNextWord = nextLineToDraw.toString() + lineWords[lineIndex]; + // need cut off at \f in next word to avoid IllegalArgumentException + String nextWord = lineWords[lineIndex]; + indexFF = nextWord.indexOf('\f'); + if (indexFF != -1) + { + nextWord = nextWord.substring(0, indexFF); + } + + String lineWithNextWord = nextLineToDraw.toString() + " " + nextWord; lengthIfUsingNextWord = (font.getStringWidth( lineWithNextWord )/1000) * fontSize; } @@ -118,7 +166,7 @@ { // We have crossed the end-of-page boundary and need to extend the // document by another page. - page = new PDPage(); + page = new PDPage(mediaBox); doc.addPage( page ); if( contentStream != null ) { @@ -142,6 +190,18 @@ contentStream.moveTextPositionByAmount( 0, -height); y -= height; contentStream.drawString( nextLineToDraw.toString() ); + if (ff) + { + page = new PDPage(mediaBox); + doc.addPage(page); + contentStream.endText(); + contentStream.close(); + contentStream = new PDPageContentStream(doc, page); + contentStream.setFont(font, fontSize); + contentStream.beginText(); + y = page.getMediaBox().getHeight() - margin + height; + contentStream.moveTextPositionByAmount(margin, y); + } } @@ -210,6 +270,10 @@ i++; app.setFontSize( Integer.parseInt( args[i] ) ); } + else if( args[i].equals( "-landscape" )) + { + app.setLandscape(true); + } else { throw new IOException( "Unknown argument:" + args[i] ); @@ -243,6 +307,7 @@ } System.err.println( " -ttf The TTF font to use."); System.err.println( " -fontSize default:10" ); + System.err.println( " -landscape sets orientation to landscape" ); } @@ -274,4 +339,25 @@ { this.fontSize = aFontSize; } + + /** + * Tells the paper orientation. + * + * @return + */ + public boolean isLandscape() + { + return landscape; + } + + /** + * Sets paper orientation. + * + * @param landscape + */ + public void setLandscape(boolean landscape) + { + this.landscape = landscape; + } + } diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java 2016-12-05 19:30:18.000000000 +0000 @@ -195,7 +195,7 @@ } String offset = formatTZoffset(cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET), "'"); - return String.format("D:" + return String.format(Locale.US, "D:" + "%1$4tY%1$2tm%1$2td" // yyyyMMdd + "%1$2tH%1$2tM%1$2tS" // HHmmss + "%2$s" // time zone @@ -216,7 +216,7 @@ { String offset = formatTZoffset(cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET), ":"); - return String.format( + return String.format(Locale.US, "%1$4tY" // yyyy + "-%1$2tm" // -mm (%tm adds one to cal month value) + "-%1$2td" // -dd (%tm adds one to cal month value) @@ -227,14 +227,25 @@ } /** - * Constrain a timezone offset to the range [-11:59 thru +11:59]. + * Constrain a timezone offset to the range [-14:00 thru +14:00]. * @param proposedOffset A value intended to be a timezone offset. * @return The corresponding value reduced to the above noted range * by adding or subtracting multiples of a full day. */ public static int restrainTZoffset(long proposedOffset) { + if (proposedOffset <= 14 * MILLIS_PER_HOUR && proposedOffset >= -14 * MILLIS_PER_HOUR) + { + // https://www.w3.org/TR/xmlschema-2/#dateTime-timezones + // Timezones between 14:00 and -14:00 are valid + return (int) proposedOffset; + } + // Constrain a timezone offset to the range [-11:59 thru +12:00]. proposedOffset = ((proposedOffset+HALF_DAY)%DAY+DAY)%DAY; + if (proposedOffset == 0) + { + return HALF_DAY; + } // 0 <= proposedOffset < DAY proposedOffset = (proposedOffset-HALF_DAY)%HALF_DAY; // -HALF_DAY < proposedOffset < HALF_DAY @@ -486,7 +497,7 @@ { // we parsed a time zone in default format int hrSign = (sign == '-' ? -1 :+1); tz.setRawOffset(restrainTZoffset(hrSign*(tzHours*MILLIS_PER_HOUR + tzMin*MILLIS_PER_MINUTE))); - tz.setID("unknown"); + updateZoneId(tz); } else if ( ! hadGMT) { // try to process as a name; "GMT" or "UTC" has already been processed @@ -509,6 +520,43 @@ } /** + * Update the zone ID based on the raw offset. This is either GMT, GMT+hh:mm or GMT-hh:mm, where + * n is between 1 and 14. The highest negative hour is -14, the highest positive hour is 12. + * Zones that don't fit in this schema are set to zone ID "unknown". + * + * @param tz the time zone to update. + */ + private static void updateZoneId(TimeZone tz) + { + // https://garygregory.wordpress.com/2013/06/18/what-are-the-java-timezone-ids/ + int offset = tz.getRawOffset(); + char pm = '+'; + if (offset < 0) + { + pm = '-'; + offset = -offset; + } + int hh = offset / 3600000; + int mm = offset % 3600000 / 60000; + if (offset == 0) + { + tz.setID("GMT"); + } + else if (pm == '+' && hh <= 12) + { + tz.setID(String.format(Locale.US, "GMT+%02d:%02d", hh, mm)); + } + else if (pm == '-' && hh <= 14) + { + tz.setID(String.format(Locale.US, "GMT-%02d:%02d", hh, mm)); + } + else + { + tz.setID("unknown"); + } + } + + /** * Parses a big-endian date: year month day hour min sec. * The year must be four digits. Other fields may be adjacent * and delimited by length or they may follow appropriate delimiters. diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java 2016-12-05 19:30:18.000000000 +0000 @@ -447,6 +447,13 @@ destCatalog.getCOSDictionary().setItem(COSName.METADATA, newStream); } + COSDictionary destOCP = (COSDictionary) destCatalog.getCOSDictionary().getDictionaryObject(COSName.OCPROPERTIES); + COSDictionary srcOCP = (COSDictionary) srcCatalog.getCOSDictionary().getDictionaryObject(COSName.OCPROPERTIES); + if (destOCP == null && srcOCP != null) + { + destCatalog.getCOSDictionary().setItem(COSName.OCPROPERTIES, cloner.cloneForNewDocument(srcOCP)); + } + // merge logical structure hierarchy if logical structure information is available in both source pdf and // destination pdf boolean mergeStructTree = false; diff -Nru libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java --- libpdfbox-java-1.8.12/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java 2016-04-22 16:33:18.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java 2016-12-05 19:30:18.000000000 +0000 @@ -35,6 +35,22 @@ { private static final Log LOG = LogFactory.getLog(TIFFUtil.class); + private static String tagSetClassName = "com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet"; + + static + { + try + { + String alternateClassName = "com.github.jaiimageio.plugins.tiff.BaselineTIFFTagSet"; + Class.forName(alternateClassName); + tagSetClassName = alternateClassName; + } + catch (ClassNotFoundException ex) + { + // ignore + } + } + /** * Sets the ImageIO parameter compression type based on the given image. * @param image buffered image used to decide compression type @@ -81,8 +97,7 @@ if (root.getElementsByTagName("TIFFIFD").getLength() == 0) { ifd = new IIOMetadataNode("TIFFIFD"); - ifd.setAttribute("tagSets", - "com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet"); + ifd.setAttribute("tagSets", tagSetClassName); root.appendChild(ifd); } else diff -Nru libpdfbox-java-1.8.12/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java libpdfbox-java-1.8.13/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java --- libpdfbox-java-1.8.12/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java 2016-04-22 16:33:20.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java 2016-12-05 19:30:12.000000000 +0000 @@ -207,7 +207,10 @@ // check permissions assertEquals(expectedPermissions.isOwnerPermission(), currentAccessPermission.isOwnerPermission()); - assertEquals(expectedPermissions.isReadOnly(), currentAccessPermission.isReadOnly()); + if (!expectedPermissions.isOwnerPermission()) + { + assertEquals(true, currentAccessPermission.isReadOnly()); + } assertEquals(expectedPermissions.canAssembleDocument(), currentAccessPermission.canAssembleDocument()); assertEquals(expectedPermissions.canExtractContent(), currentAccessPermission.canExtractContent()); assertEquals(expectedPermissions.canExtractForAccessibility(), currentAccessPermission.canExtractForAccessibility()); diff -Nru libpdfbox-java-1.8.12/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java libpdfbox-java-1.8.13/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java --- libpdfbox-java-1.8.12/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java 2016-04-22 16:33:20.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java 2016-12-05 19:30:10.000000000 +0000 @@ -108,7 +108,7 @@ assertTrue(outputIntents.isEmpty()); // add an OutputIntent - colorProfile = TestPDDocumentCatalog.class.getResourceAsStream("sRGB Color Space Profile.icm"); + colorProfile = TestPDDocumentCatalog.class.getResourceAsStream("sRGB.icc"); // create output intent PDOutputIntent oi = new PDOutputIntent(doc, colorProfile); oi.setInfo("sRGB IEC61966-2.1"); diff -Nru libpdfbox-java-1.8.12/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java libpdfbox-java-1.8.13/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java --- libpdfbox-java-1.8.12/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java 2016-04-22 16:33:20.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java 2016-12-05 19:30:10.000000000 +0000 @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; +import java.util.Locale; import org.apache.pdfbox.exceptions.COSVisitorException; import org.apache.pdfbox.io.IOUtils; diff -Nru libpdfbox-java-1.8.12/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java libpdfbox-java-1.8.13/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java --- libpdfbox-java-1.8.12/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java 2016-04-22 16:33:20.000000000 +0000 +++ libpdfbox-java-1.8.13/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java 2016-12-05 19:30:12.000000000 +0000 @@ -151,9 +151,9 @@ int hr, int min, int sec, int offsetHours, int offsetMinutes, String orig) throws Exception { - String pdfDate = String.format("D:%04d%02d%02d%02d%02d%02d%+03d'%02d'", + String pdfDate = String.format(Locale.US, "D:%04d%02d%02d%02d%02d%02d%+03d'%02d'", yr,mon,day,hr,min,sec,offsetHours,offsetMinutes); - String iso8601Date = String.format("%04d-%02d-%02d" + String iso8601Date = String.format(Locale.US, "%04d-%02d-%02d" + "T%02d:%02d:%02d%+03d:%02d", yr,mon,day,hr,min,sec,offsetHours,offsetMinutes); Calendar cal = null; @@ -328,6 +328,8 @@ // ambiguous big-endian date checkParse(2073,12,25, 0, 8, 0, 0, 0, "2073 12 25:08"); + // PDFBOX-3315 GMT+12 + checkParse(2016, 4,11,16,01,15, 12, 0, "D:20160411160115+12'00'"); } private static void checkToString(int yr, int mon, int day, @@ -338,9 +340,9 @@ GregorianCalendar cal = new GregorianCalendar(tz, Locale.ENGLISH); cal.set(yr, mon-1, day, hr, min, sec); // create expected strings - String pdfDate = String.format("D:%04d%02d%02d%02d%02d%02d%+03d'%02d'", + String pdfDate = String.format(Locale.US, "D:%04d%02d%02d%02d%02d%02d%+03d'%02d'", yr,mon,day,hr,min,sec,offsetHours, offsetMinutes); - String iso8601Date = String.format("%04d-%02d-%02d" + String iso8601Date = String.format(Locale.US, "%04d-%02d-%02d" + "T%02d:%02d:%02d%+03d:%02d", yr,mon,day,hr,min,sec,offsetHours, offsetMinutes); // compare outputs from toString and toISO8601 with expected values @@ -403,14 +405,15 @@ */ public void testParseTZ() { + // 1st parameter is what to expect checkParseTZ(0*HRS+0*MINS, "+00:00"); checkParseTZ(0*HRS+0*MINS, "-0000"); checkParseTZ(1*HRS+0*MINS, "+1:00"); checkParseTZ(-(1*HRS+0*MINS), "-1:00"); checkParseTZ(-(1*HRS+30*MINS), "-0130"); checkParseTZ(11*HRS+59*MINS, "1159"); - checkParseTZ(-(11*HRS+30*MINS), "1230"); - checkParseTZ(11*HRS+30*MINS, "-12:30"); + checkParseTZ(12*HRS+30*MINS, "1230"); + checkParseTZ(-(12*HRS+30*MINS), "-12:30"); checkParseTZ(0*HRS+0*MINS, "Z"); checkParseTZ(-(8*HRS+0*MINS), "PST"); checkParseTZ(0*HRS+0*MINS, "EDT"); // EDT does not parse @@ -426,6 +429,11 @@ checkParseTZ((5*HRS+0*MINS), "+0500"); checkParseTZ((11*HRS+0*MINS), "+11'00'"); checkParseTZ(0, "Z"); + // PDFBOX-3315, PDFBOX-2420 + checkParseTZ(12*HRS+0*MINS, "+12:00"); + checkParseTZ(-(12*HRS+0*MINS), "-12:00"); + checkParseTZ(14*HRS+0*MINS, "1400"); + checkParseTZ(-(14*HRS+0*MINS), "-1400"); } private static void checkFormatOffset(double off, String expect) @@ -440,22 +448,26 @@ */ public void testFormatTZoffset() { - checkFormatOffset(-12.1, "+11:54"); - checkFormatOffset(12.1, "-11:54"); + // 2nd parameter is what to expect + checkFormatOffset(-12.1, "-12:06"); + checkFormatOffset(12.1, "+12:06"); checkFormatOffset(0, "+00:00"); checkFormatOffset(-1, "-01:00"); checkFormatOffset(.5, "+00:30"); checkFormatOffset(-0.5, "-00:30"); checkFormatOffset(.1, "+00:06"); checkFormatOffset(-0.1, "-00:06"); - checkFormatOffset(-12, "+00:00"); - checkFormatOffset(12, "+00:00"); + checkFormatOffset(-12, "-12:00"); + checkFormatOffset(12, "+12:00"); checkFormatOffset(-11.5, "-11:30"); checkFormatOffset(11.5, "+11:30"); checkFormatOffset(11.9, "+11:54"); checkFormatOffset(11.1, "+11:06"); checkFormatOffset(-11.9, "-11:54"); checkFormatOffset(-11.1, "-11:06"); + // PDFBOX-2420 + checkFormatOffset(14, "+14:00"); + checkFormatOffset(-14, "-14:00"); } // testbody precedes diff -Nru libpdfbox-java-1.8.12/pom.xml libpdfbox-java-1.8.13/pom.xml --- libpdfbox-java-1.8.12/pom.xml 2016-04-22 16:33:24.000000000 +0000 +++ libpdfbox-java-1.8.13/pom.xml 2016-12-05 19:30:08.000000000 +0000 @@ -23,7 +23,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 parent/pom.xml @@ -34,12 +34,12 @@ - scm:svn:http://svn.apache.org/repos/asf/pdfbox/tags/1.8.12 + scm:svn:http://svn.apache.org/repos/asf/pdfbox/tags/1.8.13 - scm:svn:https://svn.apache.org/repos/asf/pdfbox/tags/1.8.12 + scm:svn:https://svn.apache.org/repos/asf/pdfbox/tags/1.8.13 - http://svn.apache.org/viewvc/pdfbox/tags/1.8.12 + http://svn.apache.org/viewvc/pdfbox/tags/1.8.13 diff -Nru libpdfbox-java-1.8.12/preflight/pom.xml libpdfbox-java-1.8.13/preflight/pom.xml --- libpdfbox-java-1.8.12/preflight/pom.xml 2016-04-22 16:33:24.000000000 +0000 +++ libpdfbox-java-1.8.13/preflight/pom.xml 2016-12-05 19:30:08.000000000 +0000 @@ -26,7 +26,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml @@ -91,8 +91,12 @@ com.googlecode.maven-download-plugin - download-maven-plugin - 1.2.1 + + maven-download-plugin + 1.1.0 + + ${skipTests} + get-isartor @@ -101,7 +105,7 @@ wget - http://www.pdfa.org/wp-content/uploads/2011/08/isartor-pdfa-2008-08-13.zip + https://www.pdfa.org/wp-content/until2016_uploads/2011/08/isartor-pdfa-2008-08-13.zip true ${project.build.directory}/pdfs 9f129c834bc6f9f8dabad4491c4c10ec diff -Nru libpdfbox-java-1.8.12/preflight/src/main/java/org/apache/pdfbox/preflight/metadata/PDFAIdentificationValidation.java libpdfbox-java-1.8.13/preflight/src/main/java/org/apache/pdfbox/preflight/metadata/PDFAIdentificationValidation.java --- libpdfbox-java-1.8.12/preflight/src/main/java/org/apache/pdfbox/preflight/metadata/PDFAIdentificationValidation.java 2016-04-22 16:33:22.000000000 +0000 +++ libpdfbox-java-1.8.13/preflight/src/main/java/org/apache/pdfbox/preflight/metadata/PDFAIdentificationValidation.java 2016-12-05 19:30:08.000000000 +0000 @@ -85,7 +85,7 @@ } } checkConformanceLevel(ve, id.getConformance()); - checkPartNumber(ve, id.getPart()); + checkPartNumber(ve, id.getPart() == null ? -1 : id.getPart()); return ve; } diff -Nru libpdfbox-java-1.8.12/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightPath.java libpdfbox-java-1.8.13/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightPath.java --- libpdfbox-java-1.8.12/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightPath.java 2016-04-22 16:33:22.000000000 +0000 +++ libpdfbox-java-1.8.13/preflight/src/test/java/org/apache/pdfbox/preflight/TestPreflightPath.java 2016-12-05 19:30:08.000000000 +0000 @@ -63,7 +63,7 @@ assertEquals(1, position); Integer i = path.getPathElement(position, Integer.class); - assertEquals(new Integer(6), i); + assertEquals(Integer.valueOf(6), i); Object str = path.peek(); assertEquals(3, path.size()); diff -Nru libpdfbox-java-1.8.12/preflight-app/pom.xml libpdfbox-java-1.8.13/preflight-app/pom.xml --- libpdfbox-java-1.8.12/preflight-app/pom.xml 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/preflight-app/pom.xml 2016-12-05 19:30:08.000000000 +0000 @@ -23,7 +23,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml diff -Nru libpdfbox-java-1.8.12/RELEASE-NOTES.txt libpdfbox-java-1.8.13/RELEASE-NOTES.txt --- libpdfbox-java-1.8.12/RELEASE-NOTES.txt 2016-04-22 16:33:22.000000000 +0000 +++ libpdfbox-java-1.8.13/RELEASE-NOTES.txt 2016-12-05 19:30:08.000000000 +0000 @@ -1,11 +1,11 @@ -Release Notes -- Apache PDFBox -- Version 1.8.12 +Release Notes -- Apache PDFBox -- Version 1.8.13 Introduction ------------ The Apache PDFBox library is an open source Java tool for working with PDF documents. -This is an incremental bugfix release based on the earlier 1.8.11 release. It +This is an incremental bugfix release based on the earlier 1.8.12 release. It contains a couple of fixes and small improvements. For more details on all fixes included in this release, please refer to the following @@ -13,40 +13,50 @@ Bug -[PDFBOX-1995] - AdobePDFSchema.getProducer() returns empty string -[PDFBOX-2428] - An error occured when reading table hmtx -[PDFBOX-3024] - Preflight validation call PDType0Font.clear at the wrong time -[PDFBOX-3116] - COSNumber NumberFormatException for large number -[PDFBOX-3201] - Skip zlib-header and checksum to avoid DataFormatException -[PDFBOX-3204] - JVM crashes on PDFRenderer.renderImageWithDPI -[PDFBOX-3217] - PdfaExtensionHelper.populatePDFAPropertyType -[PDFBOX-3226] - No such Element Exception processing File -[PDFBOX-3229] - Decryption fails when Metadata not encrypted but EncryptMetadata is true/default. -[PDFBOX-3235] - ColorSpace validation fails for inlined image -[PDFBOX-3237] - ASCII85Filter does not use or recognize the correct end-of-data terminator -[PDFBOX-3254] - Corrupted XMP causes java.lang.StringIndexOutOfBoundsException -[PDFBOX-3257] - XMPSchemaBasic setCreateDate and setModifyDate don't work if already set -[PDFBOX-3258] - XMPBox XMPBasicSchema setters don't work if already set -[PDFBOX-3259] - ClassCastException in PDTilingPattern.getContents -[PDFBOX-3285] - All lines that use a given font stop rendering if 'รถ' is inserted - -ArrayIndexOutOfBoundsException in TTFSubFont.buildPostTable -[PDFBOX-3297] - Infinite loop -[PDFBOX-3299] - TIFF-files with FillOrder=2 can't be converted to PDF -[PDFBOX-3308] - Missing endOfName chars -[PDFBOX-3321] - ASCII stream data size is increased when written +[PDFBOX-2420] - DateConverter doesn't handle time zones outside -12 to +12 range properly +[PDFBOX-2919] - org.apache.fontbox.cff.CFFParser.readEntry sometimes throws java.lang.IllegalArgumentException +[PDFBOX-3315] - Dates falsely detected as different by preflight +[PDFBOX-3335] - Issue while Merging PDF with Hidden Layers +[PDFBOX-3341] - currentAccessPermission.setReadOnly() not set in StandardSecurityHandler +[PDFBOX-3355] - PDPageLabels.getLabelsByPageIndices() returns Uppercase letters for style a +[PDFBOX-3368] - ContainsKey don't work for the Map returned by PDStructureTreeRoot.getRoleMap +[PDFBOX-3369] - Error expected floating point number actual='0.00-35095424' +[PDFBOX-3409] - TextToPDF drops leading spaces +[PDFBOX-3420] - Can't sign pdf with a particular attachment +[PDFBOX-3446] - Infinite loop while parsing +[PDFBOX-3448] - NullPointerException at org.apache.pdfbox.pdmodel.common.COSArrayList.convertFloatCOSArrayToList +[PDFBOX-3450] - ArrayIndexOutOfBoundsException at org.apache.fontbox.cmap.CMapParser.increment +[PDFBOX-3463] - XMPSchemaBasic.getLabel() always returns null +[PDFBOX-3466] - Java 9 warnings +[PDFBOX-3472] - NPE when PDF/A identification metadata does not contain ID +[PDFBOX-3477] - CA and ca values should be clipped +[PDFBOX-3481] - Localization in XRef generation results in unusable PDFs +[PDFBOX-3487] - ClassCastException in COSWriter.write() when saving PDF +[PDFBOX-3491] - NumberFormatException in CFFParser.readRealNumber +[PDFBOX-3500] - Error expected floating point number actual='0.-262' +[PDFBOX-3532] - Java 6 errors +[PDFBOX-3546] - IOException over DataFormatException, "invalid stored block lengths" on a valid PDF +[PDFBOX-3551] - CLI Decrypt broken, only allows 1 argument +[PDFBOX-3555] - FlateFilter.decode cause native memory leaks +[PDFBOX-3558] - NPE in JBig2Filter if BitsPerComponent is missing +[PDFBOX-3570] - JDK-8054565 Java 8 close contract issue +[PDFBOX-3571] - sRGB Color Space Profile is subject to 3rd party copyright +[PDFBOX-3578] - java.lang.IllegalArgumentException: dash lengths all zero +[PDFBOX-3590] - AccessPermission not applied +[PDFBOX-3594] - Use PDOutlineItem#findDestinationPage() cannot get PDPage, return was null +[PDFBOX-3609] - ClassCastException in PDCIDFont.readWidths() Improvement -[PDFBOX-1840] - Automatically load isartor for preflight tests -[PDFBOX-3196] - Update maven plugins and apache parent pom -[PDFBOX-3231] - Update PDPropBuildDataDict -[PDFBOX-3251] - Improve parsing and validation of ColorSpace for inline image -[PDFBOX-3295] - Improve parsing performance of object streams +[PDFBOX-3352] - Calendar values are parsed with unknown timezones -Wish +New Feature -[PDFBOX-3241] - return original PDF Header +[PDFBOX-3410] - TextToPDF needs orientation control +Task + +[PDFBOX-3577] - remove mygrid repository in 1.8 Release Contents ---------------- diff -Nru libpdfbox-java-1.8.12/war/pom.xml libpdfbox-java-1.8.13/war/pom.xml --- libpdfbox-java-1.8.12/war/pom.xml 2016-04-22 16:33:24.000000000 +0000 +++ libpdfbox-java-1.8.13/war/pom.xml 2016-12-05 19:30:08.000000000 +0000 @@ -23,7 +23,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml diff -Nru libpdfbox-java-1.8.12/xmpbox/pom.xml libpdfbox-java-1.8.13/xmpbox/pom.xml --- libpdfbox-java-1.8.12/xmpbox/pom.xml 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/xmpbox/pom.xml 2016-12-05 19:30:08.000000000 +0000 @@ -27,7 +27,7 @@ org.apache.pdfbox pdfbox-parent - 1.8.12 + 1.8.13 ../parent/pom.xml diff -Nru libpdfbox-java-1.8.12/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java libpdfbox-java-1.8.13/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java --- libpdfbox-java-1.8.12/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/xmpbox/src/main/java/org/apache/xmpbox/DateConverter.java 2016-12-05 19:30:08.000000000 +0000 @@ -28,6 +28,7 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.SimpleTimeZone; +import java.util.TimeZone; /** * This class is used to convert dates to strings and back using the PDF date standards. Date are described in @@ -174,6 +175,7 @@ } else { + updateZoneId(zone); retval = new GregorianCalendar(zone); } retval.clear(); @@ -217,6 +219,43 @@ } /** + * Update the zone ID based on the raw offset. This is either GMT, GMT+hh:mm or GMT-hh:mm, where + * n is between 1 and 14. The highest negative hour is -14, the highest positive hour is 12. + * Zones that don't fit in this schema are set to zone ID "unknown". + * + * @param tz the time zone to update. + */ + private static void updateZoneId(TimeZone tz) + { + // https://garygregory.wordpress.com/2013/06/18/what-are-the-java-timezone-ids/ + int offset = tz.getRawOffset(); + char pm = '+'; + if (offset < 0) + { + pm = '-'; + offset = -offset; + } + int hh = offset / 3600000; + int mm = offset % 3600000 / 60000; + if (offset == 0) + { + tz.setID("GMT"); + } + else if (pm == '+' && hh <= 12) + { + tz.setID(String.format("GMT+%02d:%02d", hh, mm)); + } + else if (pm == '-' && hh <= 14) + { + tz.setID(String.format("GMT-%02d:%02d", hh, mm)); + } + else + { + tz.setID("unknown"); + } + } + + /** * Append Zero to String Buffer before number < 10 ('1' become '01') * * @param out diff -Nru libpdfbox-java-1.8.12/xmpbox/src/main/java/org/apache/xmpbox/schema/PDFAIdentificationSchema.java libpdfbox-java-1.8.13/xmpbox/src/main/java/org/apache/xmpbox/schema/PDFAIdentificationSchema.java --- libpdfbox-java-1.8.12/xmpbox/src/main/java/org/apache/xmpbox/schema/PDFAIdentificationSchema.java 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/xmpbox/src/main/java/org/apache/xmpbox/schema/PDFAIdentificationSchema.java 2016-12-05 19:30:08.000000000 +0000 @@ -190,7 +190,7 @@ /** * Give the PDFAVersionId (as an integer) * - * @return Part value (Integer) + * @return Part value (Integer) or null if it is missing */ public Integer getPart() { diff -Nru libpdfbox-java-1.8.12/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java libpdfbox-java-1.8.13/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java --- libpdfbox-java-1.8.12/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java 2016-04-22 16:33:12.000000000 +0000 +++ libpdfbox-java-1.8.13/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java 2016-12-05 19:30:08.000000000 +0000 @@ -143,14 +143,14 @@ Assert.assertEquals(2, thumbs.size()); ThumbnailType thumb = thumbs.get(0); - Assert.assertEquals(new Integer(162), thumb.getHeight()); - Assert.assertEquals(new Integer(216), thumb.getWidth()); + Assert.assertEquals(Integer.valueOf(162), thumb.getHeight()); + Assert.assertEquals(Integer.valueOf(216), thumb.getWidth()); Assert.assertEquals("JPEG", thumb.getFormat()); Assert.assertEquals("/9j/4AAQSkZJRgABAgEASABIAAD", thumb.getImage()); thumb = thumbs.get(1); - Assert.assertEquals(new Integer(162), thumb.getHeight()); - Assert.assertEquals(new Integer(216), thumb.getWidth()); + Assert.assertEquals(Integer.valueOf(162), thumb.getHeight()); + Assert.assertEquals(Integer.valueOf(216), thumb.getWidth()); Assert.assertEquals("JPEG", thumb.getFormat()); Assert.assertEquals("/9j/4AAQSkZJRgABAgEASABIAAD", thumb.getImage());