svn commit: r1917598 - /pdfbox/branches/2.0/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt
Author: tilman Date: Thu May 9 08:43:24 2024 New Revision: 1917598 URL: http://svn.apache.org/viewvc?rev=1917598&view=rev Log: PDFBOX-5818: update Scripts.txt, as suggested by Dieter von Holten Modified: pdfbox/branches/2.0/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt Modified: pdfbox/branches/2.0/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt?rev=1917598&r1=1917597&r2=1917598&view=diff == --- pdfbox/branches/2.0/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt (original) +++ pdfbox/branches/2.0/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt Thu May 9 08:43:24 2024 @@ -1,16 +1,16 @@ -# Scripts-10.0.0.txt -# Date: 2017-03-11, 06:40:37 GMT -# © 2017 Unicode®, Inc. +# Scripts-15.1.0.txt +# Date: 2023-07-28, 16:01:07 GMT +# © 2023 Unicode®, Inc. # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries. -# For terms of use, see http://www.unicode.org/terms_of_use.html +# For terms of use, see https://www.unicode.org/terms_of_use.html # # Unicode Character Database -# For documentation, see http://www.unicode.org/reports/tr44/ +# For documentation, see https://www.unicode.org/reports/tr44/ # For more information, see: -# UAX #24, Unicode Script Property: http://www.unicode.org/reports/tr24/ +# UAX #24, Unicode Script Property: https://www.unicode.org/reports/tr24/ # Especially the sections: -# http://www.unicode.org/reports/tr24/#Assignment_Script_Values -# http://www.unicode.org/reports/tr24/#Assignment_ScriptX_Values +# https://www.unicode.org/reports/tr24/#Assignment_Script_Values +# https://www.unicode.org/reports/tr24/#Assignment_ScriptX_Values # # @@ -89,7 +89,6 @@ 037E ; Common # Po GREEK QUESTION MARK 0385 ; Common # Sk GREEK DIALYTIKA TONOS 0387 ; Common # Po GREEK ANO TELEIA -0589 ; Common # Po ARMENIAN FULL STOP 0605 ; Common # Cf ARABIC NUMBER MARK ABOVE 060C ; Common # Po ARABIC COMMA 061B ; Common # Po ARABIC SEMICOLON @@ -108,10 +107,10 @@ 1CD3 ; Common # Po VEDIC SIGN NIHSHVASA 1CE1 ; Common # Mc VEDIC TONE ATHARVAVEDIC INDEPENDENT SVARITA 1CE9..1CEC; Common # Lo [4] VEDIC SIGN ANUSVARA ANTARGOMUKHA..VEDIC SIGN ANUSVARA VAMAGOMUKHA WITH TAIL -1CEE..1CF1; Common # Lo [4] VEDIC SIGN HEXIFORM LONG ANUSVARA..VEDIC SIGN ANUSVARA UBHAYATO MUKHA -1CF2..1CF3; Common # Mc [2] VEDIC SIGN ARDHAVISARGA..VEDIC SIGN ROTATED ARDHAVISARGA +1CEE..1CF3; Common # Lo [6] VEDIC SIGN HEXIFORM LONG ANUSVARA..VEDIC SIGN ROTATED ARDHAVISARGA 1CF5..1CF6; Common # Lo [2] VEDIC SIGN JIHVAMULIYA..VEDIC SIGN UPADHMANIYA 1CF7 ; Common # Mc VEDIC SIGN ATIKRAMA +1CFA ; Common # Lo VEDIC SIGN DOUBLE ANUSVARA ANTARGOMUKHA 2000..200A; Common # Zs [11] EN QUAD..HAIR SPACE 200B ; Common # Cf ZERO WIDTH SPACE 200E..200F; Common # Cf [2] LEFT-TO-RIGHT MARK..RIGHT-TO-LEFT MARK @@ -155,7 +154,7 @@ 208A..208C; Common # Sm [3] SUBSCRIPT PLUS SIGN..SUBSCRIPT EQUALS SIGN 208D ; Common # Ps SUBSCRIPT LEFT PARENTHESIS 208E ; Common # Pe SUBSCRIPT RIGHT PARENTHESIS -20A0..20BF; Common # Sc [32] EURO-CURRENCY SIGN..BITCOIN SIGN +20A0..20C0; Common # Sc [33] EURO-CURRENCY SIGN..SOM SIGN 2100..2101; Common # So [2] ACCOUNT OF..ADDRESSED TO THE SUBJECT 2102 ; Common # L& DOUBLE-STRUCK CAPITAL C 2103..2106; Common # So [4] DEGREE CELSIUS..CADA UNA @@ -308,10 +307,7 @@ 2B47..2B4C; Common # Sm [6] REVERSE TILDE OPERATOR ABOVE RIGHTWARDS ARROW..RIGHTWARDS ARROW ABOVE REVERSE TILDE OPERATOR 2B4D..2B73; Common # So [39] DOWNWARDS TRIANGLE-HEADED ZIGZAG ARROW..DOWNWARDS TRIANGLE-HEADED ARROW TO BAR 2B76..2B95; Common # So [32] NORTH WEST TRIANGLE-HEADED ARROW TO BAR..RIGHTWARDS BLACK ARROW -2B98..2BB9; Common # So [34] THREE-D TOP-LIGHTED LEFTWARDS EQUILATERAL ARROWHEAD..UP ARROWHEAD IN A RECTANGLE BOX -2BBD..2BC8; Common # So [12] BALLOT BOX WITH LIGHT X..BLACK MEDIUM RIGHT-POINTING TRIANGLE CENTRED -2BCA..2BD2; Common # So [9] TOP HALF BLACK CIRCLE..GROUP MARK -2BEC..2BEF; Common # So [4] LEFTWARDS TWO-HEADED ARROW WITH TRIANGLE ARROWHEADS..DOWNWARDS TWO-HEADED ARROW WITH TRIANGLE ARROWHEADS +2B97..2BFF; Common # So [105] SYMBOL FOR TYPE A ELECTRONICS..HELLSCHREIBER PAUSE SYMBOL 2E00..2E01; Common # Po [2] RIGHT ANGLE SUBSTITUTION MARKER..RIGHT ANGLE DOTTED SUBSTITUTION MARKER 2E02 ; Common # Pi LEFT SUBSTI
svn commit: r1917599 - /pdfbox/trunk/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt
Author: tilman Date: Thu May 9 08:43:28 2024 New Revision: 1917599 URL: http://svn.apache.org/viewvc?rev=1917599&view=rev Log: PDFBOX-5818: update Scripts.txt, as suggested by Dieter von Holten Modified: pdfbox/trunk/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt Modified: pdfbox/trunk/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt?rev=1917599&r1=1917598&r2=1917599&view=diff == --- pdfbox/trunk/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt (original) +++ pdfbox/trunk/fontbox/src/main/resources/org/apache/fontbox/unicode/Scripts.txt Thu May 9 08:43:28 2024 @@ -1,16 +1,16 @@ -# Scripts-10.0.0.txt -# Date: 2017-03-11, 06:40:37 GMT -# © 2017 Unicode®, Inc. +# Scripts-15.1.0.txt +# Date: 2023-07-28, 16:01:07 GMT +# © 2023 Unicode®, Inc. # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries. -# For terms of use, see http://www.unicode.org/terms_of_use.html +# For terms of use, see https://www.unicode.org/terms_of_use.html # # Unicode Character Database -# For documentation, see http://www.unicode.org/reports/tr44/ +# For documentation, see https://www.unicode.org/reports/tr44/ # For more information, see: -# UAX #24, Unicode Script Property: http://www.unicode.org/reports/tr24/ +# UAX #24, Unicode Script Property: https://www.unicode.org/reports/tr24/ # Especially the sections: -# http://www.unicode.org/reports/tr24/#Assignment_Script_Values -# http://www.unicode.org/reports/tr24/#Assignment_ScriptX_Values +# https://www.unicode.org/reports/tr24/#Assignment_Script_Values +# https://www.unicode.org/reports/tr24/#Assignment_ScriptX_Values # # @@ -89,7 +89,6 @@ 037E ; Common # Po GREEK QUESTION MARK 0385 ; Common # Sk GREEK DIALYTIKA TONOS 0387 ; Common # Po GREEK ANO TELEIA -0589 ; Common # Po ARMENIAN FULL STOP 0605 ; Common # Cf ARABIC NUMBER MARK ABOVE 060C ; Common # Po ARABIC COMMA 061B ; Common # Po ARABIC SEMICOLON @@ -108,10 +107,10 @@ 1CD3 ; Common # Po VEDIC SIGN NIHSHVASA 1CE1 ; Common # Mc VEDIC TONE ATHARVAVEDIC INDEPENDENT SVARITA 1CE9..1CEC; Common # Lo [4] VEDIC SIGN ANUSVARA ANTARGOMUKHA..VEDIC SIGN ANUSVARA VAMAGOMUKHA WITH TAIL -1CEE..1CF1; Common # Lo [4] VEDIC SIGN HEXIFORM LONG ANUSVARA..VEDIC SIGN ANUSVARA UBHAYATO MUKHA -1CF2..1CF3; Common # Mc [2] VEDIC SIGN ARDHAVISARGA..VEDIC SIGN ROTATED ARDHAVISARGA +1CEE..1CF3; Common # Lo [6] VEDIC SIGN HEXIFORM LONG ANUSVARA..VEDIC SIGN ROTATED ARDHAVISARGA 1CF5..1CF6; Common # Lo [2] VEDIC SIGN JIHVAMULIYA..VEDIC SIGN UPADHMANIYA 1CF7 ; Common # Mc VEDIC SIGN ATIKRAMA +1CFA ; Common # Lo VEDIC SIGN DOUBLE ANUSVARA ANTARGOMUKHA 2000..200A; Common # Zs [11] EN QUAD..HAIR SPACE 200B ; Common # Cf ZERO WIDTH SPACE 200E..200F; Common # Cf [2] LEFT-TO-RIGHT MARK..RIGHT-TO-LEFT MARK @@ -155,7 +154,7 @@ 208A..208C; Common # Sm [3] SUBSCRIPT PLUS SIGN..SUBSCRIPT EQUALS SIGN 208D ; Common # Ps SUBSCRIPT LEFT PARENTHESIS 208E ; Common # Pe SUBSCRIPT RIGHT PARENTHESIS -20A0..20BF; Common # Sc [32] EURO-CURRENCY SIGN..BITCOIN SIGN +20A0..20C0; Common # Sc [33] EURO-CURRENCY SIGN..SOM SIGN 2100..2101; Common # So [2] ACCOUNT OF..ADDRESSED TO THE SUBJECT 2102 ; Common # L& DOUBLE-STRUCK CAPITAL C 2103..2106; Common # So [4] DEGREE CELSIUS..CADA UNA @@ -308,10 +307,7 @@ 2B47..2B4C; Common # Sm [6] REVERSE TILDE OPERATOR ABOVE RIGHTWARDS ARROW..RIGHTWARDS ARROW ABOVE REVERSE TILDE OPERATOR 2B4D..2B73; Common # So [39] DOWNWARDS TRIANGLE-HEADED ZIGZAG ARROW..DOWNWARDS TRIANGLE-HEADED ARROW TO BAR 2B76..2B95; Common # So [32] NORTH WEST TRIANGLE-HEADED ARROW TO BAR..RIGHTWARDS BLACK ARROW -2B98..2BB9; Common # So [34] THREE-D TOP-LIGHTED LEFTWARDS EQUILATERAL ARROWHEAD..UP ARROWHEAD IN A RECTANGLE BOX -2BBD..2BC8; Common # So [12] BALLOT BOX WITH LIGHT X..BLACK MEDIUM RIGHT-POINTING TRIANGLE CENTRED -2BCA..2BD2; Common # So [9] TOP HALF BLACK CIRCLE..GROUP MARK -2BEC..2BEF; Common # So [4] LEFTWARDS TWO-HEADED ARROW WITH TRIANGLE ARROWHEADS..DOWNWARDS TWO-HEADED ARROW WITH TRIANGLE ARROWHEADS +2B97..2BFF; Common # So [105] SYMBOL FOR TYPE A ELECTRONICS..HELLSCHREIBER PAUSE SYMBOL 2E00..2E01; Common # Po [2] RIGHT ANGLE SUBSTITUTION MARKER..RIGHT ANGLE DOTTED SUBSTITUTION MARKER 2E02 ; Common # Pi LEFT SUBSTITUTION BRACKET 2E03 ; Com
svn commit: r1917617 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Author: tilman Date: Thu May 9 12:44:33 2024 New Revision: 1917617 URL: http://svn.apache.org/viewvc?rev=1917617&view=rev Log: PDFBOX-5820: add more logging Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java?rev=1917617&r1=1917616&r2=1917617&view=diff == --- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java (original) +++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Thu May 9 12:44:33 2024 @@ -31,6 +31,7 @@ import java.util.Random; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.pdfbox.util.Hex; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder; import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder; @@ -104,7 +105,7 @@ public class TSAClient // get TSA response byte[] tsaResponse = getTSAResponse(request.getEncoded()); -TimeStampResponse response; +TimeStampResponse response = null; try { response = new TimeStampResponse(tsaResponse); @@ -112,6 +113,14 @@ public class TSAClient } catch (TSPException e) { +LOG.error(String.format("nonce: %08X", nonce)); +LOG.error("request: " + Hex.getString(request.getEncoded())); +if (response != null) +{ +LOG.error("response status: " + response.getStatus() + " " + response.getStatusString()); +LOG.error("response tst: " + response.getTimeStampToken()); +} +LOG.error("response: " + Hex.getString(tsaResponse)); throw new IOException(e); }
svn commit: r1917619 - /pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Author: tilman Date: Thu May 9 12:48:16 2024 New Revision: 1917619 URL: http://svn.apache.org/viewvc?rev=1917619&view=rev Log: PDFBOX-5820: add more logging Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java?rev=1917619&r1=1917618&r2=1917619&view=diff == --- pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java (original) +++ pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Thu May 9 12:48:16 2024 @@ -32,6 +32,7 @@ import java.util.Random; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.io.IOUtils; +import org.apache.pdfbox.util.Hex; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder; import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder; @@ -105,7 +106,7 @@ public class TSAClient // get TSA response byte[] tsaResponse = getTSAResponse(request.getEncoded()); -TimeStampResponse response; +TimeStampResponse response = null; try { response = new TimeStampResponse(tsaResponse); @@ -113,6 +114,14 @@ public class TSAClient } catch (TSPException e) { +LOG.error(String.format("nonce: %08X", nonce)); +LOG.error("request: " + Hex.getString(request.getEncoded())); +if (response != null) +{ +LOG.error("response status: " + response.getStatus() + " " + response.getStatusString()); +LOG.error("response tst: " + response.getTimeStampToken()); +} +LOG.error("response: " + Hex.getString(tsaResponse)); throw new IOException(e); }
svn commit: r1917620 - /pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
Author: tilman Date: Thu May 9 13:51:47 2024 New Revision: 1917620 URL: http://svn.apache.org/viewvc?rev=1917620&view=rev Log: PDFBOX-5812: Sonar fix Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java?rev=1917620&r1=1917619&r2=1917620&view=diff == --- pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java (original) +++ pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Thu May 9 13:51:47 2024 @@ -660,10 +660,6 @@ this.getClass().getResourceAsStream("/or { assertEquals("could not find the glyphId for the character: ã", e.getMessage()); } -catch (Exception e) -{ -fail(); -} } @Test @@ -692,9 +688,5 @@ this.getClass().getResourceAsStream("/or { assertEquals("could not find the glyphId for the character: 𩸽" ,e.getMessage()); } -catch (Exception e) -{ -fail(); -} } }
svn commit: r1917621 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
Author: tilman Date: Thu May 9 13:51:57 2024 New Revision: 1917621 URL: http://svn.apache.org/viewvc?rev=1917621&view=rev Log: PDFBOX-5812: Sonar fix Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java?rev=1917621&r1=1917620&r2=1917621&view=diff == --- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java (original) +++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Thu May 9 13:51:57 2024 @@ -661,10 +661,6 @@ class TestFontEmbedding { assertEquals("could not find the glyphId for the character: ã", e.getMessage()); } -catch (Exception e) -{ -fail(); -} } @Test @@ -693,9 +689,5 @@ class TestFontEmbedding { assertEquals("could not find the glyphId for the character: 𩸽" ,e.getMessage()); } -catch (Exception e) -{ -fail(); -} } }
svn commit: r1917622 - /pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
Author: tilman Date: Thu May 9 14:46:49 2024 New Revision: 1917622 URL: http://svn.apache.org/viewvc?rev=1917622&view=rev Log: PDFBOX-5812: Sonar fix Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java?rev=1917622&r1=1917621&r2=1917622&view=diff == --- pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java (original) +++ pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Thu May 9 14:46:49 2024 @@ -653,13 +653,14 @@ this.getClass().getResourceAsStream("/or contents.showText(message); contents.endText(); } +catch (IllegalStateException e) +{ +assertEquals("could not find the glyphId for the character: ã", e.getMessage()); +return; +} fail(); } -catch (IllegalStateException e) -{ -assertEquals("could not find the glyphId for the character: ã", e.getMessage()); -} } @Test @@ -681,12 +682,13 @@ this.getClass().getResourceAsStream("/or contents.showText(message); contents.endText(); } +catch (IllegalStateException e) +{ +assertEquals("could not find the glyphId for the character: 𩸽" ,e.getMessage()); +return; +} fail(); } -catch (IllegalStateException e) -{ -assertEquals("could not find the glyphId for the character: 𩸽" ,e.getMessage()); -} } }
svn commit: r1917623 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
Author: tilman Date: Thu May 9 14:47:01 2024 New Revision: 1917623 URL: http://svn.apache.org/viewvc?rev=1917623&view=rev Log: PDFBOX-5812: Sonar fix Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java?rev=1917623&r1=1917622&r2=1917623&view=diff == --- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java (original) +++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Thu May 9 14:47:01 2024 @@ -654,13 +654,14 @@ class TestFontEmbedding contents.showText(message); contents.endText(); } +catch (IllegalStateException e) +{ +assertEquals("could not find the glyphId for the character: ã", e.getMessage()); +return; +} fail(); } -catch (IllegalStateException e) -{ -assertEquals("could not find the glyphId for the character: ã", e.getMessage()); -} } @Test @@ -682,12 +683,13 @@ class TestFontEmbedding contents.showText(message); contents.endText(); } +catch (IllegalStateException e) +{ +assertEquals("could not find the glyphId for the character: 𩸽", e.getMessage()); +return; +} fail(); } -catch (IllegalStateException e) -{ -assertEquals("could not find the glyphId for the character: 𩸽" ,e.getMessage()); -} } }
svn commit: r1917625 - /pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Author: tilman Date: Thu May 9 19:01:34 2024 New Revision: 1917625 URL: http://svn.apache.org/viewvc?rev=1917625&view=rev Log: PDFBOX-5820: add more logging Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java?rev=1917625&r1=1917624&r2=1917625&view=diff == --- pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java (original) +++ pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Thu May 9 19:01:34 2024 @@ -41,6 +41,7 @@ import org.bouncycastle.tsp.TimeStampReq import org.bouncycastle.tsp.TimeStampRequestGenerator; import org.bouncycastle.tsp.TimeStampResponse; import org.bouncycastle.tsp.TimeStampToken; +import org.bouncycastle.tsp.TimeStampTokenInfo; /** * Time Stamping Authority (TSA) Client [RFC 3161]. @@ -114,12 +115,25 @@ public class TSAClient } catch (TSPException e) { -LOG.error(String.format("nonce: %08X", nonce)); LOG.error("request: " + Hex.getString(request.getEncoded())); +LOG.error(String.format("request nonce: %08X / %s", nonce, request.getNonce().toString(16))); if (response != null) { LOG.error("response status: " + response.getStatus() + " " + response.getStatusString()); LOG.error("response tst: " + response.getTimeStampToken()); +if (response.getTimeStampToken() != null) +{ +TimeStampTokenInfo tsi = response.getTimeStampToken().getTimeStampInfo(); +LOG.error("response tsi: " + tsi); +if (tsi != null && tsi.getNonce() != null) +{ +LOG.error("response tsi nonce: " + tsi.getNonce().toString(16)); +} +else if (tsi != null) +{ +LOG.error("response tsi nonce is null"); +} +} } LOG.error("response: " + Hex.getString(tsaResponse)); throw new IOException(e);
svn commit: r1917626 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Author: tilman Date: Thu May 9 19:01:38 2024 New Revision: 1917626 URL: http://svn.apache.org/viewvc?rev=1917626&view=rev Log: PDFBOX-5820: add more logging Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java?rev=1917626&r1=1917625&r2=1917626&view=diff == --- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java (original) +++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Thu May 9 19:01:38 2024 @@ -40,6 +40,7 @@ import org.bouncycastle.tsp.TimeStampReq import org.bouncycastle.tsp.TimeStampRequestGenerator; import org.bouncycastle.tsp.TimeStampResponse; import org.bouncycastle.tsp.TimeStampToken; +import org.bouncycastle.tsp.TimeStampTokenInfo; /** * Time Stamping Authority (TSA) Client [RFC 3161]. @@ -113,12 +114,25 @@ public class TSAClient } catch (TSPException e) { -LOG.error(String.format("nonce: %08X", nonce)); LOG.error("request: " + Hex.getString(request.getEncoded())); +LOG.error(String.format("request nonce: %08X / %s", nonce, request.getNonce().toString(16))); if (response != null) { LOG.error("response status: " + response.getStatus() + " " + response.getStatusString()); LOG.error("response tst: " + response.getTimeStampToken()); +if (response.getTimeStampToken() != null) +{ +TimeStampTokenInfo tsi = response.getTimeStampToken().getTimeStampInfo(); +LOG.error("response tsi: " + tsi); +if (tsi != null && tsi.getNonce() != null) +{ +LOG.error("response tsi nonce: " + tsi.getNonce().toString(16)); +} +else if (tsi != null) +{ +LOG.error("response tsi nonce is null"); +} +} } LOG.error("response: " + Hex.getString(tsaResponse)); throw new IOException(e);
svn commit: r1917635 - /pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Author: tilman Date: Fri May 10 08:38:45 2024 New Revision: 1917635 URL: http://svn.apache.org/viewvc?rev=1917635&view=rev Log: PDFBOX-5820: improve logging, make nonce positive Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java?rev=1917635&r1=1917634&r2=1917635&view=diff == --- pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java (original) +++ pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Fri May 10 08:38:45 2024 @@ -95,8 +95,8 @@ public class TSAClient } byte[] hash = digest.digest(); -// 32-bit cryptographic nonce -int nonce = RANDOM.nextInt(); +// 31-bit positive cryptographic nonce +int nonce = RANDOM.nextInt(Integer.MAX_VALUE); // generate TSA request TimeStampRequestGenerator tsaGenerator = new TimeStampRequestGenerator(); @@ -105,7 +105,8 @@ public class TSAClient TimeStampRequest request = tsaGenerator.generate(oid, hash, BigInteger.valueOf(nonce)); // get TSA response -byte[] tsaResponse = getTSAResponse(request.getEncoded()); +byte[] encodedRequest = request.getEncoded(); +byte[] tsaResponse = getTSAResponse(encodedRequest); TimeStampResponse response = null; try @@ -115,27 +116,26 @@ public class TSAClient } catch (TSPException e) { -LOG.error("request: " + Hex.getString(request.getEncoded())); -LOG.error(String.format("request nonce: %08X / %s", nonce, request.getNonce().toString(16))); +// You can visualize the hex with an ASN.1 Decoder, e.g. http://ldh.org/asn1.html +LOG.error("request: " + Hex.getString(encodedRequest)); if (response != null) { -LOG.error("response status: " + response.getStatus() + " " + response.getStatusString()); -LOG.error("response tst: " + response.getTimeStampToken()); -if (response.getTimeStampToken() != null) +LOG.error("response: " + Hex.getString(tsaResponse)); +// See https://github.com/bcgit/bc-java/blob/4a10c27a03bddd96cf0a3663564d0851425b27b9/pkix/src/main/java/org/bouncycastle/tsp/TimeStampResponse.java#L159 +if ("response contains wrong nonce value.".equals(e.getMessage())) { -TimeStampTokenInfo tsi = response.getTimeStampToken().getTimeStampInfo(); -LOG.error("response tsi: " + tsi); -if (tsi != null && tsi.getNonce() != null) +LOG.error("request nonce: " + request.getNonce().toString(16)); +if (response.getTimeStampToken() != null) { -LOG.error("response tsi nonce: " + tsi.getNonce().toString(16)); -} -else if (tsi != null) -{ -LOG.error("response tsi nonce is null"); +TimeStampTokenInfo tsi = response.getTimeStampToken().getTimeStampInfo(); +if (tsi != null && tsi.getNonce() != null) +{ +// the nonce of the "wrong" test response is 0x3d3244ef +LOG.error("response nonce: " + tsi.getNonce().toString(16)); +} } } } -LOG.error("response: " + Hex.getString(tsaResponse)); throw new IOException(e); }
svn commit: r1917636 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Author: tilman Date: Fri May 10 08:38:54 2024 New Revision: 1917636 URL: http://svn.apache.org/viewvc?rev=1917636&view=rev Log: PDFBOX-5820: improve logging, make nonce positive Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java?rev=1917636&r1=1917635&r2=1917636&view=diff == --- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java (original) +++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Fri May 10 08:38:54 2024 @@ -94,8 +94,8 @@ public class TSAClient } byte[] hash = digest.digest(); -// 32-bit cryptographic nonce -int nonce = RANDOM.nextInt(); +// 31-bit positive cryptographic nonce +int nonce = RANDOM.nextInt(Integer.MAX_VALUE); // generate TSA request TimeStampRequestGenerator tsaGenerator = new TimeStampRequestGenerator(); @@ -104,7 +104,8 @@ public class TSAClient TimeStampRequest request = tsaGenerator.generate(oid, hash, BigInteger.valueOf(nonce)); // get TSA response -byte[] tsaResponse = getTSAResponse(request.getEncoded()); +byte[] encodedRequest = request.getEncoded(); +byte[] tsaResponse = getTSAResponse(encodedRequest); TimeStampResponse response = null; try @@ -114,27 +115,26 @@ public class TSAClient } catch (TSPException e) { -LOG.error("request: " + Hex.getString(request.getEncoded())); -LOG.error(String.format("request nonce: %08X / %s", nonce, request.getNonce().toString(16))); +// You can visualize the hex with an ASN.1 Decoder, e.g. http://ldh.org/asn1.html +LOG.error("request: {} ", () -> Hex.getString(encodedRequest)); if (response != null) { -LOG.error("response status: " + response.getStatus() + " " + response.getStatusString()); -LOG.error("response tst: " + response.getTimeStampToken()); -if (response.getTimeStampToken() != null) +LOG.error("response: {}", () -> Hex.getString(tsaResponse)); +// See https://github.com/bcgit/bc-java/blob/4a10c27a03bddd96cf0a3663564d0851425b27b9/pkix/src/main/java/org/bouncycastle/tsp/TimeStampResponse.java#L159 +if ("response contains wrong nonce value.".equals(e.getMessage())) { -TimeStampTokenInfo tsi = response.getTimeStampToken().getTimeStampInfo(); -LOG.error("response tsi: " + tsi); -if (tsi != null && tsi.getNonce() != null) +LOG.error("request nonce: {}", () -> request.getNonce().toString(16)); +if (response.getTimeStampToken() != null) { -LOG.error("response tsi nonce: " + tsi.getNonce().toString(16)); -} -else if (tsi != null) -{ -LOG.error("response tsi nonce is null"); +TimeStampTokenInfo tsi = response.getTimeStampToken().getTimeStampInfo(); +if (tsi != null && tsi.getNonce() != null) +{ +// the nonce of the "wrong" test response is 0x3d3244ef +LOG.error("response nonce: {}", () -> tsi.getNonce().toString(16)); +} } } } -LOG.error("response: " + Hex.getString(tsaResponse)); throw new IOException(e); }
svn commit: r1917639 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Author: tilman Date: Fri May 10 09:05:56 2024 New Revision: 1917639 URL: http://svn.apache.org/viewvc?rev=1917639&view=rev Log: PDFBOX-5820: improve logging, make nonce positive Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java?rev=1917639&r1=1917638&r2=1917639&view=diff == --- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java (original) +++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java Fri May 10 09:05:56 2024 @@ -29,6 +29,7 @@ import java.util.Random; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.io.IOUtils; +import org.apache.pdfbox.util.Hex; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers; @@ -38,6 +39,7 @@ import org.bouncycastle.tsp.TimeStampReq import org.bouncycastle.tsp.TimeStampRequestGenerator; import org.bouncycastle.tsp.TimeStampResponse; import org.bouncycastle.tsp.TimeStampToken; +import org.bouncycastle.tsp.TimeStampTokenInfo; /** * Time Stamping Authority (TSA) Client [RFC 3161]. @@ -83,8 +85,8 @@ public class TSAClient digest.reset(); byte[] hash = digest.digest(content); -// 32-bit cryptographic nonce -int nonce = RANDOM.nextInt(); +// 31-bit positive cryptographic nonce +int nonce = RANDOM.nextInt(Integer.MAX_VALUE); // generate TSA request TimeStampRequestGenerator tsaGenerator = new TimeStampRequestGenerator(); @@ -93,9 +95,10 @@ public class TSAClient TimeStampRequest request = tsaGenerator.generate(oid, hash, BigInteger.valueOf(nonce)); // get TSA response -byte[] tsaResponse = getTSAResponse(request.getEncoded()); +byte[] encodedRequest = request.getEncoded(); +byte[] tsaResponse = getTSAResponse(encodedRequest); -TimeStampResponse response; +TimeStampResponse response = null; try { response = new TimeStampResponse(tsaResponse); @@ -103,6 +106,26 @@ public class TSAClient } catch (TSPException e) { +// You can visualize the hex with an ASN.1 Decoder, e.g. http://ldh.org/asn1.html +LOG.error("request: " + Hex.getString(encodedRequest)); +if (response != null) +{ +LOG.error("response: " + Hex.getString(tsaResponse)); +// See https://github.com/bcgit/bc-java/blob/4a10c27a03bddd96cf0a3663564d0851425b27b9/pkix/src/main/java/org/bouncycastle/tsp/TimeStampResponse.java#L159 +if ("response contains wrong nonce value.".equals(e.getMessage())) +{ +LOG.error("request nonce: " + request.getNonce().toString(16)); +if (response.getTimeStampToken() != null) +{ +TimeStampTokenInfo tsi = response.getTimeStampToken().getTimeStampInfo(); +if (tsi != null && tsi.getNonce() != null) +{ +// the nonce of the "wrong" test response is 0x3d3244ef +LOG.error("response nonce: " + tsi.getNonce().toString(16)); +} +} +} +} throw new IOException(e); }
svn commit: r1917682 - /pdfbox/trunk/pdfbox/pom.xml
Author: tilman Date: Sun May 12 09:02:34 2024 New Revision: 1917682 URL: http://svn.apache.org/viewvc?rev=1917682&view=rev Log: PDFBOX-5660: update mockito Modified: pdfbox/trunk/pdfbox/pom.xml Modified: pdfbox/trunk/pdfbox/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/pom.xml?rev=1917682&r1=1917681&r2=1917682&view=diff == --- pdfbox/trunk/pdfbox/pom.xml (original) +++ pdfbox/trunk/pdfbox/pom.xml Sun May 12 09:02:34 2024 @@ -86,7 +86,7 @@ org.mockito mockito-core -5.11.0 +5.12.0 test
(pdfbox-docs) 01/02: PDFBOX-5300: update bc
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git commit 296bb6e948c6d83ee96f3f9fd6645dbe9a8ac1ea Author: Tilman Hausherr AuthorDate: Mon May 13 04:59:44 2024 +0200 PDFBOX-5300: update bc --- content/2.0/dependencies.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/2.0/dependencies.md b/content/2.0/dependencies.md index 8142a9d5..30c03a9e 100644 --- a/content/2.0/dependencies.md +++ b/content/2.0/dependencies.md @@ -121,19 +121,19 @@ Public key encryption and signing PDFs requires the *bcprov*, *bcmail* and *bcpk org.bouncycastle bcprov-jdk15to18 -1.77 +1.78.1 org.bouncycastle bcmail-jdk15to18 -1.77 +1.78.1 org.bouncycastle bcpkix-jdk15to18 -1.77 +1.78.1 ``` It is always a good idea to check for a newer version of the Bouncy Castle libraries. If you are using a more recent java version you might adapt the artifactId as well.
(pdfbox-docs) branch master updated (0ef15712 -> 7399cdca)
This is an automated email from the ASF dual-hosted git repository. tilman pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git from 0ef15712 Merge pull request #16 from jamesdaily/patch-3 new 296bb6e9 PDFBOX-5300: update bc new 7399cdca PDFBOX-5300: update bc The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: content/2.0/dependencies.md | 6 +++--- content/3.0/dependencies.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
(pdfbox-docs) 02/02: PDFBOX-5300: update bc
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git commit 7399cdca6aad28ab7065d730161eb4295cb98211 Author: Tilman Hausherr AuthorDate: Mon May 13 04:59:56 2024 +0200 PDFBOX-5300: update bc --- content/3.0/dependencies.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/3.0/dependencies.md b/content/3.0/dependencies.md index 5c64b798..36467506 100644 --- a/content/3.0/dependencies.md +++ b/content/3.0/dependencies.md @@ -121,19 +121,19 @@ Public key encryption and signing PDFs requires the *bcprov*, *bcmail* and *bcpk org.bouncycastle bcprov-jdk18on -1.77 +1.78.1 org.bouncycastle bcmail-jdk18on -1.77 +1.78.1 org.bouncycastle bcpkix-jdk18on -1.77 +1.78.1 ``` It is always a good idea to check for a newer version of the Bouncy Castle libraries. If you are using a more recent java version you might adapt the artifactId as well.
(pdfbox-docs) branch master updated: PDFBOX-5303: mention how to include activation and bind if needed
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new 2c879057 PDFBOX-5303: mention how to include activation and bind if needed 2c879057 is described below commit 2c879057619a336f692afeb4f9b24aab1918f841 Author: Tilman Hausherr AuthorDate: Mon May 13 10:36:03 2024 +0200 PDFBOX-5303: mention how to include activation and bind if needed --- content/2.0/dependencies.md | 24 1 file changed, 24 insertions(+) diff --git a/content/2.0/dependencies.md b/content/2.0/dependencies.md index 30c03a9e..80927eb3 100644 --- a/content/2.0/dependencies.md +++ b/content/2.0/dependencies.md @@ -138,6 +138,30 @@ Public key encryption and signing PDFs requires the *bcprov*, *bcmail* and *bcpk ``` It is always a good idea to check for a newer version of the Bouncy Castle libraries. If you are using a more recent java version you might adapt the artifactId as well. +### Activation and Bind + +The *activation* and *bind* libraries have been removed from the jdk starting with jdk9. They are needed for preflight and some examples. + +These can be included in your Maven project using the following dependencies: + +```xml + +javax.xml.bind +jaxb-api +2.3.1 + + +javax.activation +activation +1.1.1 + +``` +When using the preflight command-line app, copy the jar files into a "lib" subdirectory and run the app like this (use ";" instead of ":" on Windows): + +``java -cp "preflight-app-2.0.31-SNAPSHOT.jar:./lib/*" org.apache.pdfbox.preflight.Validator_A1b args`` + +It is always a good idea to check for a newer version of the libraries. If you are using a more recent java version you might adapt the artifactId as well. + ### Java Cryptography Extension (JCE) 256-bit AES encryption requires a JDK with "unlimited strength" cryptography, which requires extra files to be installed. For JDK 7, see [Java Cryptography Extension (JCE)](http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html). If these files are not installed, building PDFBox will throw an exception with the following message:
(pdfbox-docs) branch master updated: PDFBOX-5303: mention how to include activation and bind if needed
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new f9c3093d PDFBOX-5303: mention how to include activation and bind if needed f9c3093d is described below commit f9c3093d05b318ed815cd703c475db347bb6fb93 Author: Tilman Hausherr AuthorDate: Mon May 13 10:39:07 2024 +0200 PDFBOX-5303: mention how to include activation and bind if needed --- content/3.0/dependencies.md | 24 1 file changed, 24 insertions(+) diff --git a/content/3.0/dependencies.md b/content/3.0/dependencies.md index 36467506..9d189e6c 100644 --- a/content/3.0/dependencies.md +++ b/content/3.0/dependencies.md @@ -137,3 +137,27 @@ Public key encryption and signing PDFs requires the *bcprov*, *bcmail* and *bcpk ``` It is always a good idea to check for a newer version of the Bouncy Castle libraries. If you are using a more recent java version you might adapt the artifactId as well. + +### Activation and Bind + +The *activation* and *bind* libraries have been removed from the jdk starting with jdk9. They are needed for preflight and some examples. + +These can be included in your Maven project using the following dependencies: + +```xml + +javax.xml.bind +jaxb-api +2.3.1 + + +javax.activation +activation +1.1.1 + +``` +When using the preflight command-line app, copy the jar files into a "lib" subdirectory and run the app like this (use ";" instead of ":" on Windows): + +``java -cp "preflight-app-3.0.2-SNAPSHOT.jar:./lib/*" org.apache.pdfbox.preflight.Validator_A1b args`` + +It is always a good idea to check for a newer version of the libraries. If you are using a more recent java version you might adapt the artifactId as well.
(pdfbox-docs) branch master updated: PDFBOX-5303: add more general section about using external libraries from the command line
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new 50d7a647 PDFBOX-5303: add more general section about using external libraries from the command line 50d7a647 is described below commit 50d7a647bc0aa11c5f9c94a3ea59e864ef16e9ef Author: Tilman Hausherr AuthorDate: Tue May 14 10:31:27 2024 +0200 PDFBOX-5303: add more general section about using external libraries from the command line --- content/2.0/dependencies.md | 12 +--- content/3.0/dependencies.md | 12 +--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/content/2.0/dependencies.md b/content/2.0/dependencies.md index 80927eb3..75c00258 100644 --- a/content/2.0/dependencies.md +++ b/content/2.0/dependencies.md @@ -156,11 +156,17 @@ These can be included in your Maven project using the following dependencies: 1.1.1 ``` -When using the preflight command-line app, copy the jar files into a "lib" subdirectory and run the app like this (use ";" instead of ":" on Windows): +It is always a good idea to check for a newer version of the libraries. If you are using a more recent java version you might adapt the artifactId as well. -``java -cp "preflight-app-2.0.31-SNAPSHOT.jar:./lib/*" org.apache.pdfbox.preflight.Validator_A1b args`` +### Using additional libraries from the command line -It is always a good idea to check for a newer version of the libraries. If you are using a more recent java version you might adapt the artifactId as well. +When using one of the command-line apps, copy the jar files into a "lib" subdirectory and run the app like this (use ";" instead of ":" on Windows): + +``java -cp "pdfbox-app-2.0.31.jar:./lib/*" org.apache.pdfbox.tools.PDFBox args`` + +or + +``java -cp "preflight-app-2.0.31.jar:./lib/*" org.apache.pdfbox.preflight.Validator_A1b args`` ### Java Cryptography Extension (JCE) diff --git a/content/3.0/dependencies.md b/content/3.0/dependencies.md index 9d189e6c..8748558d 100644 --- a/content/3.0/dependencies.md +++ b/content/3.0/dependencies.md @@ -156,8 +156,14 @@ These can be included in your Maven project using the following dependencies: 1.1.1 ``` -When using the preflight command-line app, copy the jar files into a "lib" subdirectory and run the app like this (use ";" instead of ":" on Windows): +It is always a good idea to check for a newer version of the libraries. If you are using a more recent java version you might adapt the artifactId as well. -``java -cp "preflight-app-3.0.2-SNAPSHOT.jar:./lib/*" org.apache.pdfbox.preflight.Validator_A1b args`` +### Using additional libraries from the command line -It is always a good idea to check for a newer version of the libraries. If you are using a more recent java version you might adapt the artifactId as well. +When using one of the command-line apps, copy the jar files into a "lib" subdirectory and run the app like this (use ";" instead of ":" on Windows): + +``java -cp "pdfbox-app-3.0.2.jar:./lib/*" org.apache.pdfbox.tools.PDFBox args`` + +or + +``java -cp "preflight-app-3.0.2.jar:./lib/*" org.apache.pdfbox.preflight.Validator_A1b args``
(pdfbox-docs) branch master updated (50d7a647 -> 643b8d6a)
This is an automated email from the ASF dual-hosted git repository. tilman pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git from 50d7a647 PDFBOX-5303: add more general section about using external libraries from the command line new 641128a8 PDFBOX-5300: add text about inkblot problem new 643b8d6a PDFBOX-5300: add text about inkblot problem; move segment about complex scripts and mention that it can be disabled in 3.0.3. The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: content/2.0/faq.md | 5 + content/3.0/faq.md | 25 +++-- 2 files changed, 20 insertions(+), 10 deletions(-)
(pdfbox-docs) 01/02: PDFBOX-5300: add text about inkblot problem
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git commit 641128a8ec782f919cd3b9354b8f5423e766f702 Author: Tilman Hausherr AuthorDate: Tue May 14 10:46:27 2024 +0200 PDFBOX-5300: add text about inkblot problem --- content/2.0/faq.md | 5 + 1 file changed, 5 insertions(+) diff --git a/content/2.0/faq.md b/content/2.0/faq.md index 60ddb947..7dedec3d 100644 --- a/content/2.0/faq.md +++ b/content/2.0/faq.md @@ -212,3 +212,8 @@ but these would cost additional time and memory space. You can have a higher qua ### What to do with the IllegalArgumentException "Numbers of source Raster bands and source color space components do not match"? Sadly, this is a known bug in Java Imaging. Use the twelvemonkeys library as described in the [dependencies](dependencies.html) page. + +### Why do black inkblots, black stains, black clouds or black spots appear when rendering? + +This is a bug in the original java JPEG2000 decoder. You can see examples of such images in [PDFBOX-1752](https://issues.apache.org/jira/browse/PDFBOX-1752) and related issues. +Use the newer (1.4.0 or higher) `jai-imageio-jpeg2000` and `jai-imageio-core` decoders as explained in the [dependencies](dependencies.html) page.
(pdfbox-docs) 02/02: PDFBOX-5300: add text about inkblot problem; move segment about complex scripts and mention that it can be disabled in 3.0.3.
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git commit 643b8d6a4b6e9a684c0b740f56714a3a71dfa678 Author: Tilman Hausherr AuthorDate: Tue May 14 10:47:32 2024 +0200 PDFBOX-5300: add text about inkblot problem; move segment about complex scripts and mention that it can be disabled in 3.0.3. --- content/3.0/faq.md | 25 +++-- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/content/3.0/faq.md b/content/3.0/faq.md index ebdd2ebf..a8c638ab 100644 --- a/content/3.0/faq.md +++ b/content/3.0/faq.md @@ -92,6 +92,18 @@ Check whether the character is available in WinAnsiEncoding by looking at the [P If not, but if it is available in this font (in windows, have a look with charmap.exe), then load the font with PDType0Font.load(), see also in the EmbeddedFonts.java example in the source code download. +### Does PDFBox support complex scripts? + +Thanks to contributions we have supported Bengali and Latin ligatures since 3.0.0. +Starting with version 3.0.2 we also support Devanagari and Gujarati. +However there are some caveats: PDFBox will support only one language in a specific font, thus it is +best to use a font that is specific enough, e.g. the [Lohit fonts](https://pagure.io/lohit). +For example, the Mangal font is meant to be a Devangari font, but PDFBox will choose Bengali +because that one is also claimed to be supported and is checked first. +It is not possible to deactivate the feature in 3.0.2 but it will be in 3.0.3. +The features may be incomplete because we do not yet support all GSUB table formats, +and we don't support GPOS at all. + ## PDF Creation @@ -213,14 +225,7 @@ but these would cost additional time and memory space. You can have a higher qua Sadly, this is a known bug in Java Imaging. Use the twelvemonkeys library as described in the [dependencies](dependencies.html) page. -### Does PDFBox support complex scripts? +### Why do black inkblots, black stains, black clouds or black spots appear when rendering? -Thanks to contributions we have supported Bengali and Latin ligatures since 3.0.0. -Starting with version 3.0.2 we also support Devanagari and Gujarati. -However there are some caveats: PDFBox will support only one language in a specific font, thus it is -best to use a font that is specific enough, e.g. the [Lohit fonts](https://pagure.io/lohit). -For example, the Mangal font is meant to be a Devangari font, but PDFBox will choose Bengali -because that one is also claimed to be supported and is checked first. -It is not possible to deactivate the feature. -The features may be incomplete because we do not yet support all GSUB tables, -and we don't support GPOS at all. +This is a bug in the original java JPEG2000 decoder. You can see examples of such images in [PDFBOX-1752](https://issues.apache.org/jira/browse/PDFBOX-1752) and related issues. +Use the newer (1.4.0 or higher) `jai-imageio-jpeg2000` and `jai-imageio-core` decoders as explained in the [dependencies](dependencies.html) page.
(pdfbox-docs) branch master updated: PDFBOX-5300: fix typo
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new dda4feb9 PDFBOX-5300: fix typo dda4feb9 is described below commit dda4feb93b4e71b862d0b9b457fdf36b88f24952 Author: Tilman Hausherr AuthorDate: Tue May 14 10:49:22 2024 +0200 PDFBOX-5300: fix typo --- content/2.0/faq.md | 2 +- content/3.0/faq.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/2.0/faq.md b/content/2.0/faq.md index 7dedec3d..63a09bf2 100644 --- a/content/2.0/faq.md +++ b/content/2.0/faq.md @@ -201,7 +201,7 @@ The memory footprint depends on the PDF itself and on the resolution you use for ### Why are some texts in poor quality and not antialiased? -This is because in some PDFs (e.g. the one in [PDFBOX-2814](https://issues.apache.org/jira/browse/PDFBOX-2814), text is not +This is because in some PDFs (e.g. the one in [PDFBOX-2814](https://issues.apache.org/jira/browse/PDFBOX-2814)), text is not rendered directly, but as a shaped clipping from a background. Java graphics does not support "soft clipping" <https://bugs.openjdk.java.net/browse/JDK-4212743>, and because of that, the edges are not looking smooth. Soft clipping could be achieved with [some extra steps](https://web.archive.org/web/20200814083145/https://community.oracle.com/blogs/campbell/2006/07/19/java-2d-trickery-soft-clipping), diff --git a/content/3.0/faq.md b/content/3.0/faq.md index a8c638ab..9feec47f 100644 --- a/content/3.0/faq.md +++ b/content/3.0/faq.md @@ -213,7 +213,7 @@ The memory footprint depends on the PDF itself and on the resolution you use for ### Why are some texts in poor quality and not antialiased? -This is because in some PDFs (e.g. the one in [PDFBOX-2814](https://issues.apache.org/jira/browse/PDFBOX-2814), text is not +This is because in some PDFs (e.g. the one in [PDFBOX-2814](https://issues.apache.org/jira/browse/PDFBOX-2814)), text is not rendered directly, but as a shaped clipping from a background. Java graphics does not support "soft clipping" <https://bugs.openjdk.java.net/browse/JDK-4212743>, and because of that, the edges are not looking smooth. Soft clipping could be achieved with [some extra steps](https://web.archive.org/web/20200814083145/https://community.oracle.com/blogs/campbell/2006/07/19/java-2d-trickery-soft-clipping),
(pdfbox-docs) branch master updated: PDFBOX-5300: fix broken link
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new bcfe9fa0 PDFBOX-5300: fix broken link bcfe9fa0 is described below commit bcfe9fa0304b6fafb2d81f0c9beb8a204816c147 Author: Tilman Hausherr AuthorDate: Tue May 14 11:04:32 2024 +0200 PDFBOX-5300: fix broken link --- content/2.0/dependencies.md | 2 +- content/3.0/dependencies.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/2.0/dependencies.md b/content/2.0/dependencies.md index 75c00258..c34dfbe1 100644 --- a/content/2.0/dependencies.md +++ b/content/2.0/dependencies.md @@ -71,7 +71,7 @@ PDFBox does not ship with all features enabled. Third party components are neces PDF supports embedded image files, however support for some formats require third party libraries which are distributed under terms incompatible with the Apache 2.0 license: - Reading **JBIG2** images: [JBIG2 ImageIO](https://pdfbox.apache.org/download.cgi#JBIG2) -- Reading **JPEG 2000 (JPX)** images: [JAI Image I/O Tools Core](https://java.net/projects/jai-imageio-core) +- Reading **JPEG 2000 (JPX)** images: [JAI Image I/O Tools](https://www.oracle.com/java/technologies/java-archive-downloads-java-client-downloads.html) - Writing **TIFF** images requires *JAI Image I/O Tools Core* also. These libraries are optional and will be loaded if present on the classpath, otherwise support for these image formats will be disabled and a warning will be logged when an unsupported image is encountered. diff --git a/content/3.0/dependencies.md b/content/3.0/dependencies.md index 8748558d..4a720947 100644 --- a/content/3.0/dependencies.md +++ b/content/3.0/dependencies.md @@ -71,7 +71,7 @@ PDFBox does not ship with all features enabled. Third party components are neces PDF supports embedded image files, however support for some formats require third party libraries which are distributed under terms incompatible with the Apache 2.0 license: - Reading **JBIG2** images: [JBIG2 ImageIO](https://pdfbox.apache.org/download.cgi#JBIG2) -- Reading **JPEG 2000 (JPX)** images: [JAI Image I/O Tools Core](https://java.net/projects/jai-imageio-core) +- Reading **JPEG 2000 (JPX)** images: [JAI Image I/O Tools](https://www.oracle.com/java/technologies/java-archive-downloads-java-client-downloads.html) - Writing **TIFF** images requires *JAI Image I/O Tools Core* also. These libraries are optional and will be loaded if present on the classpath, otherwise support for these image formats will be disabled and a warning will be logged when an unsupported image is encountered.
(pdfbox-docs) branch master updated: PDFBOX-5300: fix grammar
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new 28e40858 PDFBOX-5300: fix grammar 28e40858 is described below commit 28e408582e7618bd767014896dbb579d41151807 Author: Tilman Hausherr AuthorDate: Tue May 14 11:06:23 2024 +0200 PDFBOX-5300: fix grammar --- content/2.0/dependencies.md | 2 +- content/3.0/dependencies.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/2.0/dependencies.md b/content/2.0/dependencies.md index c34dfbe1..7e3472b2 100644 --- a/content/2.0/dependencies.md +++ b/content/2.0/dependencies.md @@ -72,7 +72,7 @@ PDF supports embedded image files, however support for some formats require thir - Reading **JBIG2** images: [JBIG2 ImageIO](https://pdfbox.apache.org/download.cgi#JBIG2) - Reading **JPEG 2000 (JPX)** images: [JAI Image I/O Tools](https://www.oracle.com/java/technologies/java-archive-downloads-java-client-downloads.html) -- Writing **TIFF** images requires *JAI Image I/O Tools Core* also. +- Writing **TIFF** images also requires *JAI Image I/O Tools Core*. These libraries are optional and will be loaded if present on the classpath, otherwise support for these image formats will be disabled and a warning will be logged when an unsupported image is encountered. diff --git a/content/3.0/dependencies.md b/content/3.0/dependencies.md index 4a720947..d748d327 100644 --- a/content/3.0/dependencies.md +++ b/content/3.0/dependencies.md @@ -72,7 +72,7 @@ PDF supports embedded image files, however support for some formats require thir - Reading **JBIG2** images: [JBIG2 ImageIO](https://pdfbox.apache.org/download.cgi#JBIG2) - Reading **JPEG 2000 (JPX)** images: [JAI Image I/O Tools](https://www.oracle.com/java/technologies/java-archive-downloads-java-client-downloads.html) -- Writing **TIFF** images requires *JAI Image I/O Tools Core* also. +- Writing **TIFF** images also requires *JAI Image I/O Tools Core*. These libraries are optional and will be loaded if present on the classpath, otherwise support for these image formats will be disabled and a warning will be logged when an unsupported image is encountered.
(pdfbox-docs) branch master updated: PDFBOX-5300: add "What fonts do I need on my system?" segment
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new 1cfdbb55 PDFBOX-5300: add "What fonts do I need on my system?" segment 1cfdbb55 is described below commit 1cfdbb556100c94cd455a510dabbdc0ef243ea84 Author: Tilman Hausherr AuthorDate: Tue May 14 11:32:05 2024 +0200 PDFBOX-5300: add "What fonts do I need on my system?" segment --- content/2.0/faq.md | 21 + content/3.0/faq.md | 21 + 2 files changed, 42 insertions(+) diff --git a/content/2.0/faq.md b/content/2.0/faq.md index 63a09bf2..44bf9462 100644 --- a/content/2.0/faq.md +++ b/content/2.0/faq.md @@ -92,6 +92,27 @@ Check whether the character is available in WinAnsiEncoding by looking at the [P If not, but if it is available in this font (in windows, have a look with charmap.exe), then load the font with PDType0Font.load(), see also in the EmbeddedFonts.java example in the source code download. +### What fonts do I need on my system? + +Windows or Mac usually have the minimum fonts needed. You do need fonts that aren't embedded in PDFs +if these fonts are outside of the "Standard 14 fonts" set, and any specific fonts that you want +when you are creating PDFs. + +For rendering and text extraction, you'll need the "Standard 14 fonts" mentioned in the +PDF specification: Times-Roman, Helvetica, Courier, Symbol, Times-Bold, Helvetica-Bold, Courier-Bold, +Symbol, ZapfDingbats, Times-Italic, Helvetica-Oblique, Courier-Oblique, Times-BoldItalic, +Helvetica-BoldOblique, Courier-BoldOblique. You can get most of these fonts on linux by running +``sudo apt-get install ttf-mscorefonts-installer``. Arial is as good as Helvetica. +MS-Gothic can be used instead of ZapfDingbats. +See also [this stackoverflow answer](https://stackoverflow.com/a/67437624/535646) about getting ZapfDingbats +from ghostscript fonts. The Times/Courier/Helvetica fonts can also be replaced with the appropriate +Liberation or Nimbus fonts. The exact substitution logic that PDFBox uses can be read in the file +``FontMapperImpl.java`` from the source code download. + +To create PDFs with "Standard 14 fonts" only, no extra fonts files are needed +(version 2.0.5 or higher), +as these are not embedded and PDFBox has all the metrics and no longer needs to access the actual fonts. + ## PDF Creation diff --git a/content/3.0/faq.md b/content/3.0/faq.md index 9feec47f..8b360e7c 100644 --- a/content/3.0/faq.md +++ b/content/3.0/faq.md @@ -104,6 +104,27 @@ It is not possible to deactivate the feature in 3.0.2 but it will be in 3.0.3. The features may be incomplete because we do not yet support all GSUB table formats, and we don't support GPOS at all. +### What fonts do I need on my system? + +Windows or Mac usually have the minimum fonts needed. You do need fonts that aren't embedded in PDFs +if these fonts are outside of the "Standard 14 fonts" set, and any specific fonts that you want +when you are creating PDFs. + +For rendering and text extraction, you'll need the "Standard 14 fonts" mentioned in the +PDF specification: Times-Roman, Helvetica, Courier, Symbol, Times-Bold, Helvetica-Bold, Courier-Bold, +Symbol, ZapfDingbats, Times-Italic, Helvetica-Oblique, Courier-Oblique, Times-BoldItalic, +Helvetica-BoldOblique, Courier-BoldOblique. You can get most of these fonts on linux by running +``sudo apt-get install ttf-mscorefonts-installer``. Arial is as good as Helvetica. +MS-Gothic can be used instead of ZapfDingbats. +See also [this stackoverflow answer](https://stackoverflow.com/a/67437624/535646) about getting ZapfDingbats +from ghostscript fonts. The Times/Courier/Helvetica fonts can also be replaced with the appropriate +Liberation or Nimbus fonts. The exact substitution logic that PDFBox uses can be read in the file +``FontMapperImpl.java`` from the source code download. + +To create PDFs with "Standard 14 fonts" only, no extra fonts files are needed +(version 2.0.5 or higher), +as these are not embedded and PDFBox has all the metrics and no longer needs to access the actual fonts. + ## PDF Creation
(pdfbox-docs) branch master updated: PDFBOX-5300: add "Why do external fonts seem corrupt when loaded as a resource" segment
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new d7a8a12b PDFBOX-5300: add "Why do external fonts seem corrupt when loaded as a resource" segment d7a8a12b is described below commit d7a8a12b8058995998f057c273dc85d3e5d72c4d Author: Tilman Hausherr AuthorDate: Tue May 14 12:07:15 2024 +0200 PDFBOX-5300: add "Why do external fonts seem corrupt when loaded as a resource" segment --- content/2.0/faq.md | 8 content/3.0/faq.md | 8 2 files changed, 16 insertions(+) diff --git a/content/2.0/faq.md b/content/2.0/faq.md index 44bf9462..60703998 100644 --- a/content/2.0/faq.md +++ b/content/2.0/faq.md @@ -113,6 +113,14 @@ To create PDFs with "Standard 14 fonts" only, no extra fonts files are needed (version 2.0.5 or higher), as these are not embedded and PDFBox has all the metrics and no longer needs to access the actual fonts. +### Why do external fonts seem corrupt when loaded as a resource? + +If your program runs properly when the font is loaded from a file but not when loaded from the +resources, check whether +[resource filtering](https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html) +is activated in the maven-resources-plugin in your maven build script, and disable it for font files. +See [this stackoverflow answer](https://stackoverflow.com/a/25503853/535646) on how to fix this. + ## PDF Creation diff --git a/content/3.0/faq.md b/content/3.0/faq.md index 8b360e7c..c4cf1caa 100644 --- a/content/3.0/faq.md +++ b/content/3.0/faq.md @@ -125,6 +125,14 @@ To create PDFs with "Standard 14 fonts" only, no extra fonts files are needed (version 2.0.5 or higher), as these are not embedded and PDFBox has all the metrics and no longer needs to access the actual fonts. +### Why do external fonts seem corrupt when loaded as a resource? + +If your program runs properly when the font is loaded from a file but not when loaded from the +resources, check whether +[resource filtering](https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html) +is activated in the maven-resources-plugin in your maven build script, and disable it for font files. +See [this stackoverflow answer](https://stackoverflow.com/a/25503853/535646) on how to fix this. + ## PDF Creation
(pdfbox-docs) branch master updated: PDFBOX-5300: add "Why do I not get all fields when iterating?" segment
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new 5ef36da3 PDFBOX-5300: add "Why do I not get all fields when iterating?" segment 5ef36da3 is described below commit 5ef36da323e40bcbdab003f36c45726b7abea8ae Author: Tilman Hausherr AuthorDate: Tue May 14 12:28:36 2024 +0200 PDFBOX-5300: add "Why do I not get all fields when iterating?" segment --- content/2.0/faq.md | 5 + content/3.0/faq.md | 5 + 2 files changed, 10 insertions(+) diff --git a/content/2.0/faq.md b/content/2.0/faq.md index 60703998..2903fa7f 100644 --- a/content/2.0/faq.md +++ b/content/2.0/faq.md @@ -82,6 +82,11 @@ finally } ``` +### Why do I not get all fields when iterating? + +Call ``getFieldTree()`` instead of ``getFields()``. The later one only returns root-level fields. + + ## Font Handling diff --git a/content/3.0/faq.md b/content/3.0/faq.md index c4cf1caa..f8505e58 100644 --- a/content/3.0/faq.md +++ b/content/3.0/faq.md @@ -82,6 +82,11 @@ finally } ``` +### Why do I not get all fields when iterating? + +Call ``getFieldTree()`` instead of ``getFields()``. The later one only returns root-level fields. + + ## Font Handling
(pdfbox-docs) branch master updated (5ef36da3 -> 98f92159)
This is an automated email from the ASF dual-hosted git repository. tilman pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git from 5ef36da3 PDFBOX-5300: add "Why do I not get all fields when iterating?" segment new 1e5d453a PDFBOX-5300: mention subsampling new 98f92159 PDFBOX-5300: mention subsampling; fix document loading call The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: content/2.0/faq.md | 1 + content/3.0/faq.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
(pdfbox-docs) 01/02: PDFBOX-5300: mention subsampling
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git commit 1e5d453a433433b2806edbfd79de36093a983f29 Author: Tilman Hausherr AuthorDate: Tue May 14 13:04:41 2024 +0200 PDFBOX-5300: mention subsampling --- content/2.0/faq.md | 1 + 1 file changed, 1 insertion(+) diff --git a/content/2.0/faq.md b/content/2.0/faq.md index 2903fa7f..8af90003 100644 --- a/content/2.0/faq.md +++ b/content/2.0/faq.md @@ -226,6 +226,7 @@ The memory footprint depends on the PDF itself and on the resolution you use for - increase the `-Xmx` value when starting java - use a scratch file by loading files with this code `PDDocument.load(file, MemoryUsageSetting.setupTempFileOnly())` +- activate subsampling by calling ``setSubsamplingAllowed(true)`` on your ``PDFRenderer`` object - be careful not to hold your images after rendering them, e.g. avoid putting all images of a PDF into a `List` - don't forgot to close your `PDDocument` objects - decrease the scale when calling `PDFRenderer.renderImage()`, or the dpi value when calling `PDFRenderer.renderImageWithDPI()`
(pdfbox-docs) 02/02: PDFBOX-5300: mention subsampling; fix document loading call
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git commit 98f921596dd7ae1900f585adc3590ed9e7d4d983 Author: Tilman Hausherr AuthorDate: Tue May 14 13:05:00 2024 +0200 PDFBOX-5300: mention subsampling; fix document loading call --- content/3.0/faq.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/3.0/faq.md b/content/3.0/faq.md index f8505e58..70ca3e2a 100644 --- a/content/3.0/faq.md +++ b/content/3.0/faq.md @@ -237,7 +237,8 @@ the word "Hello" is drawn. The memory footprint depends on the PDF itself and on the resolution you use for rendering. Some possible options: - increase the `-Xmx` value when starting java -- use a scratch file by loading files with this code `PDDocument.load(file, MemoryUsageSetting.setupTempFileOnly())` +- use a scratch file by loading files with this code `Loader.loadPDF(file, IOUtils.createTempFileOnlyStreamCache())` +- activate subsampling by calling ``setSubsamplingAllowed(true)`` on your ``PDFRenderer`` object - be careful not to hold your images after rendering them, e.g. avoid putting all images of a PDF into a `List` - don't forgot to close your `PDDocument` objects - decrease the scale when calling `PDFRenderer.renderImage()`, or the dpi value when calling `PDFRenderer.renderImageWithDPI()`
(pdfbox-docs) branch master updated: PDFBOX-5300: mention workaround for printing slowness
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new 519beb9a PDFBOX-5300: mention workaround for printing slowness 519beb9a is described below commit 519beb9aebf645e9f0f4b1734f7ec7e24cd31275 Author: Tilman Hausherr AuthorDate: Tue May 14 13:58:52 2024 +0200 PDFBOX-5300: mention workaround for printing slowness --- content/2.0/faq.md | 13 + content/3.0/faq.md | 13 + 2 files changed, 26 insertions(+) diff --git a/content/2.0/faq.md b/content/2.0/faq.md index 8af90003..614d3105 100644 --- a/content/2.0/faq.md +++ b/content/2.0/faq.md @@ -252,3 +252,16 @@ Sadly, this is a known bug in Java Imaging. Use the twelvemonkeys library as des This is a bug in the original java JPEG2000 decoder. You can see examples of such images in [PDFBOX-1752](https://issues.apache.org/jira/browse/PDFBOX-1752) and related issues. Use the newer (1.4.0 or higher) `jai-imageio-jpeg2000` and `jai-imageio-core` decoders as explained in the [dependencies](dependencies.html) page. + +### Why is printing so slow for some PDFs? + +If display rendering happens within a decent time but not printing, +then the cause is likely transparent elements. Java renders these much slower when printing, +see [here](https://blog.idrsolutions.com/avoid-transparency-when-printing-in-java/) for an +explanation, and [PDFBOX-3046](https://issues.apache.org/jira/browse/PDFBOX-3046) +and related issues for sample files. + +A workaround is to use a specific dpi for the constructors of ``PDFPageable`` and ``PDFPrintable``, +PDFBox will then render into an image +and print that one. You should experiment with 300, 600 and 1200 dpi by trying it with +the command-line app. \ No newline at end of file diff --git a/content/3.0/faq.md b/content/3.0/faq.md index 70ca3e2a..74971d8d 100644 --- a/content/3.0/faq.md +++ b/content/3.0/faq.md @@ -264,3 +264,16 @@ Sadly, this is a known bug in Java Imaging. Use the twelvemonkeys library as des This is a bug in the original java JPEG2000 decoder. You can see examples of such images in [PDFBOX-1752](https://issues.apache.org/jira/browse/PDFBOX-1752) and related issues. Use the newer (1.4.0 or higher) `jai-imageio-jpeg2000` and `jai-imageio-core` decoders as explained in the [dependencies](dependencies.html) page. + +### Why is printing so slow for some PDFs? + +If display rendering happens within a decent time but not printing, +then the cause is likely transparent elements. Java renders these much slower when printing, +see [here](https://blog.idrsolutions.com/avoid-transparency-when-printing-in-java/) for an +explanation, and [PDFBOX-3046](https://issues.apache.org/jira/browse/PDFBOX-3046) +and related issues for sample files. + +A workaround is to use a specific dpi for the constructors of ``PDFPageable`` and ``PDFPrintable``, +PDFBox will then render into an image +and print that one. You should experiment with 300, 600 and 1200 dpi by trying it with +the command-line app. \ No newline at end of file
svn commit: r1917733 - in /pdfbox/trunk/examples: pom.xml src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java
Author: tilman Date: Wed May 15 08:07:28 2024 New Revision: 1917733 URL: http://svn.apache.org/viewvc?rev=1917733&view=rev Log: PDFBOX-5821: add test with VeraPDF Modified: pdfbox/trunk/examples/pom.xml pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Modified: pdfbox/trunk/examples/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/pom.xml?rev=1917733&r1=1917732&r2=1917733&view=diff == --- pdfbox/trunk/examples/pom.xml (original) +++ pdfbox/trunk/examples/pom.xml Wed May 15 08:07:28 2024 @@ -111,6 +111,12 @@ log4j-core ${log4j2.version} + +org.verapdf +validation-model +1.24.2 +test + Modified: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java?rev=1917733&r1=1917732&r2=1917733&view=diff == --- pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java (original) +++ pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Wed May 15 08:07:28 2024 @@ -17,6 +17,7 @@ package org.apache.pdfbox.examples.pdfa; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedReader; import java.io.File; @@ -37,6 +38,12 @@ import org.apache.xmpbox.schema.DublinCo import org.apache.xmpbox.xml.DomXmpParser; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider; +import org.verapdf.pdfa.Foundries; +import org.verapdf.pdfa.PDFAParser; +import org.verapdf.pdfa.PDFAValidator; +import org.verapdf.pdfa.flavours.PDFAFlavour; +import org.verapdf.pdfa.results.ValidationResult; /** * @@ -114,5 +121,14 @@ class CreatePDFATest } br.close(); +// https://docs.verapdf.org/develop/ +VeraGreenfieldFoundryProvider.initialise(); +PDFAFlavour flavour = PDFAFlavour.fromString("1b"); +try (PDFAParser parser = Foundries.defaultInstance().createParser(signedFile, flavour)) +{ +PDFAValidator validator = Foundries.defaultInstance().createValidator(flavour, false); +ValidationResult veraResult = validator.validate(parser); +assertTrue(veraResult.isCompliant()); +} } }
svn commit: r1917734 - in /pdfbox/branches/3.0/examples: pom.xml src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java
Author: tilman Date: Wed May 15 08:07:32 2024 New Revision: 1917734 URL: http://svn.apache.org/viewvc?rev=1917734&view=rev Log: PDFBOX-5821: add test with VeraPDF Modified: pdfbox/branches/3.0/examples/pom.xml pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Modified: pdfbox/branches/3.0/examples/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/pom.xml?rev=1917734&r1=1917733&r2=1917734&view=diff == --- pdfbox/branches/3.0/examples/pom.xml (original) +++ pdfbox/branches/3.0/examples/pom.xml Wed May 15 08:07:32 2024 @@ -120,6 +120,12 @@ ${log4j2.version} test + +org.verapdf +validation-model +1.24.2 +test + Modified: pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java?rev=1917734&r1=1917733&r2=1917734&view=diff == --- pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java (original) +++ pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Wed May 15 08:07:32 2024 @@ -41,6 +41,11 @@ import org.apache.xmpbox.schema.DublinCo import org.apache.xmpbox.xml.DomXmpParser; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider; +import org.verapdf.pdfa.Foundries; +import org.verapdf.pdfa.PDFAParser; +import org.verapdf.pdfa.PDFAValidator; +import org.verapdf.pdfa.flavours.PDFAFlavour; /** * @@ -126,5 +131,14 @@ class CreatePDFATest } br.close(); +// https://docs.verapdf.org/develop/ +VeraGreenfieldFoundryProvider.initialise(); +PDFAFlavour flavour = PDFAFlavour.fromString("1b"); +try (PDFAParser parser = Foundries.defaultInstance().createParser(new File(signedPdfaFilename), flavour)) +{ +PDFAValidator validator = Foundries.defaultInstance().createValidator(flavour, false); +org.verapdf.pdfa.results.ValidationResult veraResult = validator.validate(parser); +assertTrue(veraResult.isCompliant()); +} } }
svn commit: r1917735 - in /pdfbox/branches/2.0/examples: pom.xml src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java
Author: tilman Date: Wed May 15 08:07:36 2024 New Revision: 1917735 URL: http://svn.apache.org/viewvc?rev=1917735&view=rev Log: PDFBOX-5821: add test with VeraPDF Modified: pdfbox/branches/2.0/examples/pom.xml pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Modified: pdfbox/branches/2.0/examples/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/pom.xml?rev=1917735&r1=1917734&r2=1917735&view=diff == --- pdfbox/branches/2.0/examples/pom.xml (original) +++ pdfbox/branches/2.0/examples/pom.xml Wed May 15 08:07:36 2024 @@ -123,6 +123,12 @@ 1.0 test + +org.verapdf +validation-model +1.24.2 +test + Modified: pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java?rev=1917735&r1=1917734&r2=1917735&view=diff == --- pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java (original) +++ pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Wed May 15 08:07:36 2024 @@ -32,6 +32,11 @@ import org.apache.pdfbox.preflight.parse import org.apache.xmpbox.XMPMetadata; import org.apache.xmpbox.schema.DublinCoreSchema; import org.apache.xmpbox.xml.DomXmpParser; +import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider; +import org.verapdf.pdfa.Foundries; +import org.verapdf.pdfa.PDFAParser; +import org.verapdf.pdfa.PDFAValidator; +import org.verapdf.pdfa.flavours.PDFAFlavour; /** * @@ -90,6 +95,15 @@ public class CreatePDFATest extends Test DublinCoreSchema dc = metadata.getDublinCoreSchema(); assertEquals(pdfaFilename, dc.getTitle()); document.close(); + +// https://docs.verapdf.org/develop/ +VeraGreenfieldFoundryProvider.initialise(); +PDFAFlavour flavour = PDFAFlavour.fromString("1b"); +PDFAParser parser = Foundries.defaultInstance().createParser(new File(signedPdfaFilename), flavour); +PDFAValidator validator = Foundries.defaultInstance().createValidator(flavour, false); +org.verapdf.pdfa.results.ValidationResult veraResult = validator.validate(parser); +assertTrue(veraResult.isCompliant()); +parser.close(); } }
svn commit: r1917743 - in /pdfbox/trunk: fontbox/src/main/appended-resources/META-INF/LICENSE pdfbox/src/main/appended-resources/META-INF/LICENSE
Author: tilman Date: Wed May 15 14:38:26 2024 New Revision: 1917743 URL: http://svn.apache.org/viewvc?rev=1917743&view=rev Log: PDFBOX-5660: fix typo Modified: pdfbox/trunk/fontbox/src/main/appended-resources/META-INF/LICENSE pdfbox/trunk/pdfbox/src/main/appended-resources/META-INF/LICENSE Modified: pdfbox/trunk/fontbox/src/main/appended-resources/META-INF/LICENSE URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/appended-resources/META-INF/LICENSE?rev=1917743&r1=1917742&r2=1917743&view=diff == --- pdfbox/trunk/fontbox/src/main/appended-resources/META-INF/LICENSE (original) +++ pdfbox/trunk/fontbox/src/main/appended-resources/META-INF/LICENSE Wed May 15 14:38:26 2024 @@ -31,7 +31,7 @@ Apache FontBox is based on contributions OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Lohit-Bengali, Lohit-Devangari, Lohit-Gujarati fonts (https://pagure.io/lohit): +Lohit-Bengali, Lohit-Devanagari, Lohit-Gujarati fonts (https://pagure.io/lohit): Copyright 2011-15 Lohit Fonts Project contributors Modified: pdfbox/trunk/pdfbox/src/main/appended-resources/META-INF/LICENSE URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/appended-resources/META-INF/LICENSE?rev=1917743&r1=1917742&r2=1917743&view=diff == --- pdfbox/trunk/pdfbox/src/main/appended-resources/META-INF/LICENSE (original) +++ pdfbox/trunk/pdfbox/src/main/appended-resources/META-INF/LICENSE Wed May 15 14:38:26 2024 @@ -238,7 +238,7 @@ Twelvemonkeys (https://github.com/harald NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Lohit-Bengali, Lohit-Devangari, Lohit-Gujarati fonts (https://pagure.io/lohit): +Lohit-Bengali, Lohit-Devanagari, Lohit-Gujarati fonts (https://pagure.io/lohit): Copyright 2011-15 Lohit Fonts Project contributors
svn commit: r1917744 - in /pdfbox/branches/3.0: fontbox/src/main/appended-resources/META-INF/LICENSE pdfbox/src/main/appended-resources/META-INF/LICENSE
Author: tilman Date: Wed May 15 14:39:34 2024 New Revision: 1917744 URL: http://svn.apache.org/viewvc?rev=1917744&view=rev Log: PDFBOX-5660: fix typo Modified: pdfbox/branches/3.0/fontbox/src/main/appended-resources/META-INF/LICENSE pdfbox/branches/3.0/pdfbox/src/main/appended-resources/META-INF/LICENSE Modified: pdfbox/branches/3.0/fontbox/src/main/appended-resources/META-INF/LICENSE URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/fontbox/src/main/appended-resources/META-INF/LICENSE?rev=1917744&r1=1917743&r2=1917744&view=diff == --- pdfbox/branches/3.0/fontbox/src/main/appended-resources/META-INF/LICENSE (original) +++ pdfbox/branches/3.0/fontbox/src/main/appended-resources/META-INF/LICENSE Wed May 15 14:39:34 2024 @@ -31,7 +31,7 @@ Apache FontBox is based on contributions OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Lohit-Bengali, Lohit-Devangari, Lohit-Gujarati fonts (https://pagure.io/lohit): +Lohit-Bengali, Lohit-Devanagari, Lohit-Gujarati fonts (https://pagure.io/lohit): Copyright 2011-15 Lohit Fonts Project contributors Modified: pdfbox/branches/3.0/pdfbox/src/main/appended-resources/META-INF/LICENSE URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/appended-resources/META-INF/LICENSE?rev=1917744&r1=1917743&r2=1917744&view=diff == --- pdfbox/branches/3.0/pdfbox/src/main/appended-resources/META-INF/LICENSE (original) +++ pdfbox/branches/3.0/pdfbox/src/main/appended-resources/META-INF/LICENSE Wed May 15 14:39:34 2024 @@ -238,7 +238,7 @@ Twelvemonkeys (https://github.com/harald NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Lohit-Bengali, Lohit-Devangari, Lohit-Gujarati fonts (https://pagure.io/lohit): +Lohit-Bengali, Lohit-Devanagari, Lohit-Gujarati fonts (https://pagure.io/lohit): Copyright 2011-15 Lohit Fonts Project contributors
(pdfbox-jbig2) branch master updated: PDFBOX-5660: update owasp plugin
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-jbig2.git The following commit(s) were added to refs/heads/master by this push: new cdffe62 PDFBOX-5660: update owasp plugin cdffe62 is described below commit cdffe62bf2eea5ff20565c1f32c8d4788936356e Author: Tilman Hausherr AuthorDate: Thu May 16 09:25:51 2024 +0200 PDFBOX-5660: update owasp plugin --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b9496a..bbd3026 100644 --- a/pom.xml +++ b/pom.xml @@ -389,7 +389,7 @@ org.owasp dependency-check-maven -9.1.0 +9.2.0 0
svn commit: r1917760 - /pdfbox/branches/3.0/pom.xml
Author: tilman Date: Thu May 16 07:26:56 2024 New Revision: 1917760 URL: http://svn.apache.org/viewvc?rev=1917760&view=rev Log: PDFBOX-5660: update owasp plugin, commons-logging Modified: pdfbox/branches/3.0/pom.xml Modified: pdfbox/branches/3.0/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pom.xml?rev=1917760&r1=1917759&r2=1917760&view=diff == --- pdfbox/branches/3.0/pom.xml (original) +++ pdfbox/branches/3.0/pom.xml Thu May 16 07:26:56 2024 @@ -60,7 +60,7 @@ 3.0.4 1.4.0 2.16.1 -1.3.1 +1.3.2 4.7.6 2.22.0
svn commit: r1917761 - /pdfbox/branches/2.0/pom.xml
Author: tilman Date: Thu May 16 07:27:52 2024 New Revision: 1917761 URL: http://svn.apache.org/viewvc?rev=1917761&view=rev Log: PDFBOX-5660: update owasp plugin Modified: pdfbox/branches/2.0/pom.xml Modified: pdfbox/branches/2.0/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pom.xml?rev=1917761&r1=1917760&r2=1917761&view=diff == --- pdfbox/branches/2.0/pom.xml (original) +++ pdfbox/branches/2.0/pom.xml Thu May 16 07:27:52 2024 @@ -317,7 +317,7 @@ org.owasp dependency-check-maven - 9.1.0 + 9.2.0 0
svn commit: r1917762 - /pdfbox/trunk/pom.xml
Author: tilman Date: Thu May 16 07:28:38 2024 New Revision: 1917762 URL: http://svn.apache.org/viewvc?rev=1917762&view=rev Log: PDFBOX-5660: update owasp plugin Modified: pdfbox/trunk/pom.xml Modified: pdfbox/trunk/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/trunk/pom.xml?rev=1917762&r1=1917761&r2=1917762&view=diff == --- pdfbox/trunk/pom.xml (original) +++ pdfbox/trunk/pom.xml Thu May 16 07:28:38 2024 @@ -385,7 +385,7 @@ A release vote template has been generat org.owasp dependency-check-maven - 9.1.0 + 9.2.0 0
svn commit: r1917776 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/SmallMap.java
Author: tilman Date: Fri May 17 07:16:13 2024 New Revision: 1917776 URL: http://svn.apache.org/viewvc?rev=1917776&view=rev Log: PDFBOX-5660: add SO answer as a comment Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/SmallMap.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/SmallMap.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/SmallMap.java?rev=1917776&r1=1917775&r2=1917776&view=diff == --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/SmallMap.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/SmallMap.java Fri May 17 07:16:13 2024 @@ -356,6 +356,8 @@ public class SmallMap implements M @Override public int hashCode() { +// before thinking of changing this, read +// https://stackoverflow.com/a/78491381/535646 return getKey().hashCode(); }
svn commit: r1917785 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Fri May 17 13:34:00 2024 New Revision: 1917785 URL: http://svn.apache.org/viewvc?rev=1917785&view=rev Log: PDFBOX-5660, PDFBOX-5580: revert commit due to incompatibility with PDFTextStripperByArea Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917785&r1=1917784&r2=1917785&view=diff == --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Fri May 17 13:34:00 2024 @@ -961,10 +961,6 @@ public class PDFTextStripper extends Leg */ public void setStartPage(int startPageValue) { -if (startPageValue <= 0) -{ -LOG.warn("Parameter must be 1-based, but is " + startPageValue); -} startPage = startPageValue; } @@ -987,10 +983,6 @@ public class PDFTextStripper extends Leg */ public void setEndPage(int endPageValue) { -if (endPageValue <= 0) -{ -LOG.warn("Parameter must be 1-based, but is " + endPageValue); -} endPage = endPageValue; }
svn commit: r1917786 - /pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Fri May 17 13:34:03 2024 New Revision: 1917786 URL: http://svn.apache.org/viewvc?rev=1917786&view=rev Log: PDFBOX-5660, PDFBOX-5580: revert commit due to incompatibility with PDFTextStripperByArea Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917786&r1=1917785&r2=1917786&view=diff == --- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Fri May 17 13:34:03 2024 @@ -950,10 +950,6 @@ public class PDFTextStripper extends Leg */ public void setStartPage(int startPageValue) { -if (startPageValue <= 0) -{ -LOG.warn("Parameter must be 1-based, but is " + startPageValue); -} startPage = startPageValue; } @@ -976,10 +972,6 @@ public class PDFTextStripper extends Leg */ public void setEndPage(int endPageValue) { -if (endPageValue <= 0) -{ -LOG.warn("Parameter must be 1-based, but is " + endPageValue); -} endPage = endPageValue; }
svn commit: r1917787 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Fri May 17 13:34:07 2024 New Revision: 1917787 URL: http://svn.apache.org/viewvc?rev=1917787&view=rev Log: PDFBOX-5660, PDFBOX-5580: revert commit due to incompatibility with PDFTextStripperByArea Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917787&r1=1917786&r2=1917787&view=diff == --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Fri May 17 13:34:07 2024 @@ -946,15 +946,9 @@ public class PDFTextStripper extends Leg * This will set the first page to be extracted by this class. * * @param startPageValue New value of 1-based startPage property. - * - * @throws IllegalArgumentException if the parameter is below 1. */ public void setStartPage(int startPageValue) { -if (startPageValue <= 0) -{ -throw new IllegalArgumentException("Parameter must be 1-based, but is " + startPageValue); -} startPage = startPageValue; } @@ -974,15 +968,9 @@ public class PDFTextStripper extends Leg * This will set the last page to be extracted by this class. * * @param endPageValue New value of 1-based endPage property. - * - * @throws IllegalArgumentException if the parameter is below 1. */ public void setEndPage(int endPageValue) { -if (endPageValue <= 0) -{ -throw new IllegalArgumentException("Parameter must be 1-based, but is " + endPageValue); -} endPage = endPageValue; }
svn commit: r1917788 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java
Author: tilman Date: Fri May 17 13:40:02 2024 New Revision: 1917788 URL: http://svn.apache.org/viewvc?rev=1917788&view=rev Log: PDFBOX-5580: add test for PDFTextStripperByArea Added: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java (with props) Added: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java?rev=1917788&view=auto == --- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java (added) +++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java Fri May 17 13:40:02 2024 @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pdfbox.text; + +import java.awt.geom.Rectangle2D; +import java.io.File; +import java.io.IOException; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.junit.Assert; +import org.junit.Test; + +/** + * + * @author Tilman Hausherr + */ +public class PDFTextStripperByAreaTest +{ +public PDFTextStripperByAreaTest() +{ +} + +@Test +public void testSomeMethod() throws IOException +{ +File pdfFile = new File("src/test/resources/input","eu-001.pdf"); +PDDocument doc = PDDocument.load(pdfFile); +String regionName = "region"; +PDFTextStripperByArea textAreaStripper = new PDFTextStripperByArea(); +textAreaStripper.setShouldSeparateByBeads(false); // does nothing +textAreaStripper.setSortByPosition(true); +Rectangle2D rect = new Rectangle2D.Double(65, 227, 472, 34); +textAreaStripper.addRegion(regionName, rect); +textAreaStripper.setLineSeparator(""); +textAreaStripper.extractRegions(doc.getPage(0)); +String textForRegion = textAreaStripper.getTextForRegion(regionName); +textForRegion = textForRegion.trim(); +Assert.assertEquals("In the following tables you will find the 91 E-PRTR " ++ "pollutants and their thresholds broken down by the 7 groups used in all " ++ "the searches of the E-PRTR website.", textForRegion); +textAreaStripper.removeRegion(regionName); +rect = new Rectangle2D.Double(230, 370, 369, 10); +textAreaStripper.addRegion(regionName, rect); +textAreaStripper.extractRegions(doc.getPage(2)); +textForRegion = textAreaStripper.getTextForRegion(regionName); +textForRegion = textForRegion.trim(); +Assert.assertEquals("Inorganic substances", textForRegion); +Assert.assertEquals(1, textAreaStripper.getRegions().size()); +doc.close(); +} + +} Propchange: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java -- svn:eol-style = native
svn commit: r1917789 - /pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java
Author: tilman Date: Fri May 17 13:40:06 2024 New Revision: 1917789 URL: http://svn.apache.org/viewvc?rev=1917789&view=rev Log: PDFBOX-5580: add test for PDFTextStripperByArea Added: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java (with props) Added: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java?rev=1917789&view=auto == --- pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java (added) +++ pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java Fri May 17 13:40:06 2024 @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pdfbox.text; + +import java.awt.geom.Rectangle2D; +import java.io.File; +import java.io.IOException; +import org.apache.pdfbox.Loader; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * + * @author Tilman Hausherr + */ +public class PDFTextStripperByAreaTest +{ +public PDFTextStripperByAreaTest() +{ +} + +@Test +void testSomeMethod() throws IOException +{ +File pdfFile = new File("src/test/resources/input","eu-001.pdf"); +try (PDDocument doc = Loader.loadPDF(pdfFile)) +{ +String regionName = "region"; +PDFTextStripperByArea textAreaStripper = new PDFTextStripperByArea(); +textAreaStripper.setShouldSeparateByBeads(false); // does nothing +textAreaStripper.setSortByPosition(true); +Rectangle2D rect = new Rectangle2D.Double(65, 227, 472, 34); +textAreaStripper.addRegion(regionName, rect); +textAreaStripper.setLineSeparator(""); +textAreaStripper.extractRegions(doc.getPage(0)); +String textForRegion = textAreaStripper.getTextForRegion(regionName); +textForRegion = textForRegion.trim(); +Assertions.assertEquals("In the following tables you will find the 91 E-PRTR " ++ "pollutants and their thresholds broken down by the 7 groups used in all " ++ "the searches of the E-PRTR website.", textForRegion); +textAreaStripper.removeRegion(regionName); +rect = new Rectangle2D.Double(230, 370, 369, 10); +textAreaStripper.addRegion(regionName, rect); +textAreaStripper.extractRegions(doc.getPage(2)); +textForRegion = textAreaStripper.getTextForRegion(regionName); +textForRegion = textForRegion.trim(); +Assertions.assertEquals("Inorganic substances", textForRegion); +Assertions.assertEquals(1, textAreaStripper.getRegions().size()); +} +} + +} Propchange: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java -- svn:eol-style = native
svn commit: r1917790 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java
Author: tilman Date: Fri May 17 13:40:10 2024 New Revision: 1917790 URL: http://svn.apache.org/viewvc?rev=1917790&view=rev Log: PDFBOX-5580: add test for PDFTextStripperByArea Added: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java (with props) Added: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java?rev=1917790&view=auto == --- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java (added) +++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java Fri May 17 13:40:10 2024 @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pdfbox.text; + +import java.awt.geom.Rectangle2D; +import java.io.File; +import java.io.IOException; +import org.apache.pdfbox.Loader; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * + * @author Tilman Hausherr + */ +public class PDFTextStripperByAreaTest +{ +public PDFTextStripperByAreaTest() +{ +} + +@Test +void testSomeMethod() throws IOException +{ +File pdfFile = new File("src/test/resources/input","eu-001.pdf"); +try (PDDocument doc = Loader.loadPDF(pdfFile)) +{ +String regionName = "region"; +PDFTextStripperByArea textAreaStripper = new PDFTextStripperByArea(); +textAreaStripper.setShouldSeparateByBeads(false); // does nothing +textAreaStripper.setSortByPosition(true); +Rectangle2D rect = new Rectangle2D.Double(65, 227, 472, 34); +textAreaStripper.addRegion(regionName, rect); +textAreaStripper.setLineSeparator(""); +textAreaStripper.extractRegions(doc.getPage(0)); +String textForRegion = textAreaStripper.getTextForRegion(regionName); +textForRegion = textForRegion.trim(); +Assertions.assertEquals("In the following tables you will find the 91 E-PRTR " ++ "pollutants and their thresholds broken down by the 7 groups used in all " ++ "the searches of the E-PRTR website.", textForRegion); +textAreaStripper.removeRegion(regionName); +rect = new Rectangle2D.Double(230, 370, 369, 10); +textAreaStripper.addRegion(regionName, rect); +textAreaStripper.extractRegions(doc.getPage(2)); +textForRegion = textAreaStripper.getTextForRegion(regionName); +textForRegion = textForRegion.trim(); +Assertions.assertEquals("Inorganic substances", textForRegion); +Assertions.assertEquals(1, textAreaStripper.getRegions().size()); +} +} + +} Propchange: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java -- svn:eol-style = native
svn propchange: r1917785 - svn:log
Author: tilman Revision: 1917785 Modified property: svn:log Modified: svn:log at Fri May 17 13:46:21 2024 -- --- svn:log (original) +++ svn:log Fri May 17 13:46:21 2024 @@ -1 +1 @@ -PDFBOX-5660, PDFBOX-5580: revert commit due to incompatibility with PDFTextStripperByArea +PDFBOX-5660, PDFBOX-5822: revert commit due to incompatibility with PDFTextStripperByArea
svn propchange: r1917786 - svn:log
Author: tilman Revision: 1917786 Modified property: svn:log Modified: svn:log at Fri May 17 13:46:39 2024 -- --- svn:log (original) +++ svn:log Fri May 17 13:46:39 2024 @@ -1 +1 @@ -PDFBOX-5660, PDFBOX-5580: revert commit due to incompatibility with PDFTextStripperByArea +PDFBOX-5660, PDFBOX-5822: revert commit due to incompatibility with PDFTextStripperByArea
svn propchange: r1917787 - svn:log
Author: tilman Revision: 1917787 Modified property: svn:log Modified: svn:log at Fri May 17 13:46:58 2024 -- --- svn:log (original) +++ svn:log Fri May 17 13:46:58 2024 @@ -1 +1 @@ -PDFBOX-5660, PDFBOX-5580: revert commit due to incompatibility with PDFTextStripperByArea +PDFBOX-5660, PDFBOX-5822: revert commit due to incompatibility with PDFTextStripperByArea
svn propchange: r1917788 - svn:log
Author: tilman Revision: 1917788 Modified property: svn:log Modified: svn:log at Fri May 17 13:47:43 2024 -- --- svn:log (original) +++ svn:log Fri May 17 13:47:43 2024 @@ -1 +1 @@ -PDFBOX-5580: add test for PDFTextStripperByArea +PDFBOX-5822: add test for PDFTextStripperByArea
svn propchange: r1917789 - svn:log
Author: tilman Revision: 1917789 Modified property: svn:log Modified: svn:log at Fri May 17 13:47:53 2024 -- --- svn:log (original) +++ svn:log Fri May 17 13:47:53 2024 @@ -1 +1 @@ -PDFBOX-5580: add test for PDFTextStripperByArea +PDFBOX-5822: add test for PDFTextStripperByArea
svn propchange: r1917790 - svn:log
Author: tilman Revision: 1917790 Modified property: svn:log Modified: svn:log at Fri May 17 13:48:03 2024 -- --- svn:log (original) +++ svn:log Fri May 17 13:48:03 2024 @@ -1 +1 @@ -PDFBOX-5580: add test for PDFTextStripperByArea +PDFBOX-5822: add test for PDFTextStripperByArea
svn commit: r1917800 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Sat May 18 13:57:53 2024 New Revision: 1917800 URL: http://svn.apache.org/viewvc?rev=1917800&view=rev Log: PDFBOX-5580: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917800&r1=1917799&r2=1917800&view=diff == --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Sat May 18 13:57:53 2024 @@ -124,7 +124,7 @@ public class PDFTextStripper extends Leg private String articleStart = ""; private String articleEnd = ""; -private int currentPageNo = 0; +private int currentPageNo = 1; private int startPage = 1; private int endPage = Integer.MAX_VALUE; private PDOutlineItem startBookmark = null; @@ -205,7 +205,7 @@ public class PDFTextStripper extends Leg private void resetEngine() { -currentPageNo = 0; +currentPageNo = 1; document = null; if (charactersByArticle != null) { @@ -285,11 +285,11 @@ public class PDFTextStripper extends Leg for (PDPage page : pages) { -currentPageNo++; if (page.hasContents()) { processPage(page); } +currentPageNo++; } }
svn commit: r1917801 - /pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Sat May 18 13:57:57 2024 New Revision: 1917801 URL: http://svn.apache.org/viewvc?rev=1917801&view=rev Log: PDFBOX-5580: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917801&r1=1917800&r2=1917801&view=diff == --- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Sat May 18 13:57:57 2024 @@ -125,7 +125,7 @@ public class PDFTextStripper extends Leg private String articleStart = ""; private String articleEnd = ""; -private int currentPageNo = 0; +private int currentPageNo = 1; private int startPage = 1; private int endPage = Integer.MAX_VALUE; private PDOutlineItem startBookmark = null; @@ -205,7 +205,7 @@ public class PDFTextStripper extends Leg private void resetEngine() { -currentPageNo = 0; +currentPageNo = 1; document = null; charactersByArticle.clear(); characterListMapping.clear(); @@ -282,11 +282,11 @@ public class PDFTextStripper extends Leg for (PDPage page : pages) { -currentPageNo++; if (page.hasContents()) { processPage(page); } +currentPageNo++; } }
svn commit: r1917802 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Sat May 18 13:58:01 2024 New Revision: 1917802 URL: http://svn.apache.org/viewvc?rev=1917802&view=rev Log: PDFBOX-5580: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917802&r1=1917801&r2=1917802&view=diff == --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Sat May 18 13:58:01 2024 @@ -124,7 +124,7 @@ public class PDFTextStripper extends Leg private String articleStart = ""; private String articleEnd = ""; -private int currentPageNo = 0; +private int currentPageNo = 1; private int startPage = 1; private int endPage = Integer.MAX_VALUE; private PDOutlineItem startBookmark = null; @@ -204,7 +204,7 @@ public class PDFTextStripper extends Leg private void resetEngine() { -currentPageNo = 0; +currentPageNo = 1; document = null; charactersByArticle.clear(); characterListMapping.clear(); @@ -281,11 +281,11 @@ public class PDFTextStripper extends Leg for (PDPage page : pages) { -currentPageNo++; if (page.hasContents()) { processPage(page); } +currentPageNo++; } }
svn propchange: r1917800 - svn:log
Author: tilman Revision: 1917800 Modified property: svn:log Modified: svn:log at Sat May 18 14:01:08 2024 -- --- svn:log (original) +++ svn:log Sat May 18 14:01:08 2024 @@ -1 +1 @@ -PDFBOX-5580: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler +PDFBOX-5822: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler
svn propchange: r1917801 - svn:log
Author: tilman Revision: 1917801 Modified property: svn:log Modified: svn:log at Sat May 18 14:01:18 2024 -- --- svn:log (original) +++ svn:log Sat May 18 14:01:18 2024 @@ -1 +1 @@ -PDFBOX-5580: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler +PDFBOX-5822: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler
svn propchange: r1917802 - svn:log
Author: tilman Revision: 1917802 Modified property: svn:log Modified: svn:log at Sat May 18 14:01:25 2024 -- --- svn:log (original) +++ svn:log Sat May 18 14:01:25 2024 @@ -1 +1 @@ -PDFBOX-5580: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler +PDFBOX-5822: initialize currentPageNo to 1 and increment after the current page so we can restore reverted commit, as suggested by Andreas Lehmkühler
svn commit: r1917803 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java
Author: tilman Date: Sat May 18 14:10:54 2024 New Revision: 1917803 URL: http://svn.apache.org/viewvc?rev=1917803&view=rev Log: PDFBOX-5822: add test for setStartPage and setEndPage Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java?rev=1917803&r1=1917802&r2=1917803&view=diff == --- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java (original) +++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Sat May 18 14:10:54 2024 @@ -668,4 +668,24 @@ class TestTextStripper } } +/** + * Check that setting start and end pages work properly. + * + * @throws IOException + */ +@Test +void testStartEndPage() throws IOException +{ +File pdfFile = new File("src/test/resources/input", "eu-001.pdf"); +try (PDDocument doc = Loader.loadPDF(pdfFile)) +{ +PDFTextStripper textStripper = new PDFTextStripper(); +textStripper.setStartPage(2); +textStripper.setEndPage(2); +String text = textStripper.getText(doc).trim(); +assertTrue(text.startsWith("Pesticides")); +assertTrue(text.endsWith("1 000 10 10")); +assertEquals(text.length(), 1440); +} +} }
svn commit: r1917804 - /pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java
Author: tilman Date: Sat May 18 14:10:58 2024 New Revision: 1917804 URL: http://svn.apache.org/viewvc?rev=1917804&view=rev Log: PDFBOX-5822: add test for setStartPage and setEndPage Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java?rev=1917804&r1=1917803&r2=1917804&view=diff == --- pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java (original) +++ pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Sat May 18 14:10:58 2024 @@ -671,4 +671,24 @@ class TestTextStripper } } +/** + * Check that setting start and end pages work properly. + * + * @throws IOException + */ +@Test +void testStartEndPage() throws IOException +{ +File pdfFile = new File("src/test/resources/input", "eu-001.pdf"); +try (PDDocument doc = Loader.loadPDF(pdfFile)) +{ +PDFTextStripper textStripper = new PDFTextStripper(); +textStripper.setStartPage(2); +textStripper.setEndPage(2); +String text = textStripper.getText(doc).trim(); +assertTrue(text.startsWith("Pesticides")); +assertTrue(text.endsWith("1 000 10 10")); +assertEquals(text.length(), 1440); +} +} }
svn commit: r1917805 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java
Author: tilman Date: Sat May 18 14:11:02 2024 New Revision: 1917805 URL: http://svn.apache.org/viewvc?rev=1917805&view=rev Log: PDFBOX-5822: add test for setStartPage and setEndPage Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java?rev=1917805&r1=1917804&r2=1917805&view=diff == --- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java (original) +++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Sat May 18 14:11:02 2024 @@ -724,4 +724,23 @@ public class TestTextStripper extends Te String[] arg = {TestTextStripper.class.getName() }; junit.textui.TestRunner.main( arg ); } + +/** + * Check that setting start and end pages work properly. + * + * @throws IOException + */ +public void testStartEndPage() throws IOException +{ +File pdfFile = new File("src/test/resources/input", "eu-001.pdf"); +PDDocument doc = PDDocument.load(pdfFile); +PDFTextStripper textStripper = new PDFTextStripper(); +textStripper.setStartPage(2); +textStripper.setEndPage(2); +String text = textStripper.getText(doc).trim(); +assertTrue(text.startsWith("Pesticides")); +assertTrue(text.endsWith("1 000 10 10")); +assertEquals(text.length(), 1440); +doc.close(); +} }
svn commit: r1917807 - /pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java
Author: tilman Date: Sat May 18 15:35:29 2024 New Revision: 1917807 URL: http://svn.apache.org/viewvc?rev=1917807&view=rev Log: PDFBOX-5822: remove CRs and fix parameter sequence Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java?rev=1917807&r1=1917806&r2=1917807&view=diff == --- pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java (original) +++ pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Sat May 18 15:35:29 2024 @@ -688,7 +688,7 @@ class TestTextStripper String text = textStripper.getText(doc).trim(); assertTrue(text.startsWith("Pesticides")); assertTrue(text.endsWith("1 000 10 10")); -assertEquals(text.length(), 1440); +assertEquals(1378, text.replaceAll("\r", "").length()); } } }
svn commit: r1917806 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java
Author: tilman Date: Sat May 18 15:35:25 2024 New Revision: 1917806 URL: http://svn.apache.org/viewvc?rev=1917806&view=rev Log: PDFBOX-5822: remove CRs and fix parameter sequence Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java?rev=1917806&r1=1917805&r2=1917806&view=diff == --- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java (original) +++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Sat May 18 15:35:25 2024 @@ -685,7 +685,7 @@ class TestTextStripper String text = textStripper.getText(doc).trim(); assertTrue(text.startsWith("Pesticides")); assertTrue(text.endsWith("1 000 10 10")); -assertEquals(text.length(), 1440); +assertEquals(1378, text.replaceAll("\r", "").length()); } } }
svn commit: r1917808 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java
Author: tilman Date: Sat May 18 15:35:33 2024 New Revision: 1917808 URL: http://svn.apache.org/viewvc?rev=1917808&view=rev Log: PDFBOX-5822: remove CRs and fix parameter sequence Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java?rev=1917808&r1=1917807&r2=1917808&view=diff == --- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java (original) +++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Sat May 18 15:35:33 2024 @@ -740,7 +740,7 @@ public class TestTextStripper extends Te String text = textStripper.getText(doc).trim(); assertTrue(text.startsWith("Pesticides")); assertTrue(text.endsWith("1 000 10 10")); -assertEquals(text.length(), 1440); +assertEquals(1378, text.replaceAll("\r", "").length()); doc.close(); } }
svn commit: r1917811 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java
Author: tilman Date: Sat May 18 16:19:56 2024 New Revision: 1917811 URL: http://svn.apache.org/viewvc?rev=1917811&view=rev Log: PDFBOX-5822: Sonar fix Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java?rev=1917811&r1=1917810&r2=1917811&view=diff == --- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java (original) +++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java Sat May 18 16:19:56 2024 @@ -29,12 +29,8 @@ import org.junit.jupiter.api.Test; * * @author Tilman Hausherr */ -public class PDFTextStripperByAreaTest +class PDFTextStripperByAreaTest { -public PDFTextStripperByAreaTest() -{ -} - @Test void testSomeMethod() throws IOException {
svn commit: r1917810 - /pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java
Author: tilman Date: Sat May 18 16:19:24 2024 New Revision: 1917810 URL: http://svn.apache.org/viewvc?rev=1917810&view=rev Log: PDFBOX-5822: Sonar fix Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java?rev=1917810&r1=1917809&r2=1917810&view=diff == --- pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java (original) +++ pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/PDFTextStripperByAreaTest.java Sat May 18 16:19:24 2024 @@ -29,12 +29,8 @@ import org.junit.jupiter.api.Test; * * @author Tilman Hausherr */ -public class PDFTextStripperByAreaTest +class PDFTextStripperByAreaTest { -public PDFTextStripperByAreaTest() -{ -} - @Test void testSomeMethod() throws IOException {
svn commit: r1917812 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Sat May 18 16:21:29 2024 New Revision: 1917812 URL: http://svn.apache.org/viewvc?rev=1917812&view=rev Log: PDFBOX-5822: restore exception suggested by mkl in SO 78307200 Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917812&r1=1917811&r2=1917812&view=diff == --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Sat May 18 16:21:29 2024 @@ -946,9 +946,15 @@ public class PDFTextStripper extends Leg * This will set the first page to be extracted by this class. * * @param startPageValue New value of 1-based startPage property. + * + * @throws IllegalArgumentException if the parameter is below 1. */ public void setStartPage(int startPageValue) { +if (startPageValue <= 0) +{ +throw new IllegalArgumentException("Parameter must be 1-based, but is " + startPageValue); +} startPage = startPageValue; } @@ -968,9 +974,15 @@ public class PDFTextStripper extends Leg * This will set the last page to be extracted by this class. * * @param endPageValue New value of 1-based endPage property. + * + * @throws IllegalArgumentException if the parameter is below 1. */ public void setEndPage(int endPageValue) { +if (endPageValue <= 0) +{ +throw new IllegalArgumentException("Parameter must be 1-based, but is " + endPageValue); +} endPage = endPageValue; }
svn commit: r1917813 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Sat May 18 16:21:53 2024 New Revision: 1917813 URL: http://svn.apache.org/viewvc?rev=1917813&view=rev Log: PDFBOX-5822: restore warning suggested by mkl in SO 78307200 Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917813&r1=1917812&r2=1917813&view=diff == --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Sat May 18 16:21:53 2024 @@ -961,6 +961,10 @@ public class PDFTextStripper extends Leg */ public void setStartPage(int startPageValue) { +if (startPageValue <= 0) +{ +LOG.warn("Parameter must be 1-based, but is " + startPageValue); +} startPage = startPageValue; } @@ -983,6 +987,10 @@ public class PDFTextStripper extends Leg */ public void setEndPage(int endPageValue) { +if (endPageValue <= 0) +{ +LOG.warn("Parameter must be 1-based, but is " + endPageValue); +} endPage = endPageValue; }
svn commit: r1917814 - /pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
Author: tilman Date: Sat May 18 16:22:08 2024 New Revision: 1917814 URL: http://svn.apache.org/viewvc?rev=1917814&view=rev Log: PDFBOX-5822: restore warning suggested by mkl in SO 78307200 Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1917814&r1=1917813&r2=1917814&view=diff == --- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original) +++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Sat May 18 16:22:08 2024 @@ -950,6 +950,10 @@ public class PDFTextStripper extends Leg */ public void setStartPage(int startPageValue) { +if (startPageValue <= 0) +{ +LOG.warn("Parameter must be 1-based, but is " + startPageValue); +} startPage = startPageValue; } @@ -972,6 +976,10 @@ public class PDFTextStripper extends Leg */ public void setEndPage(int endPageValue) { +if (endPageValue <= 0) +{ +LOG.warn("Parameter must be 1-based, but is " + endPageValue); +} endPage = endPageValue; }
svn commit: r1917836 - /pdfbox/trunk/examples/pom.xml
Author: tilman Date: Mon May 20 10:05:16 2024 New Revision: 1917836 URL: http://svn.apache.org/viewvc?rev=1917836&view=rev Log: PDFBOX-5660: update verapdf Modified: pdfbox/trunk/examples/pom.xml Modified: pdfbox/trunk/examples/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/pom.xml?rev=1917836&r1=1917835&r2=1917836&view=diff == --- pdfbox/trunk/examples/pom.xml (original) +++ pdfbox/trunk/examples/pom.xml Mon May 20 10:05:16 2024 @@ -114,7 +114,7 @@ org.verapdf validation-model -1.24.2 +1.26.1 test
svn commit: r1917837 - /pdfbox/branches/2.0/examples/pom.xml
Author: tilman Date: Mon May 20 10:05:33 2024 New Revision: 1917837 URL: http://svn.apache.org/viewvc?rev=1917837&view=rev Log: PDFBOX-5660: update verapdf Modified: pdfbox/branches/2.0/examples/pom.xml Modified: pdfbox/branches/2.0/examples/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/pom.xml?rev=1917837&r1=1917836&r2=1917837&view=diff == --- pdfbox/branches/2.0/examples/pom.xml (original) +++ pdfbox/branches/2.0/examples/pom.xml Mon May 20 10:05:33 2024 @@ -126,7 +126,7 @@ org.verapdf validation-model -1.24.2 +1.26.1 test
svn commit: r1917838 - /pdfbox/branches/3.0/examples/pom.xml
Author: tilman Date: Mon May 20 10:05:46 2024 New Revision: 1917838 URL: http://svn.apache.org/viewvc?rev=1917838&view=rev Log: PDFBOX-5660: update verapdf Modified: pdfbox/branches/3.0/examples/pom.xml Modified: pdfbox/branches/3.0/examples/pom.xml URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/pom.xml?rev=1917838&r1=1917837&r2=1917838&view=diff == --- pdfbox/branches/3.0/examples/pom.xml (original) +++ pdfbox/branches/3.0/examples/pom.xml Mon May 20 10:05:46 2024 @@ -123,7 +123,7 @@ org.verapdf validation-model -1.24.2 +1.26.1 test
svn commit: r1917879 - /pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java
Author: tilman Date: Wed May 22 06:43:13 2024 New Revision: 1917879 URL: http://svn.apache.org/viewvc?rev=1917879&view=rev Log: PDFBOX-5825: improve javadoc Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java?rev=1917879&r1=1917878&r2=1917879&view=diff == --- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java (original) +++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java Wed May 22 06:43:13 2024 @@ -35,7 +35,8 @@ public class PDMetadata extends PDStream { /** - * This will create a new PDMetadata object. + * This will create a new PDMetadata object with the /Type and /Subtype entries for a document + * level metadata object. * * @param document The document that the stream will be part of. */ @@ -47,8 +48,9 @@ public class PDMetadata extends PDStream } /** - * Constructor. Reads all data from the input stream and embeds it into the - * document, this will close the InputStream. + * Constructor. Reads all data from the input stream and embeds it into the document, this will + * close the InputStream. The /Type and /Subtype entries for a document level metadata object + * will be created. * * @param doc The document that will hold the stream. * @param str The stream parameter. @@ -62,7 +64,7 @@ public class PDMetadata extends PDStream } /** - * Constructor. + * Constructor. This will not set up the /Type and /Subtype entries. * * @param str The stream parameter. */
svn commit: r1917880 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java
Author: tilman Date: Wed May 22 06:43:18 2024 New Revision: 1917880 URL: http://svn.apache.org/viewvc?rev=1917880&view=rev Log: PDFBOX-5825: improve javadoc Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java?rev=1917880&r1=1917879&r2=1917880&view=diff == --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java Wed May 22 06:43:18 2024 @@ -35,7 +35,8 @@ public class PDMetadata extends PDStream { /** - * This will create a new PDMetadata object. + * This will create a new PDMetadata object with the /Type and /Subtype entries for a document + * level metadata object. * * @param document The document that the stream will be part of. */ @@ -47,8 +48,9 @@ public class PDMetadata extends PDStream } /** - * Constructor. Reads all data from the input stream and embeds it into the - * document, this will close the InputStream. + * Constructor. Reads all data from the input stream and embeds it into the document, this will + * close the InputStream. The /Type and /Subtype entries for a document level metadata object + * will be created. * * @param doc The document that will hold the stream. * @param str The stream parameter. @@ -62,7 +64,7 @@ public class PDMetadata extends PDStream } /** - * Constructor. + * Constructor. This will not set up the /Type and /Subtype entries. * * @param str The stream parameter. */
svn commit: r1917881 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java
Author: tilman Date: Wed May 22 06:43:21 2024 New Revision: 1917881 URL: http://svn.apache.org/viewvc?rev=1917881&view=rev Log: PDFBOX-5825: improve javadoc Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java?rev=1917881&r1=1917880&r2=1917881&view=diff == --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java Wed May 22 06:43:21 2024 @@ -35,7 +35,8 @@ public class PDMetadata extends PDStream { /** - * This will create a new PDMetadata object. + * This will create a new PDMetadata object with the /Type and /Subtype entries for a document + * level metadata object. * * @param document The document that the stream will be part of. */ @@ -47,8 +48,9 @@ public class PDMetadata extends PDStream } /** - * Constructor. Reads all data from the input stream and embeds it into the - * document, this will close the InputStream. + * Constructor. Reads all data from the input stream and embeds it into the document, this will + * close the InputStream. The /Type and /Subtype entries for a document level metadata object + * will be created. * * @param doc The document that will hold the stream. * @param str The stream parameter. @@ -62,7 +64,7 @@ public class PDMetadata extends PDStream } /** - * Constructor. + * Constructor. This will not set up the /Type and /Subtype entries. * * @param str The stream parameter. */
svn commit: r1917886 - in /pdfbox/trunk/examples/src: main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java
Author: tilman Date: Wed May 22 10:36:57 2024 New Revision: 1917886 URL: http://svn.apache.org/viewvc?rev=1917886&view=rev Log: PDFBOX-5825: add missing entries for metadata dictionary; add test with PDF/A check Added: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java - copied, changed from r1917881, pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java?rev=1917886&r1=1917885&r2=1917886&view=diff == --- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java (original) +++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Wed May 22 10:36:57 2024 @@ -37,7 +37,9 @@ import java.util.List; import javax.xml.transform.TransformerException; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.io.IOUtils; +import org.apache.pdfbox.pdfwriter.compress.CompressParameters; /** * @@ -83,7 +85,7 @@ public class PDFMergerExample pdfMerger.setDestinationMetadata(xmpMetadata); LOG.info("Merging {} source documents into one PDF", sources.size()); -pdfMerger.mergeDocuments(IOUtils.createMemoryOnlyStreamCache()); +pdfMerger.mergeDocuments(IOUtils.createMemoryOnlyStreamCache(), CompressParameters.NO_COMPRESSION); LOG.info("PDF merge successful, size = {{}} bytes", mergedPDFOutputStream.size()); return new ByteArrayInputStream(mergedPDFOutputStream.toByteArray()); @@ -149,6 +151,8 @@ public class PDFMergerExample { new XmpSerializer().serialize(xmpMetadata, xmpOutputStream, true); cosXMPStream.write(xmpOutputStream.toByteArray()); +cosStream.setName(COSName.TYPE, "Metadata" ); +cosStream.setName(COSName.SUBTYPE, "XML" ); return new PDMetadata(cosStream); } } Copied: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java (from r1917881, pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java) URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java?p2=pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java&p1=pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java&r1=1917881&r2=1917886&rev=1917886&view=diff == --- pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java (original) +++ pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Wed May 22 10:36:57 2024 @@ -1,5 +1,5 @@ /* - * Copyright 2015 The Apache Software Foundation. + * Copyright 2024 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. @@ -15,27 +15,17 @@ */ package org.apache.pdfbox.examples.pdfa; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.security.KeyStore; -import java.util.HashSet; -import java.util.Set; - -import org.apache.pdfbox.Loader; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; import org.apache.pdfbox.examples.pdmodel.CreatePDFA; -import org.apache.pdfbox.examples.signature.CreateSignature; -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDDocumentCatalog; -import org.apache.pdfbox.pdmodel.common.PDMetadata; -import org.apache.xmpbox.XMPMetadata; -import org.apache.xmpbox.schema.DublinCoreSchema; -import org.apache.xmpbox.xml.DomXmpParser; +import org.apache.pdfbox.examples.util.PDFMergerExample; +import org.apache.pdfbox.io.RandomAccessRead; +import org.apache.pdfbox.io.RandomAccessReadBufferedFile; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider; @@ -49,7 +39,7 @@ import org.verapdf.pdfa.results.Validati * * @
svn commit: r1917887 - in /pdfbox/branches/3.0/examples/src: main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java
Author: tilman Date: Wed May 22 10:37:02 2024 New Revision: 1917887 URL: http://svn.apache.org/viewvc?rev=1917887&view=rev Log: PDFBOX-5825: add missing entries for metadata dictionary; add test with PDF/A check Added: pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java - copied, changed from r1917823, pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java?rev=1917887&r1=1917886&r2=1917887&view=diff == --- pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java (original) +++ pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Wed May 22 10:37:02 2024 @@ -37,7 +37,9 @@ import java.util.List; import javax.xml.transform.TransformerException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.io.IOUtils; +import org.apache.pdfbox.pdfwriter.compress.CompressParameters; /** * @@ -83,7 +85,7 @@ public class PDFMergerExample pdfMerger.setDestinationMetadata(xmpMetadata); LOG.info("Merging " + sources.size() + " source documents into one PDF"); -pdfMerger.mergeDocuments(IOUtils.createMemoryOnlyStreamCache()); +pdfMerger.mergeDocuments(IOUtils.createMemoryOnlyStreamCache(), CompressParameters.NO_COMPRESSION); LOG.info("PDF merge successful, size = {" + mergedPDFOutputStream.size() + "} bytes"); return new ByteArrayInputStream(mergedPDFOutputStream.toByteArray()); @@ -149,6 +151,8 @@ public class PDFMergerExample { new XmpSerializer().serialize(xmpMetadata, xmpOutputStream, true); cosXMPStream.write(xmpOutputStream.toByteArray()); +cosStream.setName(COSName.TYPE, "Metadata" ); +cosStream.setName(COSName.SUBTYPE, "XML" ); return new PDMetadata(cosStream); } } Copied: pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java (from r1917823, pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java) URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java?p2=pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java&p1=pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java&r1=1917823&r2=1917887&rev=1917887&view=diff == --- pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java (original) +++ pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Wed May 22 10:37:02 2024 @@ -1,5 +1,5 @@ /* - * Copyright 2015 The Apache Software Foundation. + * Copyright 2024 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. @@ -15,30 +15,19 @@ */ package org.apache.pdfbox.examples.pdfa; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.security.KeyStore; -import java.util.HashSet; -import java.util.Set; - -import org.apache.pdfbox.Loader; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; import org.apache.pdfbox.examples.pdmodel.CreatePDFA; -import org.apache.pdfbox.examples.signature.CreateSignature; -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDDocumentCatalog; -import org.apache.pdfbox.pdmodel.common.PDMetadata; +import org.apache.pdfbox.examples.util.PDFMergerExample; +import org.apache.pdfbox.io.IOUtils; +import org.apache.pdfbox.io.RandomAccessRead; +import org.apache.pdfbox.io.RandomAccessReadBufferedFile; import org.apache.pdfbox.preflight.ValidationResult; -import org.apache.pdfbox.preflight.ValidationResult.ValidationError; import org.apache.pdfbox.preflight.parser.Prefligh
svn commit: r1917888 - in /pdfbox/branches/2.0/examples/src: main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java
Author: tilman Date: Wed May 22 10:37:22 2024 New Revision: 1917888 URL: http://svn.apache.org/viewvc?rev=1917888&view=rev Log: PDFBOX-5825: add missing entries for metadata dictionary; don't compress for PDF/A-1b; add test with PDF/A check Added: pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java - copied, changed from r1917776, pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java?rev=1917888&r1=1917887&r2=1917888&view=diff == --- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java (original) +++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Wed May 22 10:37:22 2024 @@ -37,6 +37,7 @@ import java.util.List; import javax.xml.transform.TransformerException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.io.IOUtils; /** @@ -163,6 +164,8 @@ public class PDFMergerExample cosXMPStream = cosStream.createOutputStream(); new XmpSerializer().serialize(xmpMetadata, xmpOutputStream, true); cosXMPStream.write(xmpOutputStream.toByteArray()); +cosStream.setName(COSName.TYPE, "Metadata" ); +cosStream.setName(COSName.SUBTYPE, "XML" ); return new PDMetadata(cosStream); } finally Copied: pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java (from r1917776, pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java) URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java?p2=pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java&p1=pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java&r1=1917776&r2=1917888&rev=1917888&view=diff == --- pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java (original) +++ pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Wed May 22 10:37:22 2024 @@ -1,5 +1,5 @@ /* - * Copyright 2015 The Apache Software Foundation. + * Copyright 2024 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. @@ -19,19 +19,18 @@ import junit.framework.TestCase; import java.io.File; import java.io.FileInputStream; -import java.security.KeyStore; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import static junit.framework.TestCase.assertTrue; import org.apache.pdfbox.examples.pdmodel.CreatePDFA; -import org.apache.pdfbox.examples.signature.CreateSignature; -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDDocumentCatalog; -import org.apache.pdfbox.pdmodel.common.PDMetadata; +import org.apache.pdfbox.examples.util.PDFMergerExample; +import org.apache.pdfbox.io.IOUtils; +import org.apache.pdfbox.io.RandomAccessRead; import org.apache.pdfbox.preflight.PreflightDocument; import org.apache.pdfbox.preflight.ValidationResult; -import org.apache.pdfbox.preflight.ValidationResult.ValidationError; import org.apache.pdfbox.preflight.parser.PreflightParser; -import org.apache.xmpbox.XMPMetadata; -import org.apache.xmpbox.schema.DublinCoreSchema; -import org.apache.xmpbox.xml.DomXmpParser; import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider; import org.verapdf.pdfa.Foundries; import org.verapdf.pdfa.PDFAParser; @@ -42,7 +41,7 @@ import org.verapdf.pdfa.flavours.PDFAFla * * @author Tilman Hausherr */ -public class CreatePDFATest extends TestCase +public class MergePDFATest extends TestCase { private final String outDir = "target/test-output"; @@ -53,57 +52,46 @@ public class CreatePDFATest extends Test new File(outDir).mkdirs(); } -/** - * Test of doIt method of class CreatePDFA. - */ -public void testCreatePDFA() throws Exception +public void testMergePDFA() throws Exception { -System.out.println("testCreatePDFA"); -String pdfaFilen
svn commit: r1917889 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java
Author: tilman Date: Wed May 22 10:48:09 2024 New Revision: 1917889 URL: http://svn.apache.org/viewvc?rev=1917889&view=rev Log: PDFBOX-5825: simplify code Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java?rev=1917889&r1=1917888&r2=1917889&view=diff == --- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java (original) +++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Wed May 22 10:48:09 2024 @@ -146,11 +146,9 @@ public class PDFMergerExample basicSchema.setCreatorTool(creator); // Create and return XMP data structure in XML format -try (ByteArrayOutputStream xmpOutputStream = new ByteArrayOutputStream(); - OutputStream cosXMPStream = cosStream.createOutputStream()) +try (OutputStream cosXMPStream = cosStream.createOutputStream()) { -new XmpSerializer().serialize(xmpMetadata, xmpOutputStream, true); -cosXMPStream.write(xmpOutputStream.toByteArray()); +new XmpSerializer().serialize(xmpMetadata, cosXMPStream, true); cosStream.setName(COSName.TYPE, "Metadata" ); cosStream.setName(COSName.SUBTYPE, "XML" ); return new PDMetadata(cosStream);
svn commit: r1917890 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java
Author: tilman Date: Wed May 22 10:48:14 2024 New Revision: 1917890 URL: http://svn.apache.org/viewvc?rev=1917890&view=rev Log: PDFBOX-5825: simplify code Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java?rev=1917890&r1=1917889&r2=1917890&view=diff == --- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java (original) +++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Wed May 22 10:48:14 2024 @@ -160,10 +160,8 @@ public class PDFMergerExample OutputStream cosXMPStream = null; try { -xmpOutputStream = new ByteArrayOutputStream(); cosXMPStream = cosStream.createOutputStream(); -new XmpSerializer().serialize(xmpMetadata, xmpOutputStream, true); -cosXMPStream.write(xmpOutputStream.toByteArray()); +new XmpSerializer().serialize(xmpMetadata, cosXMPStream, true); cosStream.setName(COSName.TYPE, "Metadata" ); cosStream.setName(COSName.SUBTYPE, "XML" ); return new PDMetadata(cosStream);
svn commit: r1917891 - /pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java
Author: tilman Date: Wed May 22 10:48:18 2024 New Revision: 1917891 URL: http://svn.apache.org/viewvc?rev=1917891&view=rev Log: PDFBOX-5825: simplify code Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Modified: pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java?rev=1917891&r1=1917890&r2=1917891&view=diff == --- pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java (original) +++ pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java Wed May 22 10:48:18 2024 @@ -146,11 +146,9 @@ public class PDFMergerExample basicSchema.setCreatorTool(creator); // Create and return XMP data structure in XML format -try (ByteArrayOutputStream xmpOutputStream = new ByteArrayOutputStream(); - OutputStream cosXMPStream = cosStream.createOutputStream()) +try (OutputStream cosXMPStream = cosStream.createOutputStream()) { -new XmpSerializer().serialize(xmpMetadata, xmpOutputStream, true); -cosXMPStream.write(xmpOutputStream.toByteArray()); +new XmpSerializer().serialize(xmpMetadata, cosXMPStream, true); cosStream.setName(COSName.TYPE, "Metadata" ); cosStream.setName(COSName.SUBTYPE, "XML" ); return new PDMetadata(cosStream);
svn commit: r1917892 - /pdfbox/branches/3.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java
Author: tilman Date: Wed May 22 11:34:48 2024 New Revision: 1917892 URL: http://svn.apache.org/viewvc?rev=1917892&view=rev Log: PDFBOX-5826: check for /Type and /Subtype in metadata Modified: pdfbox/branches/3.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java Modified: pdfbox/branches/3.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java?rev=1917892&r1=1917891&r2=1917892&view=diff == --- pdfbox/branches/3.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java (original) +++ pdfbox/branches/3.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java Wed May 22 11:34:48 2024 @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import javax.imageio.ImageIO; import org.apache.pdfbox.cos.COSBase; +import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSStream; import org.apache.pdfbox.pdmodel.PDDocument; @@ -65,7 +66,7 @@ public class MetadataValidationProcess e XMPMetadata metadata; DomXmpParser builder = new DomXmpParser(); -try (InputStream is = getXpacket(document)) +try (InputStream is = getXpacket(document, ctx)) { metadata = builder.parse(is); } @@ -253,7 +254,7 @@ public class MetadataValidationProcess e /** * Return the xpacket from the dictionary's stream */ -private static InputStream getXpacket(PDDocument document) +private InputStream getXpacket(PDDocument document, PreflightContext ctx) throws IOException, XpacketParsingException { PDDocumentCatalog catalog = document.getDocumentCatalog(); @@ -274,7 +275,8 @@ public class MetadataValidationProcess e throw new XpacketParsingException("Failed while retrieving xpacket", error); } -if (metadata.getCOSObject().containsKey(COSName.FILTER)) +COSDictionary metadataDict = metadata.getCOSObject(); +if (metadataDict.containsKey(COSName.FILTER)) { // filter key should not be defined ValidationError error = new ValidationError( @@ -282,6 +284,18 @@ public class MetadataValidationProcess e "Filter specified in metadata dictionary"); throw new XpacketParsingException("Failed while retrieving xpacket", error); } +String type = metadataDict.getNameAsString(COSName.TYPE); +if (!"Metadata".equals(type)) +{ +addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_FORMAT, +"Missing or wrong /Type key in Metadata stream dictionary")); +} +String subType = metadataDict.getNameAsString(COSName.SUBTYPE); +if (!"XML".equals(subType)) +{ +addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_FORMAT, +"Missing or wrong /Subtype key in Metadata stream dictionary")); +} return metadata.exportXMPMetadata(); }
svn commit: r1917893 - /pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java
Author: tilman Date: Wed May 22 11:35:05 2024 New Revision: 1917893 URL: http://svn.apache.org/viewvc?rev=1917893&view=rev Log: PDFBOX-5826: check for /Type and /Subtype in metadata Modified: pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java Modified: pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java?rev=1917893&r1=1917892&r2=1917893&view=diff == --- pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java (original) +++ pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/MetadataValidationProcess.java Wed May 22 11:35:05 2024 @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import javax.imageio.ImageIO; import org.apache.pdfbox.cos.COSBase; +import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSStream; import org.apache.pdfbox.pdmodel.PDDocument; @@ -63,7 +64,7 @@ public class MetadataValidationProcess e { PDDocument document = ctx.getDocument(); -InputStream is = getXpacket(document); +InputStream is = getXpacket(document, ctx); DomXmpParser builder = new DomXmpParser(); XMPMetadata metadata = builder.parse(is); is.close(); @@ -254,7 +255,7 @@ public class MetadataValidationProcess e /** * Return the xpacket from the dictionary's stream */ -private static InputStream getXpacket(PDDocument document) +private InputStream getXpacket(PDDocument document, PreflightContext ctx) throws IOException, XpacketParsingException { PDDocumentCatalog catalog = document.getDocumentCatalog(); @@ -284,6 +285,19 @@ public class MetadataValidationProcess e "Filter specified in metadata dictionary"); throw new XpacketParsingException("Failed while retrieving xpacket", error); } +COSDictionary metadataDict = metadata.getCOSObject(); +String type = metadataDict.getNameAsString(COSName.TYPE); +if (!"Metadata".equals(type)) +{ +addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_FORMAT, +"Missing or wrong /Type key in Metadata stream dictionary")); +} +String subType = metadataDict.getNameAsString(COSName.SUBTYPE); +if (!"XML".equals(subType)) +{ +addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_FORMAT, +"Missing or wrong /Subtype key in Metadata stream dictionary")); +} return metadata.exportXMPMetadata(); }
svn commit: r1917896 - in /pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa: CreatePDFATest.java MergePDFATest.java
Author: tilman Date: Wed May 22 13:27:33 2024 New Revision: 1917896 URL: http://svn.apache.org/viewvc?rev=1917896&view=rev Log: PDFBOX-5660: Sonar fix Modified: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Modified: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java?rev=1917896&r1=1917895&r2=1917896&view=diff == --- pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java (original) +++ pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Wed May 22 13:27:33 2024 @@ -54,7 +54,7 @@ class CreatePDFATest private final String outDir = "target/test-output"; @BeforeEach -protected void setUp() throws Exception +protected void setUp() { new File(outDir).mkdirs(); } Modified: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java?rev=1917896&r1=1917895&r2=1917896&view=diff == --- pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java (original) +++ pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Wed May 22 13:27:33 2024 @@ -19,15 +19,18 @@ import static org.junit.jupiter.api.Asse import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import javax.xml.transform.TransformerException; import org.apache.pdfbox.examples.pdmodel.CreatePDFA; import org.apache.pdfbox.examples.util.PDFMergerExample; import org.apache.pdfbox.io.RandomAccessRead; import org.apache.pdfbox.io.RandomAccessReadBufferedFile; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.verapdf.core.VeraPDFException; import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider; import org.verapdf.pdfa.Foundries; import org.verapdf.pdfa.PDFAParser; @@ -44,13 +47,13 @@ class MergePDFATest private final String outDir = "target/test-output"; @BeforeEach -protected void setUp() throws Exception +protected void setUp() { new File(outDir).mkdirs(); } @Test -void testMergePDFA() throws Exception +void testMergePDFA() throws IOException, TransformerException, VeraPDFException { System.out.println("testMergePDFA"); String pdfaFilename = outDir + "/Source_PDFA.pdf";
svn commit: r1917897 - /pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java
Author: tilman Date: Wed May 22 13:27:37 2024 New Revision: 1917897 URL: http://svn.apache.org/viewvc?rev=1917897&view=rev Log: PDFBOX-5660: Sonar fix Modified: pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Modified: pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java?rev=1917897&r1=1917896&r2=1917897&view=diff == --- pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java (original) +++ pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Wed May 22 13:27:37 2024 @@ -20,17 +20,19 @@ import junit.framework.TestCase; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import javax.xml.transform.TransformerException; import static junit.framework.TestCase.assertTrue; import org.apache.pdfbox.examples.pdmodel.CreatePDFA; import org.apache.pdfbox.examples.util.PDFMergerExample; import org.apache.pdfbox.io.IOUtils; -import org.apache.pdfbox.io.RandomAccessRead; import org.apache.pdfbox.preflight.PreflightDocument; import org.apache.pdfbox.preflight.ValidationResult; import org.apache.pdfbox.preflight.parser.PreflightParser; +import org.verapdf.core.VeraPDFException; import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider; import org.verapdf.pdfa.Foundries; import org.verapdf.pdfa.PDFAParser; @@ -52,7 +54,7 @@ public class MergePDFATest extends TestC new File(outDir).mkdirs(); } -public void testMergePDFA() throws Exception +public void testMergePDFA() throws IOException, TransformerException, VeraPDFException { System.out.println("testMergePDFA"); String pdfaFilename = outDir + "/Source_PDFA.pdf";
svn commit: r1917898 - in /pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa: CreatePDFATest.java MergePDFATest.java
Author: tilman Date: Wed May 22 13:27:42 2024 New Revision: 1917898 URL: http://svn.apache.org/viewvc?rev=1917898&view=rev Log: PDFBOX-5660: Sonar fix Modified: pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Modified: pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java?rev=1917898&r1=1917897&r2=1917898&view=diff == --- pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java (original) +++ pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java Wed May 22 13:27:42 2024 @@ -56,7 +56,7 @@ class CreatePDFATest private final String outDir = "target/test-output"; @BeforeEach -protected void setUp() throws Exception +protected void setUp() { new File(outDir).mkdirs(); } Modified: pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java?rev=1917898&r1=1917897&r2=1917898&view=diff == --- pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java (original) +++ pdfbox/branches/3.0/examples/src/test/java/org/apache/pdfbox/examples/pdfa/MergePDFATest.java Wed May 22 13:27:42 2024 @@ -17,9 +17,11 @@ package org.apache.pdfbox.examples.pdfa; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import javax.xml.transform.TransformerException; import org.apache.pdfbox.examples.pdmodel.CreatePDFA; import org.apache.pdfbox.examples.util.PDFMergerExample; import org.apache.pdfbox.io.IOUtils; @@ -30,6 +32,7 @@ import org.apache.pdfbox.preflight.parse import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.verapdf.core.VeraPDFException; import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider; import org.verapdf.pdfa.Foundries; import org.verapdf.pdfa.PDFAParser; @@ -45,13 +48,13 @@ class MergePDFATest private final String outDir = "target/test-output"; @BeforeEach -protected void setUp() throws Exception +protected void setUp() { new File(outDir).mkdirs(); } @Test -void testMergePDFA() throws Exception +void testMergePDFA() throws IOException, TransformerException, VeraPDFException { System.out.println("testMergePDFA"); String pdfaFilename = outDir + "/Source_PDFA.pdf";
svn commit: r1917926 - in /pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf: GlyfCompositeDescript.java GlyphData.java GlyphTable.java
Author: tilman Date: Thu May 23 15:20:03 2024 New Revision: 1917926 URL: http://svn.apache.org/viewvc?rev=1917926&view=rev Log: PDFBOX-5827: avoid stack overflow by tracking the depth up to maxp.MaxComponentDepth Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java?rev=1917926&r1=1917925&r2=1917926&view=diff == --- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java (original) +++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java Thu May 23 15:20:03 2024 @@ -56,9 +56,10 @@ public class GlyfCompositeDescript exten * * @param bais the stream to be read * @param glyphTable the Glyphtable containing all glyphs + * @param level current level * @throws IOException is thrown if something went wrong */ -GlyfCompositeDescript(TTFDataStream bais, GlyphTable glyphTable) throws IOException +GlyfCompositeDescript(TTFDataStream bais, GlyphTable glyphTable, int level) throws IOException { super((short) -1, bais); @@ -78,7 +79,7 @@ public class GlyfCompositeDescript exten { readInstructions(bais, (bais.readUnsignedShort())); } -initDescriptions(); +initDescriptions(level); } /** @@ -293,14 +294,14 @@ public class GlyfCompositeDescript exten return null; } -private void initDescriptions() +private void initDescriptions(int level) { for (GlyfCompositeComp component : components) { try { int index = component.getGlyphIndex(); -GlyphData glyph = glyphTable.getGlyph(index); +GlyphData glyph = glyphTable.getGlyph(index, level); if (glyph != null) { descriptions.put(index, glyph.getDescription()); Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java?rev=1917926&r1=1917925&r2=1917926&view=diff == --- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java (original) +++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java Thu May 23 15:20:03 2024 @@ -42,9 +42,11 @@ public class GlyphData * @param glyphTable The glyph table this glyph belongs to. * @param data The stream to read the data from. * @param leftSideBearing The left side bearing for this glyph. + * @param level composite level * @throws IOException If there is an error reading the data. */ -void initData( GlyphTable glyphTable, TTFDataStream data, int leftSideBearing ) throws IOException +void initData( GlyphTable glyphTable, TTFDataStream data, int leftSideBearing, int level) +throws IOException { numberOfContours = data.readSignedShort(); xMin = data.readSignedShort(); @@ -62,7 +64,7 @@ public class GlyphData else { // create a composite glyph -glyphDescription = new GlyfCompositeDescript(data, glyphTable); +glyphDescription = new GlyfCompositeDescript(data, glyphTable, level + 1); } } Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java?rev=1917926&r1=1917925&r2=1917926&view=diff == --- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java (original) +++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java Thu May 23 15:20:03 2024 @@ -40,6 +40,7 @@ public class GlyphTable extends TTFTable private int cached = 0; private HorizontalMetricsTable hmt = null; +private MaximumProfileTable maxp = null; /** * Don't even bother to cache huge fonts. @@ -83,6 +84,8 @@ public class GlyphTable extends TTFTable // locks TrueTypeFont and then tries to lock "data" hmt = font.getHorizontalMetrics(); +maxp = ttf.getMaximumProfile(); + initia
svn commit: r1917927 - in /pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf: GlyfCompositeDescript.java GlyphData.java GlyphTable.java
Author: tilman Date: Thu May 23 15:20:07 2024 New Revision: 1917927 URL: http://svn.apache.org/viewvc?rev=1917927&view=rev Log: PDFBOX-5827: avoid stack overflow by tracking the depth up to maxp.MaxComponentDepth Modified: pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java Modified: pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java?rev=1917927&r1=1917926&r2=1917927&view=diff == --- pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java (original) +++ pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java Thu May 23 15:20:07 2024 @@ -56,9 +56,10 @@ public class GlyfCompositeDescript exten * * @param bais the stream to be read * @param glyphTable the Glyphtable containing all glyphs + * @param level current level * @throws IOException is thrown if something went wrong */ -GlyfCompositeDescript(TTFDataStream bais, GlyphTable glyphTable) throws IOException +GlyfCompositeDescript(TTFDataStream bais, GlyphTable glyphTable, int level) throws IOException { super((short) -1); @@ -78,7 +79,7 @@ public class GlyfCompositeDescript exten { readInstructions(bais, (bais.readUnsignedShort())); } -initDescriptions(); +initDescriptions(level); } /** @@ -293,14 +294,14 @@ public class GlyfCompositeDescript exten return null; } -private void initDescriptions() +private void initDescriptions(int level) { for (GlyfCompositeComp component : components) { try { int index = component.getGlyphIndex(); -GlyphData glyph = glyphTable.getGlyph(index); +GlyphData glyph = glyphTable.getGlyph(index, level); if (glyph != null) { descriptions.put(index, glyph.getDescription()); Modified: pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java?rev=1917927&r1=1917926&r2=1917927&view=diff == --- pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java (original) +++ pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java Thu May 23 15:20:07 2024 @@ -42,9 +42,11 @@ public class GlyphData * @param glyphTable The glyph table this glyph belongs to. * @param data The stream to read the data from. * @param leftSideBearing The left side bearing for this glyph. + * @param level composite level * @throws IOException If there is an error reading the data. */ -void initData( GlyphTable glyphTable, TTFDataStream data, int leftSideBearing ) throws IOException +void initData( GlyphTable glyphTable, TTFDataStream data, int leftSideBearing, int level) +throws IOException { numberOfContours = data.readSignedShort(); xMin = data.readSignedShort(); @@ -62,7 +64,7 @@ public class GlyphData else { // create a composite glyph -glyphDescription = new GlyfCompositeDescript(data, glyphTable); +glyphDescription = new GlyfCompositeDescript(data, glyphTable, level + 1); } } Modified: pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java?rev=1917927&r1=1917926&r2=1917927&view=diff == --- pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java (original) +++ pdfbox/branches/3.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java Thu May 23 15:20:07 2024 @@ -42,6 +42,7 @@ public class GlyphTable extends TTFTable private int cached = 0; private HorizontalMetricsTable hmt = null; +private MaximumProfileTable maxp = null; /** * Don't even bother to cache huge fonts. @@ -55,7 +56,6 @@ public class GlyphTable extends TTFTable GlyphTable() { -super(); } /** @@ -87,6 +87,8 @@ public class GlyphTable extends TTFTable // locks TrueTypeFont and then tries to lock &
svn commit: r1917925 - in /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf: GlyfCompositeDescript.java GlyphData.java GlyphTable.java
Author: tilman Date: Thu May 23 15:19:58 2024 New Revision: 1917925 URL: http://svn.apache.org/viewvc?rev=1917925&view=rev Log: PDFBOX-5827: avoid stack overflow by tracking the depth up to maxp.MaxComponentDepth Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java?rev=1917925&r1=1917924&r2=1917925&view=diff == --- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java (original) +++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java Thu May 23 15:19:58 2024 @@ -55,9 +55,10 @@ public class GlyfCompositeDescript exten * * @param bais the stream to be read * @param glyphTable the Glyphtable containing all glyphs + * @param level current level * @throws IOException is thrown if something went wrong */ -GlyfCompositeDescript(TTFDataStream bais, GlyphTable glyphTable) throws IOException +GlyfCompositeDescript(TTFDataStream bais, GlyphTable glyphTable, int level) throws IOException { super((short) -1); @@ -77,7 +78,7 @@ public class GlyfCompositeDescript exten { readInstructions(bais, (bais.readUnsignedShort())); } -initDescriptions(); +initDescriptions(level); } /** @@ -292,14 +293,14 @@ public class GlyfCompositeDescript exten return null; } -private void initDescriptions() +private void initDescriptions(int level) { for (GlyfCompositeComp component : components) { try { int index = component.getGlyphIndex(); -GlyphData glyph = glyphTable.getGlyph(index); +GlyphData glyph = glyphTable.getGlyph(index, level); if (glyph != null) { descriptions.put(index, glyph.getDescription()); Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java?rev=1917925&r1=1917924&r2=1917925&view=diff == --- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java (original) +++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java Thu May 23 15:19:58 2024 @@ -42,9 +42,11 @@ public class GlyphData * @param glyphTable The glyph table this glyph belongs to. * @param data The stream to read the data from. * @param leftSideBearing The left side bearing for this glyph. + * @param level composite level * @throws IOException If there is an error reading the data. */ -void initData( GlyphTable glyphTable, TTFDataStream data, int leftSideBearing ) throws IOException +void initData( GlyphTable glyphTable, TTFDataStream data, int leftSideBearing, int level) +throws IOException { numberOfContours = data.readSignedShort(); xMin = data.readSignedShort(); @@ -62,7 +64,7 @@ public class GlyphData else { // create a composite glyph -glyphDescription = new GlyfCompositeDescript(data, glyphTable); +glyphDescription = new GlyfCompositeDescript(data, glyphTable, level + 1); } } Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java?rev=1917925&r1=1917924&r2=1917925&view=diff == --- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java (original) +++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java Thu May 23 15:19:58 2024 @@ -42,6 +42,7 @@ public class GlyphTable extends TTFTable private int cached = 0; private HorizontalMetricsTable hmt = null; +private MaximumProfileTable maxp = null; /** * Don't even bother to cache huge fonts. @@ -55,7 +56,6 @@ public class GlyphTable extends TTFTable GlyphTable() { -super(); } /** @@ -87,6 +87,8 @@ public class GlyphTable extends TTFTable // locks TrueTypeFont and then tries to lock "data" hmt = ttf.getHorizontalMetrics(); +maxp = ttf.getMaximumProfile(); + initial
svn commit: r1917969 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
Author: tilman Date: Sun May 26 10:31:37 2024 New Revision: 1917969 URL: http://svn.apache.org/viewvc?rev=1917969&view=rev Log: PDFBOX-5829: suuport floats like '-12.-1' Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java?rev=1917969&r1=1917968&r2=1917969&view=diff == --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java Sun May 26 10:31:37 2024 @@ -73,6 +73,11 @@ public class COSFloat extends COSNumber // PDFBOX-3500 has 0.-262 valueAsString = "-" + valueAsString.replaceFirst("\\-", ""); } +else if (aFloat.matches("^-\\d+\\.-\\d+")) +{ +// PDFBOX-5829 has -12.-1 +valueAsString = "-" + valueAsString.replace("-", ""); +} else { throw new IOException("Error expected floating point number actual='" + aFloat + "'", e);
svn commit: r1917970 - in /pdfbox/branches/3.0/pdfbox/src: main/java/org/apache/pdfbox/cos/COSFloat.java test/java/org/apache/pdfbox/cos/TestCOSFloat.java
Author: tilman Date: Sun May 26 10:31:41 2024 New Revision: 1917970 URL: http://svn.apache.org/viewvc?rev=1917970&view=rev Log: PDFBOX-5829: suuport floats like '-12.-1' Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java?rev=1917970&r1=1917969&r2=1917970&view=diff == --- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java (original) +++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java Sun May 26 10:31:41 2024 @@ -88,6 +88,11 @@ public class COSFloat extends COSNumber // PDFBOX-3500 has 0.-262 aFloat = "-" + aFloat.replaceFirst("-", ""); } +else if (aFloat.matches("^-\\d+\\.-\\d+")) +{ +// PDFBOX-5829 has -12.-1 +aFloat = "-" + aFloat.replace("-", ""); +} else { throw new IOException("Error expected floating point number actual='" + aFloat + "'", e); Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java?rev=1917970&r1=1917969&r2=1917970&view=diff == --- pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java (original) +++ pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java Sun May 26 10:31:41 2024 @@ -384,13 +384,18 @@ class TestCOSFloat extends TestCOSNumber cosFloat = new COSFloat("0.-262"); assertEquals(new COSFloat("-0.262"), cosFloat); + +cosFloat = new COSFloat("-0.-262"); +assertEquals(new COSFloat("-0.262"), cosFloat); + +cosFloat = new COSFloat("-12.-1"); +assertEquals(new COSFloat("-12.1"), cosFloat); } @Test void testDuplicateMisplacedNegative() { assertThrows(IOException.class, () -> new COSFloat("0.-26-2")); -assertThrows(IOException.class, () -> new COSFloat("-0.-262")); assertThrows(IOException.class, () -> new COSFloat("---0.262")); assertThrows(IOException.class, () -> new COSFloat("--0.2-62")); }
svn commit: r1917971 - in /pdfbox/trunk/pdfbox/src: main/java/org/apache/pdfbox/cos/COSFloat.java test/java/org/apache/pdfbox/cos/TestCOSFloat.java
Author: tilman Date: Sun May 26 10:31:46 2024 New Revision: 1917971 URL: http://svn.apache.org/viewvc?rev=1917971&view=rev Log: PDFBOX-5829: suuport floats like '-12.-1' Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java?rev=1917971&r1=1917970&r2=1917971&view=diff == --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java Sun May 26 10:31:46 2024 @@ -88,6 +88,11 @@ public class COSFloat extends COSNumber // PDFBOX-3500 has 0.-262 aFloat = "-" + aFloat.replaceFirst("-", ""); } +else if (aFloat.matches("^-\\d+\\.-\\d+")) +{ +// PDFBOX-5829 has -12.-1 +aFloat = "-" + aFloat.replace("-", ""); +} else { throw new IOException("Error expected floating point number actual='" + aFloat + "'", e); Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java?rev=1917971&r1=1917970&r2=1917971&view=diff == --- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java (original) +++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java Sun May 26 10:31:46 2024 @@ -384,13 +384,18 @@ class TestCOSFloat extends TestCOSNumber cosFloat = new COSFloat("0.-262"); assertEquals(new COSFloat("-0.262"), cosFloat); + +cosFloat = new COSFloat("-0.-262"); +assertEquals(new COSFloat("-0.262"), cosFloat); + +cosFloat = new COSFloat("-12.-1"); +assertEquals(new COSFloat("-12.1"), cosFloat); } @Test void testDuplicateMisplacedNegative() { assertThrows(IOException.class, () -> new COSFloat("0.-26-2")); -assertThrows(IOException.class, () -> new COSFloat("-0.-262")); assertThrows(IOException.class, () -> new COSFloat("---0.262")); assertThrows(IOException.class, () -> new COSFloat("--0.2-62")); }
svn commit: r1918007 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java
Author: tilman Date: Mon May 27 18:22:34 2024 New Revision: 1918007 URL: http://svn.apache.org/viewvc?rev=1918007&view=rev Log: PDFBOX-5830: avoid NPE and assume gid 0 if name doesn't exist in Adobe glyph list Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java?rev=1918007&r1=1918006&r2=1918007&view=diff == --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java Mon May 27 18:22:34 2024 @@ -99,8 +99,12 @@ final class PDTrueTypeFontEmbedder exten if (code >= firstChar && code <= lastChar) { String uni = glyphList.toUnicode(name); -int charCode = uni.codePointAt(0); -int gid = cmapLookup.getGlyphId(charCode); +int gid = 0; +if (uni != null) +{ +int charCode = uni.codePointAt(0); +gid = cmapLookup.getGlyphId(charCode); +} widths.set(entry.getKey() - firstChar, Math.round(hmtx.getAdvanceWidth(gid) * scaling)); }
svn commit: r1918008 - /pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java
Author: tilman Date: Mon May 27 18:22:38 2024 New Revision: 1918008 URL: http://svn.apache.org/viewvc?rev=1918008&view=rev Log: PDFBOX-5830: avoid NPE and assume gid 0 if name doesn't exist in Adobe glyph list Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java?rev=1918008&r1=1918007&r2=1918008&view=diff == --- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java (original) +++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java Mon May 27 18:22:38 2024 @@ -99,8 +99,12 @@ final class PDTrueTypeFontEmbedder exten if (code >= firstChar && code <= lastChar) { String uni = glyphList.toUnicode(name); -int charCode = uni.codePointAt(0); -int gid = cmapLookup.getGlyphId(charCode); +int gid = 0; +if (uni != null) +{ +int charCode = uni.codePointAt(0); +gid = cmapLookup.getGlyphId(charCode); +} widths.set(entry.getKey() - firstChar, Math.round(hmtx.getAdvanceWidth(gid) * scaling)); }
svn commit: r1918009 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java
Author: tilman Date: Mon May 27 18:22:42 2024 New Revision: 1918009 URL: http://svn.apache.org/viewvc?rev=1918009&view=rev Log: PDFBOX-5830: avoid NPE and assume gid 0 if name doesn't exist in Adobe glyph list Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java?rev=1918009&r1=1918008&r2=1918009&view=diff == --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java Mon May 27 18:22:42 2024 @@ -99,8 +99,12 @@ final class PDTrueTypeFontEmbedder exten if (code >= firstChar && code <= lastChar) { String uni = glyphList.toUnicode(name); -int charCode = uni.codePointAt(0); -int gid = cmapLookup.getGlyphId(charCode); +int gid = 0; +if (uni != null) +{ +int charCode = uni.codePointAt(0); +gid = cmapLookup.getGlyphId(charCode); +} widths.set(entry.getKey() - firstChar, Math.round(hmtx.getAdvanceWidth(gid) * scaling)); }
(pdfbox-docs) branch master updated: PDFBOX-5655: add Charsets class
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new 2ce836d2 PDFBOX-5655: add Charsets class 2ce836d2 is described below commit 2ce836d2a20a2f17d4b7b07fc41d62c106a16d8c Author: Tilman Hausherr AuthorDate: Wed May 29 13:54:20 2024 +0200 PDFBOX-5655: add Charsets class --- content/3.0/migration.md | 4 1 file changed, 4 insertions(+) diff --git a/content/3.0/migration.md b/content/3.0/migration.md index dae36a8a..f78c808b 100644 --- a/content/3.0/migration.md +++ b/content/3.0/migration.md @@ -203,6 +203,10 @@ range and define using `float` triples instead. Instead of using the `PDAnnotationTextMarkup`, `PDAnnotationSquareCircle` or the `PDAnnotationMarkup` classes when creating certain annotations, use their subclasses `PDAnnotationCaret`, `PDAnnotationFreeText`, `PDAnnotationInk`, `PDAnnotationPolygon`, `PDAnnotationPolyline`, `PDAnnotationSound`, `PDAnnotationCircle`, `PDAnnotationSquare`, `PDAnnotationHighlight`, `PDAnnotationSquiggly`, `PDAnnotationStrikeout` and `PDAnnotationUnderline`. +### Changes with charsets + +The convenience class `org.apache.pdfbox.util.Charsets` has been removed. Please use the java class `java.nio.charset.StandardCharsets` instead. + ## Changes in Common Functions ### Interactive Forms
(pdfbox-docs) branch master updated: PDFBOX-5655: fix typo
This is an automated email from the ASF dual-hosted git repository. tilman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pdfbox-docs.git The following commit(s) were added to refs/heads/master by this push: new c7f63127 PDFBOX-5655: fix typo c7f63127 is described below commit c7f631274a007a21c597f1b54ed01dd33aabf59a Author: Tilman Hausherr AuthorDate: Wed May 29 13:57:21 2024 +0200 PDFBOX-5655: fix typo --- content/3.0/migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/3.0/migration.md b/content/3.0/migration.md index f78c808b..a9447ef4 100644 --- a/content/3.0/migration.md +++ b/content/3.0/migration.md @@ -120,7 +120,7 @@ PDFBox 3.0.x no longer uses a separate cache when reading a pdf, but still does - ***org.apache.pdfbox.io.RandomAccessStreamCache*** -`RandomAccessStreamCacheImpl` is a simple default implementaion using `RandomAccessReadWriteBuffer` as buffer. +`RandomAccessStreamCacheImpl` is a simple default implementation using `RandomAccessReadWriteBuffer` as buffer. - ***org.apache.pdfbox.io.ScratchFile***