Drawing Lines using PdfContentByte : Line « PDF RTF « Java






Drawing Lines using PdfContentByte

Drawing Lines using PdfContentByte
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Image;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

public class DrawLineUsingPdfContentBytePDF {

  public static void main(String[] args) throws Exception{
      Rectangle pageSize = new Rectangle(780, 525);
      Document document = new Document(pageSize);

      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DrawLineUsingPdfContentBytePDF.pdf"));
      document.open();

      PdfContentByte cb = writer.getDirectContent();
      cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false), 24);
      cb.moveTo(370, 0);
      cb.lineTo(370, 525);
      cb.moveTo(410, 525);
      cb.lineTo(410, 0);
      cb.stroke();

      document.close();
  }
}

           
       








itext.zip( 1,748 k)

Related examples in the same category

1.Shape: DashLineShape: DashLine
2.Shape: LineShape: Line
3.Draw Line CapDraw Line Cap