Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>I have not seriously worked with such an ancient iText version and, therefore, can only point to more current code. A quick look at the svn annotate results seems to indicate, though, that most of the central functionality has been present in iText for a long time. Thus, this code should at least show you how to get started.</em></p> <p>PDF knows the concept of a tiling pattern, confer section 8.7.3 <em>Tiling Patterns</em> of <a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf" rel="nofollow">ISO 32000-1</a>, which should be what you need to create the proper background. iText supports such tiling patterns as demonstrated in the example <a href="http://itextpdf.com/examples/iia.php?id=179" rel="nofollow">TilingPatternColor.java</a> using a helper method from <a href="http://itextpdf.com/examples/iia.php?id=177" rel="nofollow">DeviceColor.java</a>. An excerpt:</p> <pre><code>PdfContentByte canvas = writer.getDirectContent(); PdfPatternPainter square = canvas.createPattern(15, 15); square.setColorFill(new BaseColor(0xFF, 0xFF, 0x00)); square.setColorStroke(new BaseColor(0xFF, 0x00, 0x00)); square.rectangle(5, 5, 5, 5); square.fillStroke(); </code></pre> <p>Having defined a <code>PdfPatternPainter</code> like this, you can generate a color instance from it as <code>new PatternColor(square)</code> and use this color.</p> <p>The samples uses it like this:</p> <pre><code>canvas.saveState(); canvas.setColorFill(new PatternColor(square)); canvas.rectangle(36, 696, 126, 126); canvas.fillStroke(); canvas.restoreState(); </code></pre> <p>You of course have to design your <code>PdfPatternPainter</code> differently. As it essentially is a <code>PdfTemplate</code>, though, you have all the means required to create any tiling pattern you want.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload