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 ShowTextUsingPdfContentBytePDF {
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("ShowTextUsingPdfContentBytePDF.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false), 24);
cb.beginText();
cb.showTextAligned(Element.ALIGN_CENTER, "Show text using PdfContentByte", 595f, 262f, 0f);
cb.endText();
cb.stroke();
document.close();
}
}
itext.zip( 1,748 k)