List of usage examples for com.lowagie.text.pdf PdfPTable setSpacingAfter
public void setSpacingAfter(float spacing)
From source file:org.gtdfree.addons.PDFExportAddOn.java
License:Open Source License
private Element newSubSection(String s) throws DocumentException, IOException { Phrase c = fontSelectorB.process(s); Paragraph p = new Paragraph(c); PdfPTable t = new PdfPTable(1); t.setSpacingBefore(7f);/*from w ww .j a v a2 s .c o m*/ t.setSpacingAfter(5f); t.setWidthPercentage(100f); PdfPCell ce = newCell(p); ce.setBorder(PdfPCell.BOTTOM); ce.setBorderWidth(0.75f); ce.setPaddingLeft(0); ce.setPaddingRight(0); t.addCell(ce); return t; }
From source file:org.jsondoc.springmvc.pdf.PdfExportView.java
License:Open Source License
public File getPdfFile(String filename) { try {//from w w w . ja v a 2 s . c o m File file = new File(filename + "-v" + jsonDoc.getVersion() + FILE_EXTENSION); FileOutputStream fileout = new FileOutputStream(file); Document document = new Document(); PdfWriter.getInstance(document, fileout); // Header HeaderFooter header = new HeaderFooter(new Phrase("Copyright " + Calendar.getInstance().get(Calendar.YEAR) + " Paybay Networks - All rights reserved"), false); header.setBorder(Rectangle.NO_BORDER); header.setAlignment(Element.ALIGN_LEFT); document.setHeader(header); // Footer HeaderFooter footer = new HeaderFooter(new Phrase("Page "), true); footer.setBorder(Rectangle.NO_BORDER); footer.setAlignment(Element.ALIGN_CENTER); document.setFooter(footer); document.open(); //init documentation apiDocs = buildApiDocList(); apiMethodDocs = buildApiMethodDocList(apiDocs); Phrase baseUrl = new Phrase("Base url: " + jsonDoc.getBasePath()); document.add(baseUrl); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); int pos = 1; for (ApiMethodDoc apiMethodDoc : apiMethodDocs) { Phrase phrase = new Phrase(/*"Description: " + */apiMethodDoc.getDescription()); document.add(phrase); document.add(Chunk.NEWLINE); PdfPTable table = new PdfPTable(2); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.setWidthPercentage(100); table.setWidths(new int[] { 50, 200 }); // HEADER CELL START TABLE table.addCell(ITextUtils.getHeaderCell("URL")); table.addCell(ITextUtils.getHeaderCell("<baseUrl> " + apiMethodDoc.getPath())); table.completeRow(); // FIRST CELL table.addCell(ITextUtils.getCell("Http Method", 0)); table.addCell(ITextUtils.getCell(apiMethodDoc.getVerb().name(), pos)); pos++; table.completeRow(); // PRODUCES if (!apiMethodDoc.getProduces().isEmpty()) { table.addCell(ITextUtils.getCell("Produces", 0)); table.addCell(ITextUtils.getCell(buildApiMethodProduces(apiMethodDoc), pos)); pos++; table.completeRow(); } // CONSUMES if (!apiMethodDoc.getConsumes().isEmpty()) { table.addCell(ITextUtils.getCell("Consumes", 0)); table.addCell(ITextUtils.getCell(buildApiMethodConsumes(apiMethodDoc), pos)); pos++; table.completeRow(); } // HEADERS if (!apiMethodDoc.getHeaders().isEmpty()) { table.addCell(ITextUtils.getCell("Request headers", 0)); PdfPTable pathParamsTable = new PdfPTable(3); pathParamsTable.setWidths(new int[] { 30, 20, 40 }); pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); for (ApiHeaderDoc apiHeaderDoc : apiMethodDoc.getHeaders()) { PdfPCell boldCell = new PdfPCell(); Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD); boldCell.setPhrase(new Phrase(apiHeaderDoc.getName(), fontbold)); boldCell.getPhrase().setFont(new Font(Font.BOLD)); boldCell.setBorder(Rectangle.NO_BORDER); pathParamsTable.addCell(boldCell); PdfPCell paramCell = new PdfPCell(); StringBuilder builder = new StringBuilder(); for (String value : apiHeaderDoc.getAllowedvalues()) builder.append(value).append(", "); paramCell.setPhrase(new Phrase("Allowed values: " + builder.toString())); paramCell.setBorder(Rectangle.NO_BORDER); pathParamsTable.addCell(paramCell); paramCell.setPhrase(new Phrase(apiHeaderDoc.getDescription())); pathParamsTable.addCell(paramCell); pathParamsTable.completeRow(); } PdfPCell bluBorderCell = new PdfPCell(pathParamsTable); bluBorderCell.setBorder(Rectangle.NO_BORDER); bluBorderCell.setBorderWidthRight(1f); bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR); table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos)); pos++; table.completeRow(); } // PATH PARAMS if (!apiMethodDoc.getPathparameters().isEmpty()) { table.addCell(ITextUtils.getCell("Path params", 0)); PdfPTable pathParamsTable = new PdfPTable(3); pathParamsTable.setWidths(new int[] { 30, 15, 40 }); pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); for (ApiParamDoc apiParamDoc : apiMethodDoc.getPathparameters()) { PdfPCell boldCell = new PdfPCell(); Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD); boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold)); boldCell.getPhrase().setFont(new Font(Font.BOLD)); boldCell.setBorder(Rectangle.NO_BORDER); pathParamsTable.addCell(boldCell); PdfPCell paramCell = new PdfPCell(); paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText())); paramCell.setBorder(Rectangle.NO_BORDER); pathParamsTable.addCell(paramCell); paramCell.setPhrase(new Phrase(apiParamDoc.getDescription())); pathParamsTable.addCell(paramCell); pathParamsTable.completeRow(); } PdfPCell bluBorderCell = new PdfPCell(pathParamsTable); bluBorderCell.setBorder(Rectangle.NO_BORDER); bluBorderCell.setBorderWidthRight(1f); bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR); table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos)); pos++; table.completeRow(); } // QUERY PARAMS if (!apiMethodDoc.getQueryparameters().isEmpty()) { table.addCell(ITextUtils.getCell("Query params", 0)); PdfPTable queryParamsTable = new PdfPTable(3); queryParamsTable.setWidths(new int[] { 30, 15, 40 }); queryParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); queryParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); for (ApiParamDoc apiParamDoc : apiMethodDoc.getQueryparameters()) { PdfPCell boldCell = new PdfPCell(); Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD); boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold)); boldCell.getPhrase().setFont(new Font(Font.BOLD)); boldCell.setBorder(Rectangle.NO_BORDER); queryParamsTable.addCell(boldCell); PdfPCell paramCell = new PdfPCell(); paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText())); paramCell.setBorder(Rectangle.NO_BORDER); queryParamsTable.addCell(paramCell); paramCell.setPhrase(new Phrase( apiParamDoc.getDescription() + ", mandatory: " + apiParamDoc.getRequired())); queryParamsTable.addCell(paramCell); queryParamsTable.completeRow(); } PdfPCell bluBorderCell = new PdfPCell(queryParamsTable); bluBorderCell.setBorder(Rectangle.NO_BORDER); bluBorderCell.setBorderWidthRight(1f); bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR); table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos)); pos++; table.completeRow(); } // BODY OBJECT if (null != apiMethodDoc.getBodyobject()) { table.addCell(ITextUtils.getCell("Body object:", 0)); String jsonObject = buildJsonFromTemplate(apiMethodDoc.getBodyobject().getJsondocTemplate()); table.addCell(ITextUtils.getCell(jsonObject, pos)); pos++; table.completeRow(); } // RESPONSE OBJECT table.addCell(ITextUtils.getCell("Json response:", 0)); table.addCell( ITextUtils.getCell(apiMethodDoc.getResponse().getJsondocType().getOneLineText(), pos)); pos++; table.completeRow(); // RESPONSE STATUS CODE table.addCell(ITextUtils.getCell("Status code:", 0)); table.addCell(ITextUtils.getCell(apiMethodDoc.getResponsestatuscode(), pos)); pos++; table.completeRow(); table.setSpacingAfter(10f); table.setSpacingBefore(5f); document.add(table); } document.close(); return file; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } return null; }
From source file:org.mapfish.print.config.layout.AttributesBlock.java
License:Open Source License
public void render(PJsonObject params, PdfElement target, RenderingContext context) throws DocumentException { PJsonObject sourceJson = params.optJSONObject(source); if (sourceJson == null) { sourceJson = context.getGlobalParams().optJSONObject(source); }//www. j a va2 s. co m if (sourceJson == null || sourceJson.size() == 0) { return; } PJsonArray data = sourceJson.optJSONArray("data"); PJsonArray firstLine = sourceJson.getJSONArray("columns"); final List<Integer> columnWidths; if (columnDefs.values().iterator().next().getColumnWeight() > 0) { columnWidths = new ArrayList<Integer>(); } else { columnWidths = null; } //Compute the actual number of columns int nbCols = 0; for (int colNum = 0; colNum < firstLine.size(); ++colNum) { String name = firstLine.getString(colNum); ColumnDef colDef = columnDefs.get(name); if (colDef != null && colDef.isVisible(context, params)) { nbCols++; if (columnWidths != null) { columnWidths.add(colDef.getColumnWeight()); } } else { //noinspection ThrowableInstanceNeverThrown context.addError(new InvalidJsonValueException(firstLine, name, "Unknown column")); } } final PdfPTable table = new PdfPTable(nbCols); table.setWidthPercentage(100f); //deal with the weigths for the column widths, if specified if (columnWidths != null) { int[] array = new int[columnWidths.size()]; for (int i = 0; i < columnWidths.size(); i++) { array[i] = columnWidths.get(i); } table.setWidths(array); } //add the header int nbRows = data.size() + 1; for (int colNum = 0; colNum < firstLine.size(); ++colNum) { String name = firstLine.getString(colNum); ColumnDef colDef = columnDefs.get(name); if (colDef != null && colDef.isVisible(context, params)) { table.addCell(colDef.createHeaderPdfCell(params, context, colNum, nbRows, nbCols, tableConfig)); } } table.setHeaderRows(1); //add the content for (int rowNum = 0; rowNum < data.size(); ++rowNum) { PJsonObject row = data.getJSONObject(rowNum); int realColNum = 0; for (int colNum = 0; colNum < firstLine.size(); ++colNum) { String name = firstLine.getString(colNum); ColumnDef colDef = columnDefs.get(name); if (colDef != null && colDef.isVisible(context, params)) { table.addCell(colDef.createContentPdfCell(row, context, rowNum + 1, realColNum, nbRows, nbCols, tableConfig)); realColNum++; } } } table.setSpacingAfter((float) spacingAfter); target.add(table); }
From source file:org.mapfish.print.config.layout.ColumnsBlock.java
License:Open Source License
public void render(final PJsonObject params, PdfElement target, final RenderingContext context) throws DocumentException { if (isAbsolute()) { context.getCustomBlocks().addAbsoluteDrawer(new PDFCustomBlocks.AbsoluteDrawer() { public void render(PdfContentByte dc) throws DocumentException { final PdfPTable table = PDFUtils.buildTable(items, params, context, nbColumns, config); if (table != null) { table.setTotalWidth(width); table.setLockedWidth(true); if (widths != null) { table.setWidths(widths); }// ww w .ja va2s .co m table.writeSelectedRows(0, -1, absoluteX, absoluteY, dc); } } }); } else { final PdfPTable table = PDFUtils.buildTable(items, params, context, nbColumns, config); if (table != null) { if (widths != null) { table.setWidths(widths); } table.setSpacingAfter((float) spacingAfter); target.add(table); } } }
From source file:org.mapfish.print.config.layout.LegendsBlock.java
License:Open Source License
public void render(PJsonObject params, PdfElement target, RenderingContext context) throws DocumentException { PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100f);//from w w w . j a va 2 s .c o m Font layerPdfFont = getLayerPdfFont(); Font classPdfFont = getClassPdfFont(); PJsonArray legends = context.getGlobalParams().optJSONArray("legends"); if (legends != null && legends.size() > 0) { for (int i = 0; i < legends.size(); ++i) { PJsonObject layer = legends.getJSONObject(i); final PdfPCell cell = createLine(context, 0.0, layer, layerPdfFont, params); if (i > 0) { cell.setPaddingTop((float) layerSpace); } table.addCell(cell); PJsonArray classes = layer.getJSONArray("classes"); for (int j = 0; j < classes.size(); ++j) { PJsonObject clazz = classes.getJSONObject(j); final PdfPCell classCell = createLine(context, classIndentation, clazz, classPdfFont, params); classCell.setPaddingTop((float) classSpace); table.addCell(classCell); } } } table.setSpacingAfter((float) spacingAfter); target.add(table); }
From source file:org.mapfish.print.config.layout.PivotTableBlock.java
License:Open Source License
public void render(final PJsonObject params, PdfElement target, final RenderingContext context) throws DocumentException { if (isAbsolute()) { context.getCustomBlocks().addAbsoluteDrawer(new PDFCustomBlocks.AbsoluteDrawer() { public void render(PdfContentByte dc) throws DocumentException { final PdfPTable table = buildPivotTable(params, context, tableConfig); if (table != null) { table.setTotalWidth(width); table.setLockedWidth(true); if (widths != null) { table.setWidths(widths); }/* ww w . j a v a 2s . c om*/ table.writeSelectedRows(0, -1, absoluteX, absoluteY, dc); } } }); } else { final PdfPTable table = buildPivotTable(params, context, tableConfig); if (table != null) { if (widths != null) { table.setWidths(widths); } table.setSpacingAfter((float) spacingAfter); target.add(table); } } }
From source file:org.mapfish.print.PDFUtils.java
License:Open Source License
/** * When we have to do some custom drawing in a block that is layed out by * iText, we first give an empty table with the good dimensions to iText, * then iText will call a callback with the actual position. When that * happens, we use the given drawer to do the actual drawing. */// w w w.ja v a 2 s. c o m public static PdfPTable createPlaceholderTable(double width, double height, double spacingAfter, ChunkDrawer drawer, HorizontalAlign align, PDFCustomBlocks customBlocks) { PdfPTable placeHolderTable = new PdfPTable(1); placeHolderTable.setLockedWidth(true); placeHolderTable.setTotalWidth((float) width); final PdfPCell placeHolderCell = new PdfPCell(); placeHolderCell.setMinimumHeight((float) height); placeHolderCell.setPadding(0f); placeHolderCell.setBorder(PdfPCell.NO_BORDER); placeHolderTable.addCell(placeHolderCell); customBlocks.addChunkDrawer(drawer); placeHolderTable.setTableEvent(drawer); placeHolderTable.setComplete(true); final PdfPCell surroundingCell = new PdfPCell(placeHolderTable); surroundingCell.setPadding(0f); surroundingCell.setBorder(PdfPCell.NO_BORDER); if (align != null) { placeHolderTable.setHorizontalAlignment(align.getCode()); surroundingCell.setHorizontalAlignment(align.getCode()); } PdfPTable surroundingTable = new PdfPTable(1); surroundingTable.setSpacingAfter((float) spacingAfter); surroundingTable.addCell(surroundingCell); surroundingTable.setComplete(true); return surroundingTable; }
From source file:org.opentestsystem.delivery.testreg.rest.view.PDFReportView.java
License:Open Source License
@Override @SuppressWarnings("unchecked") protected void buildPdfDocument(final Map<String, Object> model, final Document document, final PdfWriter writer, final HttpServletRequest request, final HttpServletResponse response) throws Exception { document.setMarginMirroringTopBottom(true); final List<TestAdminReport> dataList = (List<TestAdminReport>) model.get(DATA_LIST); final String reportType = ((String) model.get(REPORT_TYPE)).toUpperCase(); final String levelOfReport = (String) model.get(LEVEL_OF_REPORT); final String headerMessage = (String) model.get(HEADER_MESSAGE); writer.setPageEvent(new PdfReportPageEventHelper(writer)); HierarchyLevel level = null;//from ww w. ja v a 2 s.c o m if (levelOfReport != null) { level = HierarchyLevel.valueOf(levelOfReport); } final String headerColumns[] = this.reportHeaders.get(reportType); if (headerColumns != null) { PdfPTable table = createMessageHeaders(headerColumns, level, headerMessage); table.setSpacingAfter(10f); if (reportType.equals("PARTICIPATION_DETAIL_REPORT") || reportType.equals("PROCTOR_SCHEDULE_REPORT") || reportType.equals("STUDENT_SCHEDULE_REPORT")) { table = createHeaders(headerColumns, table); } else { table = createSummaryHeaders(headerColumns, level, table); } table.setHeaderRows(2); if (dataList.size() == 0) { addEmptyCell(table); } else { addData(table, dataList, level); } document.add(table); } }
From source file:org.oscarehr.common.service.PdfRecordPrinter.java
License:Open Source License
public void printSpecsHistory(List<EyeformSpecsHistory> specsHistory) throws DocumentException { ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao"); /*/* w w w .ja va 2s . c o m*/ if( getNewPage() ) getDocument().newPage(); else setNewPage(true); */ Font obsfont = new Font(getBaseFont(), FONTSIZE, Font.UNDERLINE); Paragraph p = new Paragraph(); p.setAlignment(Paragraph.ALIGN_LEFT); Phrase phrase = new Phrase(LEADING, "\n", getFont()); p.add(phrase); phrase = new Phrase(LEADING, "Specs History", obsfont); p.add(phrase); getDocument().add(p); PdfPTable table = new PdfPTable(2); table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); table.setSpacingBefore(10f); table.setSpacingAfter(10f); table.setTotalWidth(new float[] { 10f, 60f }); table.setTotalWidth(5f); table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT); for (EyeformSpecsHistory specs : specsHistory) { PdfPCell cell1 = new PdfPCell(new Phrase(getFormatter().format(specs.getDate()), getFont())); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); table.addCell(cell1); PdfPCell cell2 = new PdfPCell(new Phrase(specs.toString2(), getFont())); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); table.addCell(cell2); } getDocument().add(table); }
From source file:org.sakaiproject.tool.assessment.pdf.itext.HTMLWorker.java
License:Mozilla Public License
public void startElement(String tag, HashMap h) { if (!tagsSupported.containsKey(tag)) return;// ww w .ja va 2s . co m try { style.applyStyle(tag, h); String follow = (String) FactoryProperties.followTags.get(tag); if (follow != null) { HashMap prop = new HashMap(); prop.put(follow, null); cprops.addToChain(follow, prop); return; } FactoryProperties.insertStyle(h); if (tag.equals("a")) { cprops.addToChain(tag, h); if (currentParagraph == null) currentParagraph = new Paragraph(); stack.push(currentParagraph); currentParagraph = new Paragraph(); return; } if (tag.equals("br")) { if (currentParagraph == null) currentParagraph = new Paragraph(); currentParagraph.add(factoryProperties.createChunk("\n", cprops)); return; } if (tag.equals("hr")) { PdfPTable hr = new PdfPTable(1); hr.setHorizontalAlignment(Element.ALIGN_CENTER); hr.setWidthPercentage(100f); hr.setSpacingAfter(0f); hr.setSpacingBefore(0f); PdfPCell cell = new PdfPCell(); cell.setUseVariableBorders(true); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(PdfPCell.BOTTOM); cell.setBorderWidth(1f); cell.setPadding(0); cell.addElement(factoryProperties.createChunk("\n", cprops)); hr.addCell(cell); // paragraphs can't have tables? really? without it hr's may be rendered a bit early.. //if (currentParagraph != null) // currentParagraph.add(hr); //else document.add(hr); return; } if (tag.equals("font") || tag.equals("span")) { cprops.addToChain(tag, h); return; } if (tag.equals("img")) { String src = (String) h.get("src"); if (src == null) return; cprops.addToChain(tag, h); Image img = null; if (interfaceProps != null) { HashMap images = (HashMap) interfaceProps.get("img_static"); if (images != null) { Image tim = (Image) images.get(src); if (tim != null) img = Image.getInstance(tim); } else { if (!src.startsWith("http")) { // relative src references only String baseurl = (String) interfaceProps.get("img_baseurl"); if (baseurl != null) { src = baseurl + src; img = Image.getInstance(src); } } } } if (img == null) { if (!src.startsWith("http")) { String path = cprops.getProperty("image_path"); if (path == null) path = ""; src = new File(path, src).getPath(); img = Image.getInstance(src); } else { byte[] buffer; String srcResource = src.substring(src.indexOf("/content", 0)).replaceAll("/content", ""); buffer = getImageStream(URLDecoder.decode(srcResource)); img = Image.getInstance(buffer); } } String align = (String) h.get("align"); String width = (String) h.get("width"); String height = (String) h.get("height"); String border = (String) h.get("border"); String hspace = (String) h.get("hspace"); String vspace = (String) h.get("vspace"); String before = cprops.getProperty("before"); String after = cprops.getProperty("after"); float wp = 0.0f; float lp = 0.0f; if (maxWidth > 0 && ((width != null && Integer.parseInt(width) > maxWidth) || (width == null && (int) img.getWidth() > maxWidth))) { wp = lengthParse(String.valueOf(maxWidth), (int) img.getWidth()); lp = wp; } else { wp = lengthParse(width, (int) img.getWidth()); lp = lengthParse(height, (int) img.getHeight()); } if (wp > 0 && lp > 0) img.scalePercent(wp, lp); else if (wp > 0) img.scalePercent(wp); else if (lp > 0) img.scalePercent(lp); img.setWidthPercentage(0); // border if (border != null && !"".equals(border)) { try { img.setBorderWidth(Integer.parseInt(border)); img.setBorder(Image.BOX); } catch (Exception e) { e.printStackTrace(); } } // horizonatal space if (hspace != null && !"".equals(hspace)) { try { img.setSpacingAfter(Float.parseFloat(hspace)); img.setSpacingBefore(Float.parseFloat(hspace)); } catch (Exception e) { e.printStackTrace(); } } // horizontal alignment if (align != null && (align.equalsIgnoreCase("left") || align.equalsIgnoreCase("right"))) { endElement("p"); int ralign = Image.LEFT; if (align.equalsIgnoreCase("right")) ralign = Image.RIGHT; img.setAlignment(ralign | Image.TEXTWRAP); Img i = null; boolean skip = false; if (interfaceProps != null) { i = (Img) interfaceProps.get("img_interface"); if (i != null) skip = i.process(img, h, cprops, document); } if (!skip) document.add(img); cprops.removeChain(tag); } // vertical alignment (or none) else { img.setAlignment(Image.TEXTWRAP); float bottom = 0.0f; float top = img.getTop(); float prevHeight = 0.0f; float prevRise = 0.0f; if (currentParagraph != null) { ArrayList chunks = currentParagraph.getChunks(); Chunk sibling = null; for (int k = chunks.size() - 1; k >= 0; k--) { if (chunks.get(k) != null) sibling = (Chunk) chunks.get(k); } if (sibling != null) { if (sibling.hasAttributes()) prevRise = sibling.getTextRise(); prevHeight = 0.0f; if (sibling.getFont() != null) { prevHeight = sibling.getFont().getCalculatedSize(); } } } if ("absMiddle".equalsIgnoreCase(align)) { if (prevHeight > 0) bottom += (img.getScaledHeight() / 2.0f) - (prevHeight / 2.0f); else if (img.getScaledHeight() > 0) bottom += img.getScaledHeight() / 2.0f; } else if ("middle".equalsIgnoreCase(align)) { if (img.getScaledHeight() > 0) bottom += (img.getScaledHeight() / 2.0f); } else if ("bottom".equalsIgnoreCase(align) || "baseline".equalsIgnoreCase(align) || "absbottom".equalsIgnoreCase(align)) { //baseline and absbottom should have some slight tweeking from bottom, but not sure what?? } else if ("top".equalsIgnoreCase(align)) { bottom += img.getScaledHeight() - prevHeight; } else if ("texttop".equalsIgnoreCase(align)) { bottom += img.getScaledHeight() - (prevHeight - prevRise); } cprops.removeChain(tag); if (currentParagraph == null) { currentParagraph = FactoryProperties.createParagraph(cprops); bottom = 0f; } else if (currentParagraph.isEmpty()) { bottom = 0f; } currentParagraph.setLeading(2f + bottom, 1.00f); currentParagraph.add(new Chunk(img, 0, 0 - bottom)); } return; } if (tag.equals("blockquote")) { cprops.addToChain(tag, h); inBLOCK = true; if (currentParagraph != null) endElement("p"); currentParagraph = FactoryProperties.createParagraph(cprops); currentParagraph.add(factoryProperties.createChunk("\n", cprops)); return; } endElement("p"); if (tag.equals("h1") || tag.equals("h2") || tag.equals("h3") || tag.equals("h4") || tag.equals("h5") || tag.equals("h6")) { if (!h.containsKey("size")) { int v = 8 - Integer.parseInt(tag.substring(1)); h.put("size", Integer.toString(v)); } cprops.addToChain(tag, h); return; } if (tag.equals("ul")) { if (pendingLI) endElement("li"); skipText = true; cprops.addToChain(tag, h); com.lowagie.text.List list = new com.lowagie.text.List(false, 10); list.setListSymbol("\u2022"); stack.push(list); return; } if (tag.equals("ol")) { if (pendingLI) endElement("li"); skipText = true; cprops.addToChain(tag, h); com.lowagie.text.List list = new com.lowagie.text.List(true, 10); stack.push(list); return; } if (tag.equals("li")) { if (pendingLI) endElement("li"); skipText = false; pendingLI = true; cprops.addToChain(tag, h); stack.push(FactoryProperties.createListItem(cprops)); return; } if (tag.equals("div") || tag.equals("body")) { cprops.addToChain(tag, h); return; } if (tag.equals("pre")) { if (!h.containsKey("face")) { h.put("face", "Courier"); } cprops.addToChain(tag, h); isPRE = true; return; } if (tag.equals("p")) { cprops.addToChain(tag, h); currentParagraph = FactoryProperties.createParagraph(cprops); if (inBLOCK) { currentParagraph.setIndentationLeft(currentParagraph.getIndentationLeft() + 40.0F); } return; } if (tag.equals("tr")) { if (pendingTR) endElement("tr"); skipText = true; pendingTR = true; cprops.addToChain("tr", h); return; } if (tag.equals("td") || tag.equals("th")) { if (pendingTD) endElement(tag); skipText = false; pendingTD = true; cprops.addToChain("td", h); stack.push(new IncCell(tag, cprops)); return; } if (tag.equals("table")) { cprops.addToChain("table", h); IncTable table = new IncTable(h); stack.push(table); tableState.push(new boolean[] { pendingTR, pendingTD }); pendingTR = pendingTD = false; skipText = true; return; } } catch (Exception e) { e.printStackTrace(); //throw new ExceptionConverter(e); } }