List of usage examples for org.apache.pdfbox.pdmodel PDPageContentStream setNonStrokingColor
@Deprecated public void setNonStrokingColor(float[] components) throws IOException
From source file:com.github.gujou.deerbelling.sonarqube.service.PdfApplicationGenerator.java
License:Open Source License
private static void attribute(PDImageXObject logo, int logoHeight, int logoWidth, String value, String label, PDFont font, int fontSize, PDDocument doc, String index, boolean isPercent, Color color) throws IOException { int dataFontSize = (int) (fontSize * 1.5f); int labelFontSize = fontSize; float logoYCoordinate = page.getMediaBox().getHeight() - positionHeight - logoHeight; float textWidth = (font.getStringWidth(value) / 1000 * dataFontSize) + (font.getStringWidth(label) / 1000 * labelFontSize); float textHeight = font.getFontDescriptor().getFontBoundingBox().getHeight() / 1000 * dataFontSize; float textYCoordinate = page.getMediaBox().getHeight() - positionHeight - (logoHeight / 2) - (textHeight / 2);/*from w w w . ja va 2 s . c om*/ float dataXCoordinate = positionLogoWidth + logoHeight + DEFAULT_SPACE_WIDTH; positionHeight += spaceHeight + ((logoHeight < textHeight) ? textHeight : logoHeight); if (positionHeight >= page.getMediaBox().getHeight()) { if (positionLogoWidth > DEFAULT_ICON_MARGIN_WIDTH) { initNewPage(doc); attribute(logo, logoHeight, logoWidth, value, label, font, labelFontSize, doc, index, isPercent, color); } else { writeToRight(); attribute(logo, logoHeight, logoWidth, value, label, font, labelFontSize, doc, index, isPercent, color); } } else { PDPageContentStream stream = new PDPageContentStream(doc, page, AppendMode.APPEND, false); try { stream.drawImage(logo, positionLogoWidth, logoYCoordinate, logoWidth, logoHeight); stream.beginText(); stream.setFont(font, dataFontSize); stream.setNonStrokingColor(color); stream.newLineAtOffset(dataXCoordinate, textYCoordinate + 6); stream.showText(value); stream.setNonStrokingColor(DEFAULT_TEXT_COLOR); stream.setFont(font, labelFontSize); stream.showText(label); if (index != null) { stream.newLineAtOffset(textWidth, (int) (labelFontSize * 0.3)); stream.setFont(PDType1Font.COURIER_BOLD, (int) (labelFontSize * 0.8)); stream.showText("("); stream.setNonStrokingColor(color); stream.showText(index); if (isPercent) { stream.showText("%"); } stream.setNonStrokingColor(DEFAULT_TEXT_COLOR); stream.showText(")"); } } finally { stream.endText(); stream.close(); } } }
From source file:domain.mediator.PDFGeneration.java
public static float printHeader(PDPageContentStream contentStream, float startPositionX, float startPositionY, Driver driver, Load load, GPSLocation currentLocation) throws IOException { ZoneId zoneId = ZoneId.systemDefault(); LocalDate recordDate = LocalDate.now(); Table headerTable = PDFGeneration.printHeaderTable(zoneId, recordDate, "123456", driver, load, currentLocation);// w w w . ja v a 2s . c o m contentStream.beginText(); contentStream.newLineAtOffset(startPositionX, startPositionY); String headerText = String.format("Logbook for %s %s", driver.getFirstName(), driver.getLastName()); contentStream.setFont(PDType1Font.TIMES_ROMAN, 12); contentStream.setNonStrokingColor(Color.BLACK); contentStream.showText(headerText); contentStream.endText(); startPositionY -= 30; new TableDrawer(contentStream, headerTable, startPositionX, startPositionY).draw(); return headerTable.getHeight() + 50; }
From source file:GUI.Helper.PDFIOHelper.java
private static void drawReportHeaderFooter(PDDocument report, Project proj, boolean headerOnFirstPage) { int pageIdx = headerOnFirstPage ? 0 : 1; int marginOffset = 10; try {/*from w ww .j a va2s . com*/ PDPageContentStream cs; for (int p = pageIdx; p < report.getNumberOfPages(); p++) { cs = new PDPageContentStream(report, report.getPage(p), true, false); cs.setFont(PDType1Font.TIMES_ROMAN, 11); cs.setNonStrokingColor(Color.BLACK); cs.beginText(); String dateString = DateFormat.getDateInstance(DateFormat.MEDIUM) .format(Calendar.getInstance().getTime()); cs.setTextMatrix(new Matrix(1, 0, 0, 1, MARGIN_LEFT_X, MARGIN_TOP_Y + marginOffset)); cs.showText(dateString); String projectString = "WZ ITS Tool Report: " + proj.getName(); cs.setTextMatrix(new Matrix(1, 0, 0, 1, MARGIN_RIGHT_X - (PDType1Font.TIMES_ROMAN.getStringWidth(projectString) / 1000 * 11), MARGIN_TOP_Y + marginOffset)); cs.showText(projectString); String pageNumString = "Page " + String.valueOf(p + 1) + " of " + String.valueOf(report.getNumberOfPages()); cs.setTextMatrix(new Matrix(1, 0, 0, 1, MARGIN_LEFT_X + (MARGIN_RIGHT_X - MARGIN_LEFT_X) / 2.0f - (PDType1Font.TIMES_ROMAN.getStringWidth(pageNumString) / 1000 * 11) / 2.0f, MARGIN_BOTTOM_Y - marginOffset)); cs.showText(pageNumString); cs.setTextMatrix(new Matrix(1, 0, 0, 1, MARGIN_LEFT_X + 20, MARGIN_BOTTOM_Y - marginOffset)); cs.showText("WZ ITS Tool V" + WZITS_FX.VERSION); String analystAgencyStr = (proj.getAnalyst() != null ? proj.getAnalyst() : "") + (proj.getAnalyst() != null && proj.getAgency() != null ? " / " : "") + (proj.getAgency() != null ? proj.getAgency() : ""); cs.setTextMatrix(new Matrix(1, 0, 0, 1, MARGIN_RIGHT_X - (PDType1Font.TIMES_ROMAN.getStringWidth(analystAgencyStr) / 1000 * 11), MARGIN_BOTTOM_Y - marginOffset)); cs.showText(analystAgencyStr); cs.endText(); BufferedImage logoWZITS = ImageIO.read(WZITS_FX.class.getResource("/GUI/Icon/wzits_icon_64.png")); //ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null); //op.filter(logoWZITS, logoWZITS); cs.drawImage(LosslessFactory.createFromImage(report, logoWZITS), MARGIN_LEFT_X, MARGIN_BOTTOM_Y - marginOffset - 3, 16, 16); cs.close(); } } catch (IOException e) { System.out.println("Something went wrong"); } }
From source file:helper.pdfpreprocessing.pdf.TextHighlight.java
License:Apache License
private boolean markupMatch(Color color, PDPageContentStream contentStream, Match markingMatch, int height, boolean withId, PDPage page, String comment, boolean commentOnly) throws IOException { final List<PDRectangle> textBoundingBoxes = getTextBoundingBoxes(markingMatch.positions); if (textBoundingBoxes.size() > 0) { contentStream.setNonStrokingColor(color); for (PDRectangle textBoundingBox : textBoundingBoxes) { if (comment.isEmpty()) { contentStream.addRect(textBoundingBox.getLowerLeftX(), textBoundingBox.getLowerLeftY(), Math .max(Math.abs(textBoundingBox.getUpperRightX() - textBoundingBox.getLowerLeftX()), 10), height);//from w w w . ja va2s. c o m contentStream.fill(); } if (withId) { PDFont font = PDType1Font.HELVETICA; contentStream.beginText(); contentStream.setFont(font, 5); contentStream.newLineAtOffset(textBoundingBox.getUpperRightX(), textBoundingBox.getUpperRightY()); contentStream.showText(markingMatch.str); contentStream.endText(); } if (!comment.isEmpty() && !commentOnly) { PDAnnotationTextMarkup txtMark = new PDAnnotationTextMarkup( PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT); PDRectangle position = new PDRectangle(); position.setLowerLeftX(textBoundingBox.getLowerLeftX()); position.setLowerLeftY(textBoundingBox.getLowerLeftY()); position.setUpperRightX(textBoundingBox.getLowerLeftX() + Math .max(Math.abs(textBoundingBox.getUpperRightX() - textBoundingBox.getLowerLeftX()), 10)); position.setUpperRightY(textBoundingBox.getLowerLeftY() + 10); txtMark.setRectangle(position); float[] quads = new float[8]; quads[0] = position.getLowerLeftX(); // x1 quads[1] = position.getUpperRightY() - 2; // y1 quads[2] = position.getUpperRightX(); // x2 quads[3] = quads[1]; // y2 quads[4] = quads[0]; // x3 quads[5] = position.getLowerLeftY() - 2; // y3 quads[6] = quads[2]; // x4 quads[7] = quads[5]; // y5 txtMark.setQuadPoints(quads); txtMark.setConstantOpacity((float) 0.5); txtMark.setContents("Missing Assumption/s (" + markingMatch.str + "):\n" + comment); float[] colorArray = new float[] { 0, 0, 0 }; colorArray = color.getColorComponents(colorArray); PDColor hColor = new PDColor(colorArray, PDDeviceRGB.INSTANCE); txtMark.setColor(hColor); txtMark.setCreationDate(Calendar.getInstance()); txtMark.setTitlePopup("Assumption Error"); page.getAnnotations().add(txtMark); } else if (!comment.isEmpty() && commentOnly) { for (int i = 0; i < page.getAnnotations().size(); i++) { String extractedComment = page.getAnnotations().get(i).getContents(); if (extractedComment != null) { String commentID = extractedComment.substring(extractedComment.indexOf("(") + 1, extractedComment.indexOf(")")); if (markingMatch.str.equals(commentID) && extractedComment.contains(comment)) { page.getAnnotations().get(i).setContents(extractedComment + "\n" + comment); } } } } } return true; } return false; }
From source file:info.informationsea.venn.graphics.VennDrawPDF.java
License:Open Source License
public static <T> void draw(VennFigure<T> vennFigure, PDDocument doc, PDPage page, PDFont font, PDRectangle rect) throws IOException { PDPageContentStream contents = new PDPageContentStream(doc, page); Rectangle2D drawRect = vennFigure.drawRect(str -> stringBoundingBox(font, str, FONT_SIZE)); PointConverter.JoinedConverter pointConverter = new PointConverter.JoinedConverter(); pointConverter//from www.j av a2 s. c o m .addLast(new PointConverter.Translate(-drawRect.getMinX() + MARGIN, -drawRect.getMinY() + MARGIN)); pointConverter.addLast(new PointConverter.Scale(1, -1)); pointConverter.addLast(new PointConverter.Translate(0, rect.getHeight())); // fill first for (VennFigure.Shape<T> shape : vennFigure.getShapes()) { if (shape instanceof VennFigure.Oval) { VennFigure.Oval<T> oval = (VennFigure.Oval<T>) shape; Color fillColor = VennDrawGraphics2D.decodeColor(oval.getColor()); if (fillColor.getAlpha() == 0) continue; //COSName graphicsStateName = page.getResources().add(graphicsState); List<VennFigure.Point> polygon = oval.toPolygon(); VennFigure.Point converted = pointConverter.convert(polygon.get(0)); contents.moveTo((float) converted.getX(), (float) converted.getY()); polygon.add(polygon.remove(0)); // move to last for (VennFigure.Point p : polygon) { converted = pointConverter.convert(p); contents.lineTo((float) converted.getX(), (float) converted.getY()); } if (fillColor.getAlpha() != 255) { PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState(); graphicsState.setNonStrokingAlphaConstant(fillColor.getAlpha() / 255.f); contents.saveGraphicsState(); contents.setGraphicsStateParameters(graphicsState); } contents.setNonStrokingColor(fillColor); contents.fill(); if (fillColor.getAlpha() != 255) { contents.restoreGraphicsState(); } } } for (VennFigure.Shape<T> shape : vennFigure.getShapes()) { if (shape instanceof VennFigure.Oval) { VennFigure.Oval<T> oval = (VennFigure.Oval<T>) shape; List<VennFigure.Point> polygon = oval.toPolygon(); VennFigure.Point converted = pointConverter.convert(polygon.get(0)); contents.moveTo((float) converted.getX(), (float) converted.getY()); polygon.add(polygon.remove(0)); // move to last for (VennFigure.Point p : polygon) { converted = pointConverter.convert(p); contents.lineTo((float) converted.getX(), (float) converted.getY()); } contents.setNonStrokingColor(Color.BLACK); contents.stroke(); } else if (shape instanceof VennFigure.Text) { VennFigure.Text<T> text = (VennFigure.Text<T>) shape; Rectangle2D boundingBox = stringBoundingBox(font, text.getText(), FONT_SIZE); VennFigure.Point converted = pointConverter.convert(text.getCenter()); float xOffset; switch (text.getJust()) { case CENTER: xOffset = (float) (-boundingBox.getWidth() / 2); break; case RIGHT: xOffset = (float) (-boundingBox.getWidth()); break; default: xOffset = 0; break; } contents.beginText(); contents.setNonStrokingColor(Color.BLACK); contents.setFont(font, FONT_SIZE); contents.newLineAtOffset((float) (converted.getX() + xOffset), (float) (converted.getY() - boundingBox.getHeight() / 2)); contents.showText(text.getText()); contents.endText(); } } contents.saveGraphicsState(); contents.close(); }
From source file:jgnash.report.pdf.Report.java
License:Open Source License
/** * Writes a table section to the report. * * @param reportModel report model//from ww w .j a va 2 s .c om * @param group report group * @param contentStream PDF content stream * @param startRow starting row * @param columnWidths column widths * @param yStart start location from top of the page * @return returns the last reported row of the group and yDoc location * @throws IOException IO exception */ @SuppressWarnings("SuspiciousNameCombination") private Pair<Integer, Float> addTableSection(final AbstractReportTableModel reportModel, @NotNull final String group, final PDPageContentStream contentStream, final int startRow, float[] columnWidths, float yStart) throws IOException { Objects.requireNonNull(group); int rowsWritten = 0; // the return value of the number of rows written // establish start location, use half the row height as the vertical margin between title and table final float yTop = (float) getPageFormat().getHeight() - getTableRowHeight() / 2 - yStart; float xPos = getLeftMargin() + getCellPadding(); float yPos = yTop - getTableRowHeight() + getRowTextBaselineOffset(); contentStream.setFont(getHeaderFont(), getBaseFontSize()); // add the header contentStream.setNonStrokingColor(headerBackground); fillRect(contentStream, getLeftMargin(), yTop - getTableRowHeight(), getAvailableWidth(), getTableRowHeight()); contentStream.setNonStrokingColor(headerTextColor); for (int i = 0; i < reportModel.getColumnCount(); i++) { if (reportModel.isColumnVisible(i)) { float shift = 0; float availWidth = columnWidths[i] - getCellPadding() * 2; final String text = truncateText(reportModel.getColumnName(i), availWidth, getHeaderFont(), getBaseFontSize()); if (rightAlign(i, reportModel)) { shift = availWidth - getStringWidth(text, getHeaderFont(), getBaseFontSize()); } drawText(contentStream, xPos + shift, yPos, text); xPos += columnWidths[i]; } } // add the rows contentStream.setFont(getTableFont(), getBaseFontSize()); contentStream.setNonStrokingColor(Color.BLACK); int row = startRow; final float bottomMargin = getBottomMargin(); while (yPos > bottomMargin + getTableRowHeight() && row < reportModel.getRowCount()) { final String rowGroup = reportModel.getGroup(row); if (group.equals(rowGroup)) { xPos = getLeftMargin() + getCellPadding(); yPos -= getTableRowHeight(); for (int i = 0; i < reportModel.getColumnCount(); i++) { if (reportModel.isColumnVisible(i)) { final Object value = reportModel.getValueAt(row, i); if (value != null) { float shift = 0; float availWidth = columnWidths[i] - getCellPadding() * 2; final String text = truncateText( formatValue(reportModel.getValueAt(row, i), i, reportModel), availWidth, getTableFont(), getBaseFontSize()); if (rightAlign(i, reportModel)) { shift = availWidth - getStringWidth(text, getTableFont(), getBaseFontSize()); } drawText(contentStream, xPos + shift, yPos, text); } xPos += columnWidths[i]; } } rowsWritten++; } row++; } // add row lines yPos = yTop; xPos = getLeftMargin(); for (int r = 0; r <= rowsWritten + 1; r++) { drawLine(contentStream, xPos, yPos, getAvailableWidth() + getLeftMargin(), yPos); yPos -= getTableRowHeight(); } // add column lines yPos = yTop; xPos = getLeftMargin(); for (int i = 0; i < reportModel.getColumnCount(); i++) { if (reportModel.isColumnVisible(i)) { drawLine(contentStream, xPos, yPos, xPos, yPos - getTableRowHeight() * (rowsWritten + 1)); xPos += columnWidths[i]; } } // end of last column drawLine(contentStream, xPos, yPos, xPos, yPos - getTableRowHeight() * (rowsWritten + 1)); float yDoc = (float) getPageFormat().getHeight() - (yPos - getTableRowHeight() * (rowsWritten + 1)); // return the row and docY position return new ImmutablePair<>(row, yDoc); }
From source file:jgnash.report.pdf.Report.java
License:Open Source License
/** * Writes a table footer to the report./*from ww w .java 2s . c om*/ * * @param reportModel report model * @param groupInfo Group info to report on * @param contentStream PDF content stream * @param columnWidths column widths * @param yStart start location from top of the page * @return returns the y position from the top of the page * @throws IOException IO exception */ private float addTableFooter(final AbstractReportTableModel reportModel, final GroupInfo groupInfo, final PDPageContentStream contentStream, float[] columnWidths, float yStart) throws IOException { float yDoc = yStart + getTableRowHeight(); // add the footer background contentStream.setNonStrokingColor(footerBackGround); fillRect(contentStream, getLeftMargin(), docYToPageY(yDoc), getAvailableWidth(), getTableRowHeight()); drawLine(contentStream, getLeftMargin(), docYToPageY(yDoc), getAvailableWidth() + getLeftMargin(), docYToPageY(yDoc)); drawLine(contentStream, getLeftMargin(), docYToPageY(yDoc - getTableRowHeight()), getLeftMargin(), docYToPageY(yDoc)); drawLine(contentStream, getLeftMargin() + getAvailableWidth(), docYToPageY(yDoc - getTableRowHeight()), getLeftMargin() + getAvailableWidth(), docYToPageY(yDoc)); contentStream.setFont(getTableFont(), getBaseFontSize()); contentStream.setNonStrokingColor(Color.BLACK); // draw summation values float xPos = getLeftMargin() + getCellPadding(); //drawText(contentStream, xPos, docYToPageY(yDoc - getRowTextBaselineOffset()), getGroupFooterLabel()); // search for first visible column width for (int c = 0; c < reportModel.getColumnCount(); c++) { if (reportModel.isColumnVisible(c)) { // right align the text final float availWidth = columnWidths[c] - getCellPadding() * 2; final float shift = availWidth - getStringWidth(getGroupFooterLabel(), getTableFont(), getBaseFontSize()); drawText(contentStream, xPos + shift, docYToPageY(yDoc - getRowTextBaselineOffset()), getGroupFooterLabel()); break; } } for (int c = 0; c < reportModel.getColumnCount(); c++) { if (reportModel.isColumnVisible(c) && reportModel.isColumnSummed(c)) { final Object value = groupInfo.getValue(c); if (value != null) { float shift = 0; float availWidth = columnWidths[c] - getCellPadding() * 2; final String text = truncateText(formatValue(groupInfo.getValue(c), c, reportModel), availWidth, getTableFont(), getBaseFontSize()); if (rightAlign(c, reportModel)) { shift = availWidth - getStringWidth(text, getTableFont(), getBaseFontSize()); } drawText(contentStream, xPos + shift, docYToPageY(yDoc - getRowTextBaselineOffset()), text); } } if (c < reportModel.getColumnCount() - 1) { xPos += columnWidths[c]; } } return yDoc; }
From source file:jgnash.report.pdf.Report.java
License:Open Source License
/** * Writes a table footer to the report./*from w w w.j av a 2 s . c o m*/ * * @param reportModel report model * @param contentStream PDF content stream * @param columnWidths column widths * @param yStart start location from top of the page * @throws IOException IO exception */ private void addGlobalFooter(final AbstractReportTableModel reportModel, final PDPageContentStream contentStream, float[] columnWidths, float yStart) throws IOException { float yDoc = yStart + getTableRowHeight(); // add the footer background contentStream.setNonStrokingColor(footerBackGround); fillRect(contentStream, getLeftMargin(), docYToPageY(yDoc), getAvailableWidth(), getTableRowHeight()); drawLine(contentStream, getLeftMargin(), docYToPageY(yDoc), getAvailableWidth() + getLeftMargin(), docYToPageY(yDoc)); drawLine(contentStream, getLeftMargin(), docYToPageY(yDoc - getTableRowHeight()), getLeftMargin(), docYToPageY(yDoc)); drawLine(contentStream, getLeftMargin() + getAvailableWidth(), docYToPageY(yDoc - getTableRowHeight()), getLeftMargin() + getAvailableWidth(), docYToPageY(yDoc)); contentStream.setFont(getTableFont(), getBaseFontSize()); contentStream.setNonStrokingColor(Color.BLACK); // draw summation values float xPos = getLeftMargin() + getCellPadding(); // search for first visible column width for (int c = 0; c < reportModel.getColumnCount(); c++) { if (reportModel.isColumnVisible(c)) { // right align the text final float availWidth = columnWidths[c] - getCellPadding() * 2; final float shift = availWidth - getStringWidth(getGrandTotalLegend(), getTableFont(), getBaseFontSize()); drawText(contentStream, xPos + shift, docYToPageY(yDoc - getRowTextBaselineOffset()), getGrandTotalLegend()); break; } } for (int c = 0; c < reportModel.getColumnCount(); c++) { if (reportModel.isColumnVisible(c) && reportModel.isColumnSummed(c)) { final Object value = reportModel.getGlobalSum(c); if (value != null) { float shift = 0; float availWidth = columnWidths[c] - getCellPadding() * 2; final String text = truncateText(formatValue(reportModel.getGlobalSum(c), c, reportModel), availWidth, getTableFont(), getBaseFontSize()); if (rightAlign(c, reportModel)) { shift = availWidth - getStringWidth(text, getTableFont(), getBaseFontSize()); } drawText(contentStream, xPos + shift, docYToPageY(yDoc - getRowTextBaselineOffset()), text); } } if (c < reportModel.getColumnCount() - 1) { xPos += columnWidths[c]; } } //return yDoc; }
From source file:org.dspace.disseminate.CitationDocumentServiceImpl.java
License:BSD License
protected void generateCoverPage(Context context, PDDocument document, PDPage coverPage, Item item) throws IOException { PDPageContentStream contentStream = new PDPageContentStream(document, coverPage); try {/*from w w w.j a v a 2 s .c o m*/ int ypos = 760; int xpos = 30; int xwidth = 550; int ygap = 20; PDFont fontHelvetica = PDType1Font.HELVETICA; PDFont fontHelveticaBold = PDType1Font.HELVETICA_BOLD; PDFont fontHelveticaOblique = PDType1Font.HELVETICA_OBLIQUE; contentStream.setNonStrokingColor(Color.BLACK); String[][] content = { header1 }; drawTable(coverPage, contentStream, ypos, xpos, content, fontHelveticaBold, 11, false); ypos -= (ygap); String[][] content2 = { header2 }; drawTable(coverPage, contentStream, ypos, xpos, content2, fontHelveticaBold, 11, false); ypos -= ygap; contentStream.fillRect(xpos, ypos, xwidth, 1); contentStream.closeAndStroke(); String[][] content3 = { { getOwningCommunity(context, item), getOwningCollection(item) } }; drawTable(coverPage, contentStream, ypos, xpos, content3, fontHelvetica, 9, false); ypos -= ygap; contentStream.fillRect(xpos, ypos, xwidth, 1); contentStream.closeAndStroke(); ypos -= (ygap * 2); for (String field : fields) { field = field.trim(); PDFont font = fontHelvetica; int fontSize = 11; if (field.contains("title")) { fontSize = 26; ypos -= ygap; } else if (field.contains("creator") || field.contains("contributor")) { fontSize = 16; } if (field.equals("_line_")) { contentStream.fillRect(xpos, ypos, xwidth, 1); contentStream.closeAndStroke(); ypos -= (ygap); } else if (StringUtils.isNotEmpty(itemService.getMetadata(item, field))) { ypos = drawStringWordWrap(coverPage, contentStream, itemService.getMetadata(item, field), xpos, ypos, font, fontSize); } if (field.contains("title")) { ypos -= ygap; } } contentStream.beginText(); contentStream.setFont(fontHelveticaOblique, 11); contentStream.moveTextPositionByAmount(xpos, ypos); contentStream.drawString(footer); contentStream.endText(); } finally { contentStream.close(); } }
From source file:org.gfbio.idmg.util.PDFUtil.java
private void toggleTextColorAndType(PDPageContentStream content, boolean oblique) throws IOException { if (!oblique) { content.setNonStrokingColor(Color.GRAY); content.setFont(PDType1Font.HELVETICA_OBLIQUE, 11); } else {//from www .ja v a 2 s . c om content.setNonStrokingColor(51, 90, 163); content.setFont(boldFont, 11); } }