Author: tilman
Date: Fri Sep 11 19:31:49 2026
New Revision: 1938117

Log:
PDFBOX-5250: add test, by Valery Bokov; closes #529

Modified:
   pdfbox/branches/3.0/pdfbox/pom.xml
   
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestQuality.java

Modified: pdfbox/branches/3.0/pdfbox/pom.xml
==============================================================================
--- pdfbox/branches/3.0/pdfbox/pom.xml  Fri Sep 11 19:31:35 2026        
(r1938116)
+++ pdfbox/branches/3.0/pdfbox/pom.xml  Fri Sep 11 19:31:49 2026        
(r1938117)
@@ -95,6 +95,12 @@
             <version>${jbig2.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.twelvemonkeys.imageio</groupId>
+            <artifactId>imageio-jpeg</artifactId>
+            <version>3.14.0</version>
+            <scope>test</scope>
+        </dependency>
         <!-- can't use 5.*, doesn't support jdk11 -->
         <dependency>
             <groupId>org.mockito</groupId>
@@ -114,7 +120,7 @@
         <dependency>
             <groupId>com.github.jai-imageio</groupId>
             <artifactId>jai-imageio-jpeg2000</artifactId>
-            <version>${jai.version}</version>
+            <version>1.4.1-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -152,9 +158,10 @@
             <plugin>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
-                    <argLine>@{surefireArgLine} -Xmx1g</argLine>
+                    <argLine>@{surefireArgLine} -Xmx32g</argLine>
                     <excludes>
                         
<exclude>org/apache/pdfbox/rendering/TestPDFToImage.java</exclude>
+                        
<exclude>org/apache/pdfbox/rendering/TestRendering.java</exclude>
                     </excludes>
                     <systemPropertyVariables>
                         
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
@@ -1015,6 +1022,19 @@
                         </configuration>
                     </execution>
                     <execution>
+                        <id>PDFBOX-5250</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>wget</goal>
+                        </goals>
+                        <configuration>
+                            
<url>https://issues.apache.org/jira/secure/attachment/13073765/PDFBOX-5250-pattern-reduced3.pdf</url>
+                            
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
+                            
<outputFileName>PDFBOX-5250-pattern-reduced3.pdf</outputFileName>
+                            
<sha512>fef1da8db49531a3bf017c6872b2032cac2d3c7e431f5529a80f87886b2d06455d086c9228ad35aee80d824ffb9e65e5ea302327b7feada001ede66f83199101</sha512>
+                        </configuration>
+                    </execution>
+                    <execution>
                         <id>PDFBOX-5960</id>
                         <phase>generate-test-resources</phase>
                         <goals>

Modified: 
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestQuality.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestQuality.java
       Fri Sep 11 19:31:35 2026        (r1938116)
+++ 
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestQuality.java
       Fri Sep 11 19:31:49 2026        (r1938117)
@@ -136,6 +136,38 @@ class TestQuality
     }
 
     /**
+     * PDFBOX-5250: a mesh shading pattern used inside a transparency group 
that has its own
+     * non-trivial /Matrix must be positioned using that group's own initial 
matrix, not the
+     * parent's. Before the fix, the transparency group's /Matrix was 
concatenated into the CTM
+     * only after the initial matrix had already been captured, so any pattern 
painted inside the
+     * group (here, a colored tiling pattern whose cell is itself a 
transparency group filled
+     * with a type 7 shading) was placed using the wrong reference matrix. 
That shifted the mesh
+     * shading far out of position, so instead of the intended multicolor 
gradient, only a
+     * single, mostly-green sliver of it ever landed on the visible glyphs.
+     *
+     * @throws IOException
+     */
+    @Test
+    void testPDFBox5250() throws IOException
+    {
+        File file = new File(TARGET_PDF_DIR, 
"PDFBOX-5250-pattern-reduced3.pdf");
+        try (PDDocument doc = Loader.loadPDF(file))
+        {
+            PDFRenderer renderer = new PDFRenderer(doc);
+            BufferedImage renderedImage = renderer.renderImageWithDPI(0, 100);
+            // a pixel within the shading-pattern-filled text; before the fix, 
the mesh shading
+            // was shifted out of view here, leaving this pixel blank white 
instead of the
+            // gradient's red-ish color. Checking red without also ruling out 
green isn't enough
+            // because white also has a maxed-out red channel.
+            int rgb = renderedImage.getRGB(190, 331);
+            int red = (rgb >> 16) & 0xFF;
+            int green = (rgb >> 8) & 0xFF;
+            Assertions.assertTrue(red > 150 && green < 150,
+                    "expected a red-ish gradient pixel but was: " + 
Integer.toHexString(rgb));
+        }
+    }
+  
+    /**
      * PDFBOX-5876: rendering a page containing a very large JPEG 2000 (JPX) 
image at reduced
      * scale must not decode the image at full resolution first just to read 
its width, height
      * and color space. Before the fix, {@code PDImageXObject.initJPXValues()} 
did exactly that,

Reply via email to