Shading Pattern : Pattern « PDF RTF « Java






Shading Pattern

Shading Pattern
import java.awt.Color;
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfShading;
import com.lowagie.text.pdf.PdfShadingPattern;
import com.lowagie.text.pdf.PdfWriter;

public class ShadingPatternPDF {
  public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ShadingPatternPDF.pdf"));
      document.open();

      PdfShading shading = PdfShading.simpleAxial(writer, 100, 100, 400, 100, Color.red, Color.cyan);
      PdfShadingPattern shadingPattern = new PdfShadingPattern(shading);
      
      PdfContentByte cb = writer.getDirectContent();
      
      cb.setShadingFill(shadingPattern);
      cb.circle(50,50,50);
      cb.stroke();      

      PdfShading shadingR = PdfShading.simpleRadial(writer, 200, 500, 50, 300, 500, 100, new Color(
          255, 247, 148), new Color(247, 138, 107), false, false);
      cb.paintShading(shadingR);

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








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 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