bai yuan created PDFBOX-5882: -------------------------------- Summary: The pattern created with PDFBox shows inconsistent colors between Safari and Adobe. Key: PDFBOX-5882 URL: https://issues.apache.org/jira/browse/PDFBOX-5882 Project: PDFBox Issue Type: Bug Affects Versions: 2.0.24 Reporter: bai yuan Attachments: excel_pattern_fill.pdf, image-2024-10-08-16-04-32-344.png, image-2024-10-08-16-04-49-033.png
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: {code:java} 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"); } {code} **Safari:** !image-2024-10-08-16-04-32-344.png! Adobe: !image-2024-10-08-16-04-49-033.png! The exported pdf file : excel_pattern_fill.pdf -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org