List of usage examples for com.lowagie.text Chunk setAnchor
public Chunk setAnchor(String url)
Chunk
. From source file:classroom.filmfestival_b.Movies14.java
@SuppressWarnings("unchecked") public static void main(String[] args) { // step 1// w w w . jav a 2s .co m Document document = new Document(); try { // step 2 OutputStream os = new FileOutputStream(RESULT); PdfWriter.getInstance(document, os); // step 3 document.open(); // step 4 Session session = (Session) MySessionFactory.currentSession(); Query q = session.createQuery("from FilmTitle order by title"); java.util.List<FilmTitle> results = q.list(); PdfPTable table = new PdfPTable(2); table.setWidths(new float[] { 1, 5 }); File f; Paragraph p; Chunk c; PdfPCell cell = new PdfPCell(); Font bold = new Font(Font.HELVETICA, 12, Font.BOLD); Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC); p = new Paragraph("FILMFESTIVAL", bold); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setColspan(2); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); cell = new PdfPCell(); cell.setFixedHeight(20); cell.setColspan(2); cell.setBorder(PdfPCell.NO_BORDER); cell.setCellEvent(new Movies14().new PageCell()); table.addCell(cell); table.setHeaderRows(2); table.setFooterRows(1); for (FilmTitle movie : results) { f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg"); if (f.exists()) { cell = new PdfPCell(Image.getInstance(f.getPath()), true); cell.setPadding(2); } else { cell = new PdfPCell(); } table.addCell(cell); p = new Paragraph(20); c = new Chunk(movie.getTitle(), bold); c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId()); p.add(c); c = new Chunk(" (" + movie.getYear() + ") ", italic); p.add(c); c = new Chunk("IMDB"); c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb()); p.add(c); cell = new PdfPCell(); cell.setUseAscender(true); cell.setUseDescender(true); cell.addElement(p); Set<DirectorName> directors = movie.getDirectorNames(); List list = new List(); for (DirectorName director : directors) { list.add(director.getName()); } cell.addElement(list); table.addCell(cell); } document.add(table); // step 5 document.close(); } catch (IOException e) { LOGGER.error("IOException: ", e); } catch (DocumentException e) { LOGGER.error("DocumentException: ", e); } }
From source file:classroom.filmfestival_b.Movies15.java
@SuppressWarnings("unchecked") public static void main(String[] args) { // step 1/* w ww. j av a2 s .c o m*/ Document document = new Document(); try { // step 2 OutputStream os = new FileOutputStream(RESULT); PdfWriter writer = PdfWriter.getInstance(document, os); // step 3 document.open(); // step 4 Session session = (Session) MySessionFactory.currentSession(); Query q = session.createQuery("from FilmTitle order by title"); java.util.List<FilmTitle> results = q.list(); PdfPTable table = new PdfPTable(2); table.setComplete(false); table.setWidths(new float[] { 1, 5 }); File f; Paragraph p; Chunk c; PdfPCell cell = new PdfPCell(); Font bold = new Font(Font.HELVETICA, 12, Font.BOLD); Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC); p = new Paragraph("FILMFESTIVAL", bold); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setColspan(2); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); cell = new PdfPCell(); cell.setFixedHeight(20); cell.setColspan(2); cell.setBorder(PdfPCell.NO_BORDER); cell.setCellEvent(new Movies14().new PageCell()); table.addCell(cell); table.setHeaderRows(2); table.setFooterRows(1); int counter = 10; for (FilmTitle movie : results) { f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg"); if (f.exists()) { cell = new PdfPCell(Image.getInstance(f.getPath()), true); cell.setPadding(2); } else { cell = new PdfPCell(); } table.addCell(cell); p = new Paragraph(20); c = new Chunk(movie.getTitle(), bold); c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId()); p.add(c); c = new Chunk(" (" + movie.getYear() + ") ", italic); p.add(c); c = new Chunk("IMDB"); c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb()); p.add(c); cell = new PdfPCell(); cell.setUseAscender(true); cell.setUseDescender(true); cell.addElement(p); Set<DirectorName> directors = movie.getDirectorNames(); List list = new List(); for (DirectorName director : directors) { list.add(director.getName()); } cell.addElement(list); table.addCell(cell); if (counter % 10 == 0) { document.add(table); } System.out.println(writer.getPageNumber()); counter++; } table.setComplete(true); document.add(table); // step 5 document.close(); } catch (IOException e) { LOGGER.error("IOException: ", e); } catch (DocumentException e) { LOGGER.error("DocumentException: ", e); } }
From source file:classroom.filmfestival_c.Movies16.java
@SuppressWarnings("unchecked") public static void main(String[] args) { // step 1/*from www . ja va 2 s . c o m*/ Document document = new Document(); try { // step 2 OutputStream os = new FileOutputStream(RESULT); PdfWriter.getInstance(document, os); // step 3 document.open(); // step 4 PdfPTable table; PdfPCell cell; Chunk imdb; Session session = (Session) MySessionFactory.currentSession(); Query q = session.createQuery( "select distinct festival.id.day from FestivalScreening as festival order by festival.id.day"); java.util.List<Date> days = q.list(); java.util.List<FestivalScreening> screenings; for (Date day : days) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(day); if (gc.get(GregorianCalendar.YEAR) != YEAR) continue; table = new PdfPTable(new float[] { 7, 1, 2, 1 }); cell = new PdfPCell(new Phrase(day.toString(), NORMALWHITE)); cell.setBackgroundColor(BLACK); cell.setColspan(4); table.addCell(cell); q = session.createQuery("from FestivalScreening where id.day=? order by id.time, id.place"); q.setDate(0, day); screenings = q.list(); for (FestivalScreening screening : screenings) { table.addCell(screening.getFilmTitle().getTitle()); table.addCell(screening.getId().getPlace().toString()); cell = new PdfPCell(new Phrase(screening.getId().getTime().toString())); if (screening.getPress() == 1) { cell.setBackgroundColor(SILVER); } table.addCell(cell); if (screening.getFilmTitle().getImdb().startsWith("?")) { table.addCell(""); } else { imdb = new Chunk("imdb"); imdb.setAnchor("http://imdb.com/title/tt" + screening.getFilmTitle().getImdb()); table.addCell(new Phrase(imdb)); } } document.add(table); } // step 5 document.close(); } catch (IOException e) { LOGGER.error("IOException: ", e); } catch (DocumentException e) { LOGGER.error("DocumentException: ", e); } }
From source file:com.develog.utils.report.engine.export.JRPdfExporter.java
License:Open Source License
/** * *///w w w . jav a2s . c o m protected void exportImage(JRPrintImage printImage) throws DocumentException, IOException { pdfContentByte.setRGBColorFill(printImage.getBackcolor().getRed(), printImage.getBackcolor().getGreen(), printImage.getBackcolor().getBlue()); int borderOffset = 0; float borderCorrection = 0f; float lineWidth = 1f; boolean isLineDotted = false; switch (printImage.getPen()) { case JRGraphicElement.PEN_DOTTED: { borderOffset = 0; borderCorrection = 0f; lineWidth = 1f; isLineDotted = true; break; } case JRGraphicElement.PEN_4_POINT: { borderOffset = 2; borderCorrection = 0f; lineWidth = 4f; isLineDotted = false; break; } case JRGraphicElement.PEN_2_POINT: { borderOffset = 1; borderCorrection = 0f; lineWidth = 2f; isLineDotted = false; break; } case JRGraphicElement.PEN_THIN: { borderOffset = 0; borderCorrection = 0.25f; lineWidth = 0.5f; isLineDotted = false; break; } case JRGraphicElement.PEN_NONE: { borderOffset = 0; borderCorrection = 0.5f; lineWidth = 1f; isLineDotted = false; break; } case JRGraphicElement.PEN_1_POINT: default: { borderOffset = 0; borderCorrection = 0f; lineWidth = 1f; isLineDotted = false; break; } } if (printImage.getMode() == JRElement.MODE_OPAQUE) { pdfContentByte.setRGBColorStroke(printImage.getBackcolor().getRed(), printImage.getBackcolor().getGreen(), printImage.getBackcolor().getBlue()); pdfContentByte.setLineWidth(0.1f); pdfContentByte.setLineDash(0f); pdfContentByte.rectangle(printImage.getX() - borderCorrection, jasperPrint.getPageHeight() - printImage.getY() + borderCorrection, printImage.getWidth() + 2 * borderCorrection - 1, -printImage.getHeight() - 2 * borderCorrection + 1); pdfContentByte.fillStroke(); } int availableImageWidth = printImage.getWidth() - 2 * borderOffset; availableImageWidth = (availableImageWidth < 0) ? 0 : availableImageWidth; int availableImageHeight = printImage.getHeight() - 2 * borderOffset; availableImageHeight = (availableImageHeight < 0) ? 0 : availableImageHeight; int xoffset = 0; int yoffset = 0; if (printImage.getImageData() != null && availableImageWidth > 0 && availableImageHeight > 0) { //java.awt.Image awtImage = JRImageLoader.loadImage(printImage.getImageData()); //com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(awtImage, printImage.getBackcolor()); //com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(awtImage, null); com.lowagie.text.Image image = null; float xalignFactor = 0f; switch (printImage.getHorizontalAlignment()) { case JRAlignment.HORIZONTAL_ALIGN_RIGHT: { xalignFactor = 1f; break; } case JRAlignment.HORIZONTAL_ALIGN_CENTER: { xalignFactor = 0.5f; break; } case JRAlignment.HORIZONTAL_ALIGN_LEFT: default: { xalignFactor = 0f; break; } } float yalignFactor = 0f; switch (printImage.getVerticalAlignment()) { case JRAlignment.VERTICAL_ALIGN_BOTTOM: { yalignFactor = 1f; break; } case JRAlignment.VERTICAL_ALIGN_MIDDLE: { yalignFactor = 0.5f; break; } case JRAlignment.VERTICAL_ALIGN_TOP: default: { yalignFactor = 0f; break; } } switch (printImage.getScaleImage()) { case JRImage.SCALE_IMAGE_CLIP: { java.awt.Image awtImage = JRImageLoader.loadImage(printImage.getImageData()); //image = com.lowagie.text.Image.getInstance(awtImage, null); int awtWidth = awtImage.getWidth(null); int awtHeight = awtImage.getHeight(null); xoffset = (int) (xalignFactor * (availableImageWidth - awtWidth)); yoffset = (int) (yalignFactor * (availableImageHeight - awtHeight)); int minWidth = Math.min(awtWidth, availableImageWidth); int minHeight = Math.min(awtHeight, availableImageHeight); BufferedImage bi = new BufferedImage(minWidth, minHeight, BufferedImage.TYPE_INT_RGB); Graphics g = bi.getGraphics(); g.setColor(printImage.getBackcolor()); g.fillRect(0, 0, minWidth, minHeight); g.drawImage(awtImage, (xoffset > 0 ? 0 : xoffset), (yoffset > 0 ? 0 : yoffset), null); xoffset = (xoffset < 0 ? 0 : xoffset); yoffset = (yoffset < 0 ? 0 : yoffset); //awtImage = bi.getSubimage(0, 0, minWidth, minHeight); awtImage = bi; //image = com.lowagie.text.Image.getInstance(awtImage, printImage.getBackcolor()); image = com.lowagie.text.Image.getInstance(awtImage, null); break; } case JRImage.SCALE_IMAGE_FILL_FRAME: { try { image = com.lowagie.text.Image.getInstance(printImage.getImageData()); imageTesterPdfContentByte.addImage(image, 10, 0, 0, 10, 0, 0); } catch (Exception e) { java.awt.Image awtImage = JRImageLoader.loadImage(printImage.getImageData()); image = com.lowagie.text.Image.getInstance(awtImage, null); } image.scaleAbsolute(availableImageWidth, availableImageHeight); break; } case JRImage.SCALE_IMAGE_RETAIN_SHAPE: default: { try { image = com.lowagie.text.Image.getInstance(printImage.getImageData()); imageTesterPdfContentByte.addImage(image, 10, 0, 0, 10, 0, 0); } catch (Exception e) { java.awt.Image awtImage = JRImageLoader.loadImage(printImage.getImageData()); image = com.lowagie.text.Image.getInstance(awtImage, null); } image.scaleToFit(availableImageWidth, availableImageHeight); xoffset = (int) (xalignFactor * (availableImageWidth - image.plainWidth())); yoffset = (int) (yalignFactor * (availableImageHeight - image.plainHeight())); xoffset = (xoffset < 0 ? 0 : xoffset); yoffset = (yoffset < 0 ? 0 : yoffset); break; } } /* image.setAbsolutePosition( printImage.getX() + borderOffset, jasperPrint.getPageHeight() - printImage.getY() - image.scaledHeight() - borderOffset ); pdfContentByte.addImage(image); */ Chunk chunk = new Chunk(image, -0.5f, 0.5f); if (printImage.getAnchorName() != null) { chunk.setLocalDestination(printImage.getAnchorName()); } switch (printImage.getHyperlinkType()) { case JRHyperlink.HYPERLINK_TYPE_REFERENCE: { if (printImage.getHyperlinkReference() != null) { chunk.setAnchor(printImage.getHyperlinkReference()); } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR: { if (printImage.getHyperlinkAnchor() != null) { chunk.setLocalGoto(printImage.getHyperlinkAnchor()); } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE: { if (printImage.getHyperlinkPage() != null) { chunk.setLocalGoto("JR_PAGE_ANCHOR_" + printImage.getHyperlinkPage().toString()); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR: { if (printImage.getHyperlinkReference() != null && printImage.getHyperlinkAnchor() != null) { chunk.setRemoteGoto(printImage.getHyperlinkReference(), printImage.getHyperlinkAnchor()); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE: { if (printImage.getHyperlinkReference() != null && printImage.getHyperlinkPage() != null) { chunk.setRemoteGoto(printImage.getHyperlinkReference(), printImage.getHyperlinkPage().intValue()); } break; } case JRHyperlink.HYPERLINK_TYPE_NONE: default: { break; } } ColumnText colText = new ColumnText(pdfContentByte); colText.setSimpleColumn(new Phrase(chunk), printImage.getX() + xoffset + borderOffset, jasperPrint.getPageHeight() - printImage.getY() - image.scaledHeight() - yoffset - borderOffset, printImage.getX() + xoffset + borderOffset + image.scaledWidth(), jasperPrint.getPageHeight() - printImage.getY() - yoffset - borderOffset, image.scaledHeight(), Element.ALIGN_LEFT); colText.go(); } if (printImage.getPen() != JRGraphicElement.PEN_NONE) { pdfContentByte.setRGBColorStroke(printImage.getForecolor().getRed(), printImage.getForecolor().getGreen(), printImage.getForecolor().getBlue()); pdfContentByte.setLineWidth(lineWidth); if (isLineDotted) { pdfContentByte.setLineDash(5f, 3f, 0f); } else { pdfContentByte.setLineDash(0f); } pdfContentByte.rectangle(printImage.getX() - borderCorrection, jasperPrint.getPageHeight() - printImage.getY() + borderCorrection, printImage.getWidth() + 2 * borderCorrection - 1, -printImage.getHeight() - 2 * borderCorrection + 1); pdfContentByte.stroke(); } }
From source file:com.develog.utils.report.engine.export.JRPdfExporter.java
License:Open Source License
/** * /*from w w w . ja va2 s . c o m*/ */ protected Chunk getHyperlinkInfoChunk(JRPrintText text) { Chunk chunk = new Chunk(EMPTY_STRING); if (text.getAnchorName() != null) { chunk.setLocalDestination(text.getAnchorName()); } switch (text.getHyperlinkType()) { case JRHyperlink.HYPERLINK_TYPE_REFERENCE: { if (text.getHyperlinkReference() != null) { chunk.setAnchor(text.getHyperlinkReference()); } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR: { if (text.getHyperlinkAnchor() != null) { chunk.setLocalGoto(text.getHyperlinkAnchor()); } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE: { if (text.getHyperlinkPage() != null) { chunk.setLocalGoto("JR_PAGE_ANCHOR_" + text.getHyperlinkPage().toString()); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR: { if (text.getHyperlinkReference() != null && text.getHyperlinkAnchor() != null) { chunk.setRemoteGoto(text.getHyperlinkReference(), text.getHyperlinkAnchor()); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE: { if (text.getHyperlinkReference() != null && text.getHyperlinkPage() != null) { chunk.setRemoteGoto(text.getHyperlinkReference(), text.getHyperlinkPage().intValue()); } break; } case JRHyperlink.HYPERLINK_TYPE_NONE: default: { break; } } return chunk; }
From source file:com.dlya.facturews.DlyaPdfExporter2.java
License:Open Source License
/** * *//*w w w. j av a 2 s . co m*/ protected void setHyperlinkInfo(Chunk chunk, JRPrintHyperlink link) { if (link != null) { switch (link.getHyperlinkTypeValue()) { case REFERENCE: { if (link.getHyperlinkReference() != null) { switch (link.getHyperlinkTargetValue()) { case BLANK: { chunk.setAction(PdfAction.javaScript("if (app.viewerVersion < 7)" + "{this.getURL(\"" + link.getHyperlinkReference() + "\");}" + "else {app.launchURL(\"" + link.getHyperlinkReference() + "\", true);};", pdfWriter)); break; } case SELF: default: { chunk.setAnchor(link.getHyperlinkReference()); break; } } } break; } case LOCAL_ANCHOR: { if (link.getHyperlinkAnchor() != null) { chunk.setLocalGoto(link.getHyperlinkAnchor()); } break; } case LOCAL_PAGE: { if (link.getHyperlinkPage() != null) { chunk.setLocalGoto( JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + link.getHyperlinkPage().toString()); } break; } case REMOTE_ANCHOR: { if (link.getHyperlinkReference() != null && link.getHyperlinkAnchor() != null) { chunk.setRemoteGoto(link.getHyperlinkReference(), link.getHyperlinkAnchor()); } break; } case REMOTE_PAGE: { if (link.getHyperlinkReference() != null && link.getHyperlinkPage() != null) { chunk.setRemoteGoto(link.getHyperlinkReference(), link.getHyperlinkPage().intValue()); } break; } case CUSTOM: { if (hyperlinkProducerFactory != null) { String hyperlink = hyperlinkProducerFactory.produceHyperlink(link); if (hyperlink != null) { switch (link.getHyperlinkTargetValue()) { case BLANK: { chunk.setAction( PdfAction.javaScript( "if (app.viewerVersion < 7)" + "{this.getURL(\"" + hyperlink + "\");}" + "else {app.launchURL(\"" + hyperlink + "\", true);};", pdfWriter)); break; } case SELF: default: { chunk.setAnchor(hyperlink); break; } } } } } case NONE: default: { break; } } } }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private void addLinkPart(String link, Phrase bodyPhrase, Font linkFont) { String linkName = link;/* w w w. j av a 2 s . c o m*/ link = link.trim(); Chunk anchor = new Chunk(linkName, linkFont); /* * A anchor need http (or https) */ if (!link.toLowerCase().startsWith("http")) { link = "http://" + link; } anchor.setAnchor(link); bodyPhrase.add(anchor); }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private void addReplyLink(Document document, String replyURL) throws DocumentException { PdfPTable replyTable = new PdfPTable(1); replyTable.setWidthPercentage(100f); replyTable.setSplitLate(false);/*from w ww . ja v a2 s . co m*/ replyTable.setSpacingBefore(5f); replyTable.setHorizontalAlignment(Element.ALIGN_LEFT); Font linkFont = new Font(); linkFont.setStyle(Font.BOLD); linkFont.setColor(0, 0, 255); linkFont.setSize(headerFontSize); Chunk anchor = new Chunk("Reply", linkFont); anchor.setAnchor(replyURL); Phrase phrase = new Phrase(); phrase.add(anchor); PdfPCell cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); replyTable.addCell(cell); document.add(replyTable); }
From source file:net.sf.jasperreports.engine.export.JRPdfExporter.java
License:LGPL
/** * *//*from ww w .ja v a2s .co m*/ protected void setHyperlinkInfo(Chunk chunk, JRPrintHyperlink link) { switch (link.getHyperlinkType()) { case JRHyperlink.HYPERLINK_TYPE_REFERENCE: { if (link.getHyperlinkReference() != null) { switch (link.getHyperlinkTarget()) { case JRHyperlink.HYPERLINK_TARGET_BLANK: { chunk.setAction(PdfAction.javaScript("if (app.viewerVersion < 7)" + "{this.getURL(\"" + link.getHyperlinkReference() + "\");}" + "else {app.launchURL(\"" + link.getHyperlinkReference() + "\", true);};", pdfWriter)); break; } case JRHyperlink.HYPERLINK_TARGET_SELF: default: { chunk.setAnchor(link.getHyperlinkReference()); break; } } } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR: { if (link.getHyperlinkAnchor() != null) { chunk.setLocalGoto(link.getHyperlinkAnchor()); } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE: { if (link.getHyperlinkPage() != null) { chunk.setLocalGoto(JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + link.getHyperlinkPage().toString()); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR: { if (link.getHyperlinkReference() != null && link.getHyperlinkAnchor() != null) { chunk.setRemoteGoto(link.getHyperlinkReference(), link.getHyperlinkAnchor()); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE: { if (link.getHyperlinkReference() != null && link.getHyperlinkPage() != null) { chunk.setRemoteGoto(link.getHyperlinkReference(), link.getHyperlinkPage().intValue()); } break; } case JRHyperlink.HYPERLINK_TYPE_CUSTOM: { if (hyperlinkProducerFactory != null) { String hyperlink = hyperlinkProducerFactory.produceHyperlink(link); if (hyperlink != null) { switch (link.getHyperlinkTarget()) { case JRHyperlink.HYPERLINK_TARGET_BLANK: { chunk.setAction( PdfAction.javaScript( "if (app.viewerVersion < 7)" + "{this.getURL(\"" + hyperlink + "\");}" + "else {app.launchURL(\"" + hyperlink + "\", true);};", pdfWriter)); break; } case JRHyperlink.HYPERLINK_TARGET_SELF: default: { chunk.setAnchor(hyperlink); break; } } } } } case JRHyperlink.HYPERLINK_TYPE_NONE: default: { break; } } }
From source file:nl.knaw.dans.common.lang.pdf.ExtendedHtmlWorker.java
License:Apache License
public void endElement(String tag) { if (!tagsSupported.containsKey(tag)) return;/*from w w w.j a v a 2s . c om*/ try { String follow = (String) FactoryProperties.followTags.get(tag); if (follow != null) { cprops.removeChain(follow); return; } if (tag.equals("font") || tag.equals("span")) { cprops.removeChain(tag); return; } if (tag.equals("a")) { if (currentParagraph == null) currentParagraph = new Paragraph(); ALink i = null; boolean skip = false; if (interfaceProps != null) { i = (ALink) interfaceProps.get("alink_interface"); if (i != null) skip = i.process(currentParagraph, cprops); } if (!skip) { String href = cprops.getProperty("href"); if (href != null) { ArrayList chunks = currentParagraph.getChunks(); for (int k = 0; k < chunks.size(); ++k) { Chunk ck = (Chunk) chunks.get(k); ck.setAnchor(href); } } } Paragraph tmp = (Paragraph) stack.pop(); Phrase tmp2 = new Phrase(); tmp2.add(currentParagraph); tmp.add(tmp2); currentParagraph = tmp; cprops.removeChain("a"); return; } if (tag.equals("br")) { return; } if (currentParagraph != null) { if (stack.empty()) document.add(currentParagraph); else { Object obj = stack.pop(); if (obj instanceof TextElementArray) { TextElementArray current = (TextElementArray) obj; current.add(currentParagraph); } stack.push(obj); } } currentParagraph = null; if (tag.equals("ul") || tag.equals("ol")) { if (pendingLI) endElement("li"); skipText = false; cprops.removeChain(tag); if (stack.empty()) return; Object obj = stack.pop(); if (!(obj instanceof com.lowagie.text.List)) { stack.push(obj); return; } if (stack.empty()) document.add((Element) obj); else ((TextElementArray) stack.peek()).add(obj); return; } if (tag.equals("li")) { pendingLI = false; skipText = true; cprops.removeChain(tag); if (stack.empty()) return; Object obj = stack.pop(); if (!(obj instanceof ListItem)) { stack.push(obj); return; } if (stack.empty()) { document.add((Element) obj); return; } Object list = stack.pop(); if (!(list instanceof com.lowagie.text.List)) { stack.push(list); return; } ListItem item = (ListItem) obj; ((com.lowagie.text.List) list).add(item); ArrayList cks = item.getChunks(); if (!cks.isEmpty()) item.getListSymbol().setFont(((Chunk) cks.get(0)).getFont()); stack.push(list); return; } if (tag.equals("div") || tag.equals("body")) { cprops.removeChain(tag); return; } if (tag.equals("pre")) { cprops.removeChain(tag); isPRE = false; return; } if (tag.equals("p")) { cprops.removeChain(tag); return; } if (tag.equals("h1") || tag.equals("h2") || tag.equals("h3") || tag.equals("h4") || tag.equals("h5") || tag.equals("h6")) { cprops.removeChain(tag); return; } if (tag.equals("table")) { if (pendingTR) endElement("tr"); cprops.removeChain("table"); IncTable table = (IncTable) stack.pop(); PdfPTable tb = table.buildTable(); tb.setSplitRows(true); if (stack.empty()) document.add(tb); else ((TextElementArray) stack.peek()).add(tb); boolean state[] = (boolean[]) tableState.pop(); pendingTR = state[0]; pendingTD = state[1]; skipText = false; return; } if (tag.equals("tr")) { if (pendingTD) endElement("td"); pendingTR = false; cprops.removeChain("tr"); ArrayList cells = new ArrayList(); IncTable table = null; while (true) { Object obj = stack.pop(); if (obj instanceof IncCell) { cells.add(((IncCell) obj).getCell()); } if (obj instanceof IncTable) { table = (IncTable) obj; break; } } table.addCols(cells); table.endRow(); stack.push(table); skipText = true; return; } if (tag.equals("td") || tag.equals("th")) { pendingTD = false; cprops.removeChain("td"); skipText = true; return; } } catch (Exception e) { throw new ExceptionConverter(e); } }