Skip to content

Commit

Permalink
PDFBOX-5851: set color and colorspace before setting the path, as sug…
Browse files Browse the repository at this point in the history
…gested by Michael Klink

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1919371 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Jul 19, 2024
1 parent feae0c8 commit 54b327b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public static void main(String[] args) throws IOException

PDColor patternColor1 = new PDColor(patternName1, patternCS1);

pcs.addRect(50, 500, 200, 200);
pcs.setNonStrokingColor(patternColor1);
pcs.addRect(50, 500, 200, 200);
pcs.fill();

// Uncolored pattern - the color is passed later
Expand Down Expand Up @@ -111,20 +111,20 @@ public static void main(String[] args) throws IOException
patternName2,
patternCS2);

pcs.addRect(300, 500, 100, 100);
pcs.setNonStrokingColor(patternColor2green);
pcs.addRect(300, 500, 100, 100);
pcs.fill();

// same pattern again but with different color + different pattern start position
PDColor patternColor2blue = new PDColor(
new float[]{0,0,1},
patternName2,
patternCS2);
pcs.addRect(455, 505, 100, 100);
pcs.setNonStrokingColor(patternColor2blue);
pcs.addRect(455, 505, 100, 100);
pcs.fill();
}
doc.save("patterns.pdf");
doc.save("c:/users/tilman/downloads/patterns.pdf");
}
}
}

0 comments on commit 54b327b

Please sign in to comment.