for (String line: lines) contentStream.showText(line); contentStream.newLineAtOffset(0, -leading);
contentStream.showText(message); "/org/apache/pdfbox/resources/ttf/LiberationSans-Regular.ttf"), WinAnsiEncoding.INSTANCE); contentStream.setFont(font, FONT_SIZE); contentStream.showText(message); contentStream.setFont(font, FONT_SIZE); contentStream.setWordSpacing(wordSpacing); contentStream.showText(message); contentStream.setFont(font, FONT_SIZE); contentStream.setWordSpacing(wordSpacing); contentStream.showText(message);
/** * This will draw a string at the current location on the screen. * * @param text The text to draw. * @throws IOException If an io exception occurs. * @deprecated Use {@link #showText} instead. */ @Deprecated public void drawString(String text) throws IOException { showText(text); }
contents.setFont(font, 12); contents.newLineAtOffset(100, 700); contents.showText(message); contents.endText();
contents.setFont(font, 12); contents.newLineAtOffset(100, 700); contents.showText(message); contents.endText();
contents.setFont(font, 12); contents.newLineAtOffset(100, 700); contents.showText(message); contents.endText();
contentStream.setLeading(25); contentStream.newLineAtOffset(20, 300); contentStream.showText("Key:"); contentStream.newLine(); contentStream.showText("① Horizontal"); contentStream.newLine(); contentStream.showText("② Vertical with substitution"); contentStream.newLine(); contentStream.showText("③ Vertical without substitution"); contentStream.endText(); contentStream.setFont(hfont, 20); contentStream.newLineAtOffset(20, 650); contentStream.showText("①「あーだこーだ」"); contentStream.endText(); contentStream.setFont(vfont, 20); contentStream.newLineAtOffset(50, 600); contentStream.showText("②「あーだこーだ」"); contentStream.endText(); contentStream.setFont(vfont2, 20); contentStream.newLineAtOffset(100, 600); contentStream.showText("③「あーだこーだ」"); contentStream.endText();
contentStream.showText(nextLineToDraw.toString()); if (ff)
contents.showText(line); contents.newLineAtOffset(0, -(FONT_SIZE + LINE_GAP));
contents.setFont(font, 12); contents.newLineAtOffset(100, 700); contents.showText(message); contents.endText();
contentStream.setFont( font, 12 ); contentStream.newLineAtOffset(100, 700); contentStream.showText("Go to Document->File Attachments to View Embedded Files"); contentStream.endText();
contentStream.showText(message + " " + i); contentStream.showText(message + " " + i); contentStream.showText(message + " " + i); contentStream.showText(message + " " + i++); contentStream.showText(message + " " + i++); contentStream.showText(message + " " + i++); contentStream.showText(message + " " + i++);
private static void showPageNo(PDDocument document, PDPage page, String pageText) throws IOException { int fontSize = 10; try (PDPageContentStream contents = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.PREPEND, true)) { float pageWidth = page.getMediaBox().getWidth(); float pageHeight = page.getMediaBox().getHeight(); PDFont font = PDType1Font.HELVETICA; contents.setFont(font, fontSize); float textWidth = font.getStringWidth(pageText) / 1000 * fontSize; contents.beginText(); contents.newLineAtOffset(pageWidth / 2 - textWidth / 2, pageHeight - INCH / 2); contents.showText(pageText); contents.endText(); } } }
contents.setFont(PDType1Font.HELVETICA_BOLD, 12); contents.newLineAtOffset(2, PDRectangle.LETTER.getHeight() - 12); contents.showText("Sample text"); contents.endText();
contents.setFont(PDType1Font.HELVETICA, 15); contents.newLineAtOffset(70, PDRectangle.A4.getHeight() - 30 - i * 35); contents.showText(options.get(i)); contents.endText();
contentStream.showText(message); contentStream.endText();