I pull the latest 2.x version and am just playing around with the API. I saw some examples, and was trying to add some text to each page.
The following code creates a corrupt PDF. Wondering if anyone can help me understand why. def addUser(user: UserData, is: InputStream): Try[PDDocument] = Try { val doc = PDDocument.load(is) if (doc.isEncrypted) { throw new RuntimeException("We can't adjust the PDF if it's encrypted") } val licensee = s"${user.name} (${user.email})" doc.getPages.forEach { page => val contentStream = new PDPageContentStream(doc, page, AppendMode.APPEND, true, true) contentStream.beginText() contentStream.setFont(PDType1Font.HELVETICA_BOLD, 15.0f) contentStream.setNonStrokingColor(Color.red) contentStream.setTextMatrix(Matrix.getTranslateInstance(0, 0)); contentStream.showText(licensee); contentStream.endText(); } doc } Best, Andy