[ https://issues.apache.org/jira/browse/PDFBOX-5882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17887535#comment-17887535 ]
Tilman Hausherr edited comment on PDFBOX-5882 at 10/19/24 10:11 AM: -------------------------------------------------------------------- I've added a warning. My original idea was to throw an exception, but these might happen in rendering in some cases so the warning is a compromise. Update: it does happen, e.g. with file {{pop-bugzilla62905.pdf}} from https://bugs.freedesktop.org/show_bug.cgi?id=62905 . was (Author: tilman): I've added a warning. My original idea was to throw an exception, but these might happen in rendering in some cases so the warning is a compromise. Update: it does happen, e.g. with the pop-bugzilla62905.pdf from https://bugs.freedesktop.org/show_bug.cgi?id=62905 . > 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 > Components: PDModel > Affects Versions: 2.0.24, 2.0.32, 3.0.3 PDFBox > Reporter: bai yuan > Assignee: Tilman Hausherr > Priority: Major > Fix For: 2.0.33, 3.0.4 PDFBox, 4.0.0 > > Attachments: excel_pattern_fill-fixed.pdf, 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