Setting PdfContentByte for PdfPatternPainter : Pattern « PDF RTF « Java






Setting PdfContentByte for PdfPatternPainter

Setting PdfContentByte for PdfPatternPainter
import java.awt.Color;
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PatternColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPatternPainter;
import com.lowagie.text.pdf.PdfWriter;

public class PatternPatternColorPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PatternPatternColorPDF.pdf"));
      document.open();
      PdfContentByte cb = writer.getDirectContent();

      PdfPatternPainter p = cb.createPattern(60f, 60f, 60f, 60f);
      p.setColorFill(Color.red);
      p.circle(2,2,2);
      p.stroke();

      cb.setPatternFill(p);
      cb.setGrayStroke(0.0f);
      cb.rectangle(20, 20, 280, 120);
      cb.fillStroke();
      
    } catch (Exception e) {
      e.printStackTrace();
    }
    document.close();
  }
}

           
       








itext.zip( 1,748 k)

Related examples in the same category

1.Text Pattern ColorText Pattern Color
2.Text Pattern ShapeText Pattern Shape
3.Shading PatternShading Pattern
4.Shading Pattern TextShading Pattern Text
5.PdfPatternPainter DemoPdfPatternPainter Demo
6.Set Pattern colorSet Pattern color
7.PdfSpotColor for PatternPdfSpotColor for Pattern
8.Pattern by PdfContentBytePattern by PdfContentByte
9.Image Pattern: ShapeImage Pattern: Shape