Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.0.24, 2.0.32, 3.0.3 PDFBox
-
None
Description
The pattern created with PDFBox shows inconsistent colors between Safari and Adobe.
It appears red in Adobe and Chrome, which is correct.
It appears blue in Safari, which is incorrect.
Here is the example code:
try (PDDocument document = new PDDocument()) { PDPage page = new PDPage(); document.addPage(page); try (PDPageContentStream contentStream = new PDPageContentStream(document, page)) { PDTilingPattern pattern = new PDTilingPattern(); pattern.setBBox(new PDRectangle(3, 3)); pattern.setPaintType(PDTilingPattern.PAINT_UNCOLORED); pattern.setTilingType(PDTilingPattern.TILING_CONSTANT_SPACING); pattern.setXStep(3); pattern.setYStep(3); pattern.setMatrix(Matrix.getScaleInstance(1, 1).createAffineTransform()); try (PDPatternContentStream patternContentStream = new PDPatternContentStream(pattern)) { patternContentStream.setLineWidth(0.4f); patternContentStream.moveTo(0, 2); patternContentStream.lineTo(0, 3); patternContentStream.lineTo(2, 3); patternContentStream.lineTo(2, 2); patternContentStream.lineTo(3, 2); patternContentStream.lineTo(3, 0); patternContentStream.lineTo(2, 0); patternContentStream.lineTo(2, 1); patternContentStream.lineTo(1, 1); patternContentStream.lineTo(1, 2); patternContentStream.closePath(); patternContentStream.fill(); } catch (IOException e) { throw new RuntimeException(e); }; COSName patternName = page.getResources().add(pattern); PDPattern pdPattern = new PDPattern(page.getResources(), PDDeviceRGB.INSTANCE); PDColor pdColor = new PDColor(Color.RED.getComponents(null), patternName, pdPattern); contentStream.setNonStrokingColor(pdColor); contentStream.addRect(100, 500, 400, 200); contentStream.fill(); } document.save("excel_pattern_fill.pdf"); }
*Safari:*
Adobe:
The exported pdf file : excel_pattern_fill.pdf