Text Pattern Color : Pattern « PDF RTF « Java






Text Pattern Color

Text Pattern Color
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 TextPatternColorPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(
          "TextPatternColorPDF.pdf"));
      document.open();
      PdfContentByte cb = writer.getDirectContent();

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

      document.add(new Paragraph("asdfasdf", FontFactory.getFont(FontFactory.HELVETICA, 60,
          Font.BOLD, new PatternColor(p))));

    } catch (Exception e) {
      e.printStackTrace();
    }
    document.close();
  }
}

           
       








itext.zip( 1,748 k)

Related examples in the same category

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