PDF RTF Java

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)