I have a simple working 3.0.0.RC1 example code as below:
try (var document = new PDDocument();) {
var page = new PDPage();
document.addPage(page);
try (var contentStream = new PDPageContentStream(document, page);) {
contentStream.beginText();
contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12);
contentStream.newLineAtOffset(100, 700);
contentStream.showText("Hello World");
contentStream.endText();
}
document.save(path.toFile());
When i change the version from 3.0.0.RC1 to 3.0.0 current code below is not working:
contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12);
I tried below code, but it gives error: "PDFont is abtract; cannot be instantiated:"
contentStream.setFont(new PDFont(Standard14Fonts.FontName.HELVETICA_BOLD), 12);
According to answer How do I solve this pdfbox?
I tried this code, and it compiles.
contentStream.setFont(new PDType1Font(Standard14Fonts.FontName.HELVETICA_BOLD), 12);