[Git][java-team/libsambox-java][upstream] New upstream version 2.3.1

Markus Koschany (@apo) gitlab at salsa.debian.org
Sat Nov 20 21:48:28 GMT 2021



Markus Koschany pushed to branch upstream at Debian Java Maintainers / libsambox-java


Commits:
bfc4d272 by Markus Koschany at 2021-11-20T22:43:58+01:00
New upstream version 2.3.1
- - - - -


3 changed files:

- pom.xml
- src/main/java/org/sejda/sambox/pdmodel/PDPage.java
- src/main/java/org/sejda/sambox/pdmodel/common/PDNameTreeNode.java


Changes:

=====================================
pom.xml
=====================================
@@ -5,7 +5,7 @@
 	<artifactId>sambox</artifactId>
 	<packaging>jar</packaging>
 	<name>sambox</name>
-	<version>2.3.0</version>
+	<version>2.3.1</version>
 
 	<description>An Apache PDFBox fork intended to be used as PDF processor for Sejda and PDFsam related projects</description>
 	<url>http://www.sejda.org</url>
@@ -33,7 +33,7 @@
 		<connection>scm:git:git at github.com:torakiki/sambox.git</connection>
 		<developerConnection>scm:git:git at github.com:torakiki/sambox.git</developerConnection>
 		<url>scm:git:git at github.com:torakiki/sambox.git</url>
-		<tag>v2.3.0</tag>
+		<tag>v2.3.1</tag>
 	</scm>
 
 	<developers>


=====================================
src/main/java/org/sejda/sambox/pdmodel/PDPage.java
=====================================
@@ -162,13 +162,13 @@ public class PDPage implements COSObjectable, PDContentStream
             for (int i = 0; i < array.size(); i++)
             {
                 COSBase baseObject = array.getObject(i);
-                if(baseObject instanceof COSStream) 
+                if (baseObject instanceof COSStream)
                 {
                     COSStream stream = (COSStream) baseObject;
                     if (nonNull(stream))
                     {
                         streams.add(new PDStream(stream));
-                    }    
+                    }
                 }
                 else
                 {
@@ -232,9 +232,9 @@ public class PDPage implements COSObjectable, PDContentStream
     {
         if (pageResources == null)
         {
-            pageResources = new PDResources(ofNullable(
-                    (COSDictionary) PDPageTree.getInheritableAttribute(page, COSName.RESOURCES, COSDictionary.class))
-                            .orElseGet(() -> {
+            pageResources = new PDResources(
+                    ofNullable((COSDictionary) PDPageTree.getInheritableAttribute(page,
+                            COSName.RESOURCES, COSDictionary.class)).orElseGet(() -> {
                                 COSDictionary emptyRes = new COSDictionary();
                                 // it's illegal for a page to not have resources, either direct or inherited. According
                                 // to the specs "If the page requires no resources, the value of this entry shall be an
@@ -322,8 +322,12 @@ public class PDPage implements COSObjectable, PDContentStream
 
     public PDRectangle getMediaBoxRaw()
     {
-        return PDRectangle
-                .rectangleFrom(page.getDictionaryObject(COSName.MEDIA_BOX, COSArray.class));
+        COSBase array = PDPageTree.getInheritableAttribute(page, COSName.MEDIA_BOX);
+        if (array instanceof COSArray)
+        {
+            return PDRectangle.rectangleFrom((COSArray) array);
+        }
+        return null;
     }
 
     /**
@@ -368,8 +372,12 @@ public class PDPage implements COSObjectable, PDContentStream
 
     public PDRectangle getCropBoxRaw()
     {
-        return PDRectangle
-                .rectangleFrom(page.getDictionaryObject(COSName.CROP_BOX, COSArray.class));
+        COSBase array = PDPageTree.getInheritableAttribute(page, COSName.CROP_BOX);
+        if (array instanceof COSArray)
+        {
+            return PDRectangle.rectangleFrom((COSArray) array);
+        }
+        return null;
     }
 
     /**
@@ -399,14 +407,10 @@ public class PDPage implements COSObjectable, PDContentStream
     {
         try
         {
-            COSBase base = page.getDictionaryObject(COSName.BLEED_BOX);
-            if (base instanceof COSArray)
+            PDRectangle trimBox = getBleedBoxRaw();
+            if (inMediaBoxBounds(trimBox))
             {
-                COSArray array = (COSArray) base;
-                if (inMediaBoxBounds(new PDRectangle(array)))
-                {
-                    return new PDRectangle((COSArray) base);
-                }
+                return trimBox;
             }
         }
         catch (Exception ex)
@@ -449,14 +453,10 @@ public class PDPage implements COSObjectable, PDContentStream
     {
         try
         {
-            COSBase base = page.getDictionaryObject(COSName.TRIM_BOX);
-            if (base instanceof COSArray)
+            PDRectangle trimBox = getTrimBoxRaw();
+            if (inMediaBoxBounds(trimBox))
             {
-                COSArray array = (COSArray) base;
-                if (inMediaBoxBounds(new PDRectangle(array)))
-                {
-                    return new PDRectangle(array);
-                }
+                return trimBox;
             }
         }
         catch (Exception ex)
@@ -499,14 +499,10 @@ public class PDPage implements COSObjectable, PDContentStream
     {
         try
         {
-            COSBase base = page.getDictionaryObject(COSName.ART_BOX);
-            if (base instanceof COSArray)
+            PDRectangle artBox = getArtBoxRaw();
+            if (inMediaBoxBounds(artBox))
             {
-                COSArray array = (COSArray) base;
-                if (inMediaBoxBounds(new PDRectangle(array)))
-                {
-                    return new PDRectangle(array);
-                }
+                return artBox;
             }
         }
         catch (Exception ex)
@@ -558,7 +554,7 @@ public class PDPage implements COSObjectable, PDContentStream
     private boolean inMediaBoxBounds(PDRectangle box)
     {
         PDRectangle mediaBox = getMediaBox();
-        return mediaBox.getLowerLeftX() <= box.getLowerLeftX()
+        return nonNull(box) && mediaBox.getLowerLeftX() <= box.getLowerLeftX()
                 && mediaBox.getLowerLeftY() <= box.getLowerLeftY()
                 && mediaBox.getUpperRightX() >= box.getUpperRightX()
                 && mediaBox.getUpperRightY() >= box.getUpperRightY();
@@ -942,7 +938,8 @@ public class PDPage implements COSObjectable, PDContentStream
         });
     }
 
-    public COSDictionary getPageTreeParent() {
+    public COSDictionary getPageTreeParent()
+    {
         return pageTreeParent;
     }
 }


=====================================
src/main/java/org/sejda/sambox/pdmodel/common/PDNameTreeNode.java
=====================================
@@ -291,7 +291,17 @@ public abstract class PDNameTreeNode<T extends COSObjectable> implements COSObje
                     continue;
                 }
                 COSBase cosValue = namesArray.getObject(i + 1);
-                names.put(key.getString(), convertCOSToPD(cosValue));
+                T pdValue = null;
+                try 
+                {
+                    pdValue = convertCOSToPD(cosValue);
+                } 
+                catch (ClassCastException ex)
+                {
+                    LOG.warn("Skipping, could not convert COS to PD: " + cosValue, ex);
+                }
+
+                names.put(key.getString(), pdValue);
             }
             return Collections.unmodifiableMap(names);
         }



View it on GitLab: https://salsa.debian.org/java-team/libsambox-java/-/commit/bfc4d2722e1d738e416f9ade2d3bb64e77c78af8

-- 
View it on GitLab: https://salsa.debian.org/java-team/libsambox-java/-/commit/bfc4d2722e1d738e416f9ade2d3bb64e77c78af8
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20211120/7281cc7f/attachment.htm>


More information about the pkg-java-commits mailing list