import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
String text = "this is a test";
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
cb.setFontAndSize(bf, 12);
cb.beginText();
for (int i = 0; i < 360; i += 30) {
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, text, 200, 300, i);
}
cb.endText();
document.close();
}
}
|