Create font : Font « PDF « Java Tutorial






import java.io.FileOutputStream;

import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;

public class MainClass {

  public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("HelloWorldRead.pdf");
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("HelloWorldStamper.pdf"));
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    PdfContentByte over;
    int total = reader.getNumberOfPages() + 1;
    for (int i = 1; i < total; i++) {
      over = stamper.getOverContent(i);
      over.beginText();
      over.setFontAndSize(bf, 18);
      over.setTextMatrix(30, 30);
      over.showText("page " + i);
      over.endText();
      over.setRGBColorStroke(0xFF, 0x00, 0x00);
      over.setLineWidth(5f);
      over.ellipse(250, 450, 350, 550);
      over.stroke();
    }
    stamper.close();
  }

}








29.13.Font
29.13.1.Create font
29.13.2.new Font(Font.COURIER, 10, Font.BOLD)
29.13.3.Font.UNDERLINE
29.13.4.Create font from pfm file
29.13.5.Embeded font
29.13.6..afm font
29.13.7.TrueType font
29.13.8..otf font
29.13.9.Font Metrics
29.13.10.Embeded TrueType Font
29.13.11.All kinds of fonts
29.13.12.Get font name
29.13.13.Not Embedded font
29.13.14.Font supporting Unicode
29.13.15.Japanese font
29.13.16.Korea font
29.13.17.Right To Left Example
29.13.18.BaseFont.createFont(BaseFont.HELVETICA,BaseFont.WINANSI, BaseFont.NOT_EMBEDDED)
29.13.19.Use truetype font to draw unicode string
29.13.20.Use DefaultFontMapper