Templates Draw : Template « PDF RTF « Java






Templates Draw

Templates Draw
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;

public class TemplatesDrawPDF {
  public static void main(String[] args) {
    Document document = new Document();

    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TemplatesDrawPDF.pdf"));
      document.open();
      
      PdfContentByte cb = writer.getDirectContent();
      PdfTemplate template = cb.createTemplate(500, 200);
      template.moveTo(0, 200);
      template.lineTo(500, 0);
      template.stroke();
      template.circle(250f, 100f, 80f);
      template.stroke();

      cb.addTemplate(template, 0, 0);

      document.newPage();
      cb.addTemplate(template, 2, 0, 0, 2, -200, 400);
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    document.close();
  }

}
           
       








itext.zip( 1,748 k)

Related examples in the same category

1.Creating Image from templateCreating Image from template
2.Template Images Scale HeightTemplate Images Scale Height
3.Templates: TextTemplates: Text