Text Pattern Shape : Pattern « PDF RTF « Java






Text Pattern Shape

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

      BaseFont bf = BaseFont.createFont("Times-Roman", "winansi", false);
      PdfPatternPainter p = cb.createPattern(30f, 30f, 30f, 30f);
      p.setGrayFill(0.3f);
      p.setFontAndSize(bf, 12);
      p.beginText();
      p.setTextMatrix(1f, 0f, 0f, 1f, 0f, 0f);
      p.showText("A B C D");
      p.endText();
      p.moveTo(0f, 0f);
      p.lineTo(30f, 30f);
      p.stroke();

      cb.setPatternFill(p);
      cb.circle(150f, 400f, 150f);
      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.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