List of usage examples for org.apache.pdfbox.pdmodel.common PDRectangle A4
PDRectangle A4
To view the source code for org.apache.pdfbox.pdmodel.common PDRectangle A4.
Click Source Link
From source file:at.gv.egiz.pdfas.lib.impl.signing.pdfbox2.PADESPDFBOXSigner.java
License:EUPL
@Override public Image generateVisibleSignaturePreview(SignParameter parameter, java.security.cert.X509Certificate cert, int resolution, OperationStatus status, RequestedSignature requestedSignature) throws PDFASError { try {/*from w w w . ja v a 2s .co m*/ PDFBOXObject pdfObject = (PDFBOXObject) status.getPdfObject(); PDDocument origDoc = new PDDocument(); origDoc.addPage(new PDPage(PDRectangle.A4)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); origDoc.save(baos); baos.close(); pdfObject.setOriginalDocument(new ByteArrayDataSource(baos.toByteArray())); SignatureProfileSettings signatureProfileSettings = TableFactory .createProfile(requestedSignature.getSignatureProfileID(), pdfObject.getStatus().getSettings()); // create Table describtion Table main = TableFactory.createSigTable(signatureProfileSettings, MAIN, pdfObject.getStatus(), requestedSignature); IPDFStamper stamper = StamperFactory.createDefaultStamper(pdfObject.getStatus().getSettings()); IPDFVisualObject visualObject = stamper.createVisualPDFObject(pdfObject, main); SignatureProfileConfiguration signatureProfileConfiguration = pdfObject.getStatus() .getSignatureProfileConfiguration(requestedSignature.getSignatureProfileID()); String signaturePosString = signatureProfileConfiguration.getDefaultPositioning(); PositioningInstruction positioningInstruction = null; if (signaturePosString != null) { positioningInstruction = Positioning.determineTablePositioning(new TablePos(signaturePosString), "", origDoc, visualObject, pdfObject.getStatus().getSettings()); } else { positioningInstruction = Positioning.determineTablePositioning(new TablePos(), "", origDoc, visualObject, pdfObject.getStatus().getSettings()); } origDoc.close(); SignaturePositionImpl position = new SignaturePositionImpl(); position.setX(positioningInstruction.getX()); position.setY(positioningInstruction.getY()); position.setPage(positioningInstruction.getPage()); position.setHeight(visualObject.getHeight()); position.setWidth(visualObject.getWidth()); requestedSignature.setSignaturePosition(position); PDFAsVisualSignatureProperties properties = new PDFAsVisualSignatureProperties( pdfObject.getStatus().getSettings(), pdfObject, (PdfBoxVisualObject) visualObject, positioningInstruction, signatureProfileSettings); properties.buildSignature(); PDDocument visualDoc; synchronized (PDDocument.class) { visualDoc = PDDocument.load(properties.getVisibleSignature()); } // PDPageable pageable = new PDPageable(visualDoc); PDPage firstPage = visualDoc.getDocumentCatalog().getPages().get(0); float stdRes = 72; float targetRes = resolution; float factor = targetRes / stdRes; int targetPageNumber = 0;//TODO: is this always the case PDFRenderer pdfRenderer = new PDFRenderer(visualDoc); BufferedImage outputImage = pdfRenderer.renderImageWithDPI(targetPageNumber, targetRes, ImageType.ARGB); //BufferedImage outputImage = firstPage.convertToImage(BufferedImage.TYPE_4BYTE_ABGR, (int) targetRes); BufferedImage cutOut = new BufferedImage((int) (position.getWidth() * factor), (int) (position.getHeight() * factor), BufferedImage.TYPE_4BYTE_ABGR); Graphics2D graphics = (Graphics2D) cutOut.getGraphics(); graphics.drawImage(outputImage, 0, 0, cutOut.getWidth(), cutOut.getHeight(), (int) (1 * factor), (int) (outputImage.getHeight() - ((position.getHeight() + 1) * factor)), (int) ((1 + position.getWidth()) * factor), (int) (outputImage.getHeight() - ((position.getHeight() + 1) * factor) + (position.getHeight() * factor)), null); return cutOut; } catch (PdfAsException e) { logger.warn("PDF-AS Exception", e); throw ErrorExtractor.searchPdfAsError(e, status); } catch (Throwable e) { logger.warn("Unexpected Throwable Exception", e); throw ErrorExtractor.searchPdfAsError(e, status); } }
From source file:br.com.techne.gluonsoft.pdfgenerator.PDFGenerator.java
License:Apache License
/** * Add a new page to the PDF document/*from w ww.j av a 2s. com*/ * @param title * @param strLineContent Text to be added to the page * @throws IOException */ public void addNewPage(String pageTitle, String[] strLineContent) throws IOException { PDPage page = new PDPage(PDRectangle.A4); this.addNewPage(page); PDRectangle rect = new PDRectangle(); rect = page.getMediaBox(); final float PAGE_MAX_WIDTH = rect.getWidth() - (2 * PAGE_MARGIN); final float PAGE_MAX_HEIGHT = rect.getHeight(); final float PAGE_X_ALIGN_CENTER = PAGE_MAX_WIDTH / 2; // (PAGE_MAX_WIDTH + (2 * PAGE_MARGIN)) / 2 ; PDPageContentStream pageContent = new PDPageContentStream(this.getPdfDocument(), page); // Page's Stream int line = 1; // Add the page's title if (pageTitle != null) { pageContent.beginText(); pageContent.setFont(FONT_BOLD, FONT_SIZE_DEFAULT); pageContent.newLineAtOffset(PAGE_X_ALIGN_CENTER, PAGE_INITIAL_Y_POSITION); // CENTER pageContent.showText(pageTitle); // Title pageContent.endText(); pageContent.beginText(); pageContent.setFont(FONT_BOLD, FONT_SIZE_DEFAULT); pageContent.newLineAtOffset(PAGE_MARGIN, PAGE_INITIAL_Y_POSITION - 10 * (line++)); // pageContent.newLineAtOffset(PAGE_MARGIN, PAGE_INITIAL_Y_POSITION); pageContent.showText(""); // Line after title pageContent.endText(); } // Add the page's content if (strLineContent != null && strLineContent.length > 0) { for (String strLine : strLineContent) { ArrayList<String> newLines = autoBreakLineIntoOthers(strLine, _MAX_LINE_CHARACTERS); // Break a text line into others lines to fit into page width. for (String str : newLines) { pageContent.beginText(); pageContent.setFont(FONT_PLAIN, FONT_SIZE_DEFAULT); pageContent.newLineAtOffset(PAGE_MARGIN, PAGE_INITIAL_Y_POSITION - 10 * (line++)); pageContent.showText(str); pageContent.endText(); } } } pageContent.close(); }
From source file:br.com.techne.gluonsoft.pdfgenerator.PDFGenerator.java
License:Apache License
/** * Create a page with table.//from w w w . j a va2s .co m * @param tableTitle Table Title * @param tableColumnsName Array of Strings with table columns titles. * @param strTableContent Array of Strings with the table data. * @throws IOException */ @SuppressWarnings("deprecation") public void addNewTable(String tableTitle, ArrayList<String> tableColumnsName, ArrayList<String> strTableContent) throws IOException { PDRectangle rectLandscapeOrientation = new PDRectangle(PDRectangle.A4.getHeight(), PDRectangle.A4.getWidth()); // Changed width to height to get Landscape Orientation PDPage tablePage = new PDPage(PDRectangle.A4); PDRectangle rect = tablePage.getMediaBox(); this.getPdfDocument().addPage(tablePage); PDPageContentStream pageContent = new PDPageContentStream(this.getPdfDocument(), tablePage); final float margin = 20f; final int tableRows = strTableContent != null ? strTableContent.size() : 0; final int tableColumns = tableColumnsName != null ? tableColumnsName.size() : 0; final float rowHeigth = 20f; final float tableWidth = rect.getWidth() - (2 * margin); final float tableHeight = rowHeigth * tableRows; final float tableColWidth = tableWidth / (float) tableColumns; final float tableCelMargin = 5f; // Draw the lines float nextY = PAGE_INITIAL_Y_POSITION; for (int r = 0; r <= tableRows; r++) { pageContent.drawLine(margin, nextY, margin + tableWidth, nextY); nextY -= rowHeigth; } // Draw the columns float nextX = margin; for (int i = 0; i <= tableColumns; i++) { pageContent.drawLine(nextX, PAGE_INITIAL_Y_POSITION, nextX, PAGE_INITIAL_Y_POSITION - tableHeight); nextX += tableColWidth; } pageContent.setFont(FONT_BOLD, FONT_SIZE_DEFAULT); // Initial Font for the columns' titles float textPosX = margin + tableCelMargin; float textPosY = PAGE_INITIAL_Y_POSITION - 15; // Title float centerX = tableWidth / 2 - (margin * 2); float xAlignLeft = margin; pageContent.beginText(); pageContent.newLineAtOffset(xAlignLeft, PAGE_INITIAL_Y_POSITION + 5); pageContent.showText(tableTitle); pageContent.endText(); // Columns' names for (int i = 0; i < tableColumnsName.size(); i++) { String columnName = tableColumnsName.get(i); System.out.println(columnName); pageContent.beginText(); pageContent.newLineAtOffset(textPosX, textPosY); pageContent.showText(columnName); pageContent.endText(); textPosX += tableColWidth; } // textPosY -= rowHeigth; // textPosX = margin + tableCelMargin; // Cels' content (Add the text) int actualCol = 0; pageContent.setFont(FONT_PLAIN, FONT_SIZE_DEFAULT); for (int i = 0; i < strTableContent.size(); i++) { if (actualCol % tableColumns == 0) { actualCol = 0; textPosY -= rowHeigth; textPosX = margin + tableCelMargin; } String celText = strTableContent.get(i); System.out.println(celText); pageContent.beginText(); pageContent.newLineAtOffset(textPosX, textPosY); pageContent.showText(celText); pageContent.endText(); textPosX += tableColWidth; actualCol++; } pageContent.close(); }
From source file:br.com.techne.gluonsoft.pdfgenerator.PDFGenerator.java
License:Apache License
/** * Create a page with table./*from ww w .j a v a 2 s . c o m*/ * @param tableTitle Table Title * @param strTableContent Array of Strings, where the column's titles goes into the first array line and the data goes into others lines. * @throws IOException */ @SuppressWarnings("deprecation") public void addNewTable(String tableTitle, String[][] strTableContent) throws IOException { PDPage tablePage = new PDPage(PDRectangle.A4); PDRectangle rect = new PDRectangle(); rect = tablePage.getMediaBox(); this.getPdfDocument().addPage(tablePage); PDPageContentStream pageContent = new PDPageContentStream(this.getPdfDocument(), tablePage); final float margin = 20f; final int tableRows = strTableContent.length; final int tableColumns = strTableContent[0].length; final float rowHeigth = 20f; final float tableWidth = rect.getWidth() - (2 * margin); final float tableHeight = rowHeigth * tableRows; final float tableColWidth = tableWidth / (float) tableColumns; final float tableCelMargin = 5f; // Draw the lines float nextY = PAGE_INITIAL_Y_POSITION; for (int r = 0; r <= tableRows; r++) { pageContent.drawLine(margin, nextY, margin + tableWidth, nextY); nextY -= rowHeigth; } // Draw the columns float nextX = margin; for (int i = 0; i <= tableColumns; i++) { pageContent.drawLine(nextX, PAGE_INITIAL_Y_POSITION, nextX, PAGE_INITIAL_Y_POSITION - tableHeight); nextX += tableColWidth; } pageContent.setFont(FONT_BOLD, FONT_SIZE_DEFAULT); // Fonte inicial para o ttulo das colunas float textPosX = margin + tableCelMargin; float textPosY = PAGE_INITIAL_Y_POSITION - 15; // Title float centerX = tableWidth / 2 - (margin * 2); pageContent.beginText(); pageContent.newLineAtOffset(centerX, PAGE_INITIAL_Y_POSITION + 5); pageContent.showText(tableTitle); pageContent.endText(); // Cels' content (Add the text) for (int l = 0; l < strTableContent.length; l++) { for (int c = 0; c < strTableContent[l].length; c++) { String celText = strTableContent[l][c]; if (l > 0) { pageContent.setFont(FONT_PLAIN, FONT_SIZE_DEFAULT); } pageContent.beginText(); pageContent.newLineAtOffset(textPosX, textPosY); pageContent.showText(celText); pageContent.endText(); textPosX += tableColWidth; } textPosY -= rowHeigth; textPosX = margin + tableCelMargin; } pageContent.close(); }
From source file:Bulletin.myPdf.java
public void newPage() { System.out.println("new page"); this.page = new PDPage(PDRectangle.A4); this.rect = page.getMediaBox(); this.left = leftMargin; this.right = rect.getWidth() - leftMargin; this.width = right - left; this.height = rect.getHeight(); this.Y = rect.getHeight() - topMargin; this.top = this.Y; try {//from www. j a v a2 s .c o m this.cos = new PDPageContentStream(this.document, this.page); } catch (IOException ex) { Logger.getLogger(myPdf.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Bulletin.test.java
public static void test2() { try {//ww w. j a va 2 s .c o m PDDocument document = new PDDocument(); PDPage page = new PDPage(PDRectangle.A4); PDPageContentStream cos = null; try { cos = new PDPageContentStream(document, page); } catch (IOException ex) { Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex); } float X = 501.4f; float Y = 556.0f; // String text = "HALLO"; // String text = "HALLO#HOE#GAAT#HET"; // String text = "HALLO#HOE#GAAT"; String text = "Non atteints"; int rh = 10; cos.moveTo(X, Y - 50); cos.lineTo(X, Y + 50); cos.stroke(); cos.moveTo(X - 50, Y); cos.lineTo(X + 50, Y); cos.stroke(); cos.beginText(); cos.setFont(PDType1Font.HELVETICA, 6); float dtw = 0.5f * getTextWidth(PDType1Font.HELVETICA, text, 6); float dth = 0.0f * getFontHeight(PDType1Font.HELVETICA, 6); int nbLines = text.split("#").length; Y += 0.5f * (nbLines - 1) * rh; for (String line : text.split("#")) { Matrix M = Matrix.getTranslateInstance(X, Y); M.concatenate(Matrix.getRotateInstance(Math.toRadians(0), 0, 0)); M.concatenate(Matrix.getTranslateInstance(-dtw, -dth)); cos.setTextMatrix(M); cos.showText(line); Y -= rh; } cos.close(); document.addPage(page); document.save("/tmp/test.pdf"); document.close(); } catch (IOException ex) { Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ch.dowa.jassturnier.pdf.PlaceMappingPdf.java
public static void exportPlaceMapping(TurnierController.PlaceMappingType placeMapping, int gangNr, String turnierTitel) throws IOException { PdfGenerator gen = new PdfGenerator(PDRectangle.A4); String outputFileName;/* w w w.j a va 2 s. co m*/ outputFileName = turnierTitel.replace(' ', '_') + "_Platzzuweisung_Gang_" + String.valueOf(gangNr) + ".pdf"; String titel = turnierTitel + " - Platzzuweisung Gang " + String.valueOf(gangNr); final Table.TableBuilder tableBuilder = Table.builder().addColumnsOfWidth((float) (gen.tabelWidth() * 0.6), (float) (gen.tabelWidth() * 0.2), (float) (gen.tabelWidth() * 0.2)).fontSize(10).font(STANDART_FONT) .borderColor(Color.WHITE); final Row headerRow = Row.builder() .add(CellText.builder().text("Spieler").horizontalAlignment(LEFT).borderWidth(1).build()) .add(CellText.builder().text("Tisch").horizontalAlignment(LEFT).borderWidth(1).build()) .add(CellText.builder().text("Platz").horizontalAlignment(LEFT).borderWidth(1).build()) .backgroundColor(BACKGROUND_HEADER).textColor(Color.WHITE).font(STANDART_FONT_BOLD).fontSize(12) .build(); tableBuilder.addRow(headerRow); ArrayList<String> names = placeMapping.getNames(); ArrayList<String> tables = placeMapping.getTables(); ArrayList<String> seats = placeMapping.getSeats(); for (int i = 0; i < placeMapping.getNames().size(); i++) { tableBuilder.addRow(Row.builder() .add(CellText.builder().font(STANDART_FONT).text(names.get(i)).horizontalAlignment(LEFT) .borderWidth(1).build()) .add(CellText.builder().font(STANDART_FONT_BOLD).text(tables.get(i)).horizontalAlignment(RIGHT) .borderWidth(1).build()) .add(CellText.builder().font(STANDART_FONT_BOLD).text(seats.get(i)).horizontalAlignment(RIGHT) .borderWidth(1).build()) .backgroundColor(i % 2 == 0 ? BACKGROUND_ROW_EVEN : BACKGROUND_ROW_ODD).build()); } gen.exportTemplateWithTable(tableBuilder, outputFileName, titel); }
From source file:ch.dowa.jassturnier.pdf.PlayerListPdf.java
public static void exportPlayerList(ArrayList<String> playerNames, String turnierTitel) throws IOException { PdfGenerator gen = new PdfGenerator(PDRectangle.A4); String outputFileName;//from ww w . j av a 2s . c o m outputFileName = turnierTitel.replace(' ', '_') + "_Spielerliste.pdf"; String titel = turnierTitel + " - Spielerliste"; final Table.TableBuilder tableBuilder = Table.builder().addColumnsOfWidth((float) (gen.tabelWidth() * 0.6), (float) (gen.tabelWidth() * 0.2), (float) (gen.tabelWidth() * 0.2)).fontSize(10).font(STANDART_FONT) .borderColor(Color.WHITE); final Row headerRow = Row.builder() .add(CellText.builder().text("Spieler").horizontalAlignment(LEFT).borderWidth(1).build()) .add(CellText.builder().text("anwesend").horizontalAlignment(LEFT).borderWidth(1).build()) .add(CellText.builder().text("bezahlt").horizontalAlignment(LEFT).borderWidth(1).build()) .backgroundColor(BACKGROUND_HEADER).textColor(Color.WHITE).font(STANDART_FONT_BOLD).fontSize(12) .build(); tableBuilder.addRow(headerRow); int i = 0; for (String playerName : playerNames) { tableBuilder.addRow(Row.builder() .add(CellText.builder().text(playerName).horizontalAlignment(LEFT).borderWidth(1).build()) .add(CellText.builder().text("").horizontalAlignment(LEFT).borderWidth(1).build()) .add(CellText.builder().text("").horizontalAlignment(LEFT).borderWidth(1).build()) .backgroundColor(i % 2 == 0 ? BACKGROUND_ROW_EVEN : BACKGROUND_ROW_ODD).build()); i++; } gen.exportTemplateWithTable(tableBuilder, outputFileName, titel); }
From source file:ch.dowa.jassturnier.pdf.RankingPdf.java
public static void exportRanking(HashMap<Integer, String> names, HashMap<Integer, ArrayList<Long>> points, int gangNr, String turnierTitel, boolean schlussrangliste) throws IOException { PdfGenerator gen = new PdfGenerator(PDRectangle.A4); LinkedHashMap<Integer, ArrayList<Long>> sortedPoints; sortedPoints = points.entrySet().stream() .sorted((Map.Entry<Integer, ArrayList<Long>> e1, Map.Entry<Integer, ArrayList<Long>> e2) -> { ArrayList<Long> pointList1 = e1.getValue(); ArrayList<Long> pointList2 = e2.getValue(); Long points1 = pointList1.get(pointList1.size() - 1); Long points2 = pointList2.get(pointList2.size() - 1); return points2.compareTo(points1); }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> { return oldValue; }, LinkedHashMap::new)); sortedPoints.keySet().forEach(id -> System.out.println(names.get(id) + points.get(id).toString())); String outputFileName;//from w w w . j av a 2 s. c o m outputFileName = turnierTitel.replace(' ', '_') + "_" + (schlussrangliste ? "Schlussrangliste" : "Zwischenrangliste_Gang_" + String.valueOf(gangNr)) + ".pdf"; String titel = turnierTitel + " - " + (schlussrangliste ? "Schlussrangliste" : "Zwischenrangliste Gang " + String.valueOf(gangNr)); Table.TableBuilder tableBuilder = Table.builder(); tableBuilder = tableBuilder.addColumnOfWidth((float) (gen.tabelWidth() * 0.1)); tableBuilder = tableBuilder.addColumnOfWidth((float) (gen.tabelWidth() * (1 - (0.12 * (gangNr + 1))))); for (int i = 1; i <= gangNr; i++) { tableBuilder = tableBuilder.addColumnOfWidth((float) (gen.tabelWidth() * 0.12)); } tableBuilder.fontSize(10).font(STANDART_FONT).borderColor(Color.WHITE); int rang = 1; Long lastPoints = 0L; int nofEqualPoints = 0; Row.RowBuilder headerRowBuilder = Row.builder() .add(CellText.builder().text("Rang").horizontalAlignment(LEFT).borderWidth(1).build()) .add(CellText.builder().text("Spieler").horizontalAlignment(LEFT).borderWidth(1).build()); for (int i = 1; i <= gangNr; i++) { headerRowBuilder = headerRowBuilder.add(CellText.builder().text(String.valueOf(i) + ". Gang") .horizontalAlignment(LEFT).borderWidth(1).build()); } final Row headerRow = headerRowBuilder.backgroundColor(BACKGROUND_HEADER).textColor(Color.WHITE) .font(STANDART_FONT_BOLD).fontSize(12).build(); tableBuilder.addRow(headerRow); int j = 0; for (Integer index : sortedPoints.keySet()) { ArrayList<Long> pointList = sortedPoints.get(index); Long actPoints = pointList.get(pointList.size() - 1); rang = Objects.equals(actPoints, lastPoints) ? rang : rang + nofEqualPoints; nofEqualPoints = Objects.equals(actPoints, lastPoints) ? nofEqualPoints + 1 : 1; lastPoints = actPoints; String playerName = names.get(index); Row.RowBuilder rowBuilder = Row.builder(); rowBuilder = rowBuilder .add(CellText.builder().font(STANDART_FONT_BOLD).text(String.valueOf(rang)) .horizontalAlignment(LEFT).borderWidth(1).build()) .add(CellText.builder().font(STANDART_FONT).text(playerName).horizontalAlignment(LEFT) .borderWidth(1).build()); for (int i = 0; i < pointList.size(); i++) { if (i == pointList.size() - 1) { rowBuilder = rowBuilder .add(CellText.builder().font(STANDART_FONT_BOLD).text(String.valueOf(pointList.get(i))) .horizontalAlignment(RIGHT).borderWidth(1).build()); } else { rowBuilder = rowBuilder .add(CellText.builder().font(STANDART_FONT).text(String.valueOf(pointList.get(i))) .horizontalAlignment(RIGHT).borderWidth(1).build()); } } Row row = rowBuilder.backgroundColor(j % 2 == 0 ? BACKGROUND_ROW_EVEN : BACKGROUND_ROW_ODD).build(); tableBuilder.addRow(row); j++; } gen.exportTemplateWithTable(tableBuilder, outputFileName, titel); }
From source file:de.rototor.pdfbox.graphics2d.PdfBoxGraphics2DTestBase.java
License:Apache License
@SuppressWarnings("SpellCheckingInspection") void exportGraphic(String dir, String name, GraphicsExporter exporter) { try {/*from ww w. j a v a2s.c o m*/ PDDocument document = new PDDocument(); PDFont pdArial = PDFontFactory.createDefaultFont(); File parentDir = new File("target/test/" + dir); // noinspection ResultOfMethodCallIgnored parentDir.mkdirs(); BufferedImage image = new BufferedImage(400, 400, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D imageGraphics = image.createGraphics(); exporter.draw(imageGraphics); imageGraphics.dispose(); ImageIO.write(image, "PNG", new File(parentDir, name + ".png")); for (Mode m : Mode.values()) { PDPage page = new PDPage(PDRectangle.A4); document.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(document, page); PdfBoxGraphics2D pdfBoxGraphics2D = new PdfBoxGraphics2D(document, 400, 400); PdfBoxGraphics2DFontTextDrawer fontTextDrawer = null; contentStream.beginText(); contentStream.setStrokingColor(0, 0, 0); contentStream.setNonStrokingColor(0, 0, 0); contentStream.setFont(PDType1Font.HELVETICA_BOLD, 15); contentStream.setTextMatrix(Matrix.getTranslateInstance(10, 800)); contentStream.showText("Mode " + m); contentStream.endText(); switch (m) { case FontTextIfPossible: fontTextDrawer = new PdfBoxGraphics2DFontTextDrawer(); registerFots(fontTextDrawer); break; case DefaultFontText: { fontTextDrawer = new PdfBoxGraphics2DFontTextDrawerDefaultFonts(); registerFots(fontTextDrawer); break; } case ForceFontText: fontTextDrawer = new PdfBoxGraphics2DFontTextForcedDrawer(); registerFots(fontTextDrawer); fontTextDrawer.registerFont("Arial", pdArial); break; case DefaultVectorized: default: break; } if (fontTextDrawer != null) { pdfBoxGraphics2D.setFontTextDrawer(fontTextDrawer); } exporter.draw(pdfBoxGraphics2D); pdfBoxGraphics2D.dispose(); PDFormXObject appearanceStream = pdfBoxGraphics2D.getXFormObject(); Matrix matrix = new Matrix(); matrix.translate(0, 20); contentStream.transform(matrix); contentStream.drawForm(appearanceStream); matrix.scale(1.5f, 1.5f); matrix.translate(0, 100); contentStream.transform(matrix); contentStream.drawForm(appearanceStream); contentStream.close(); } document.save(new File(parentDir, name + ".pdf")); document.close(); } catch (Exception e) { throw new RuntimeException(e); } }