List of usage examples for com.lowagie.text Chunk Chunk
public Chunk(DrawInterface separator, float tabPosition)
From source file:org.areasy.common.doclet.document.Summary.java
License:Open Source License
/** * Creates the inner table for both columns. The left column * already contains the declaration text part. * * @param text The text (like "static final"..) *//*ww w . ja v a 2s .c om*/ private static PdfPTable addDeclaration(String text, Phrase returnType) throws DocumentException { PdfPTable innerTable = new PdfPTable(2); innerTable.setWidthPercentage(100f); innerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); innerTable.setWidths(new int[] { 24, 76 }); Paragraph declarationParagraph = new Paragraph((float) 9.0); Chunk leftPart = new Chunk(text, Fonts.getFont(CODE_FONT, 9)); declarationParagraph.add(leftPart); if (returnType != null) { declarationParagraph.add(returnType); declarationParagraph.add(new Chunk(" ", Fonts.getFont(CODE_FONT, 9))); } PdfPCell cell = new CustomPdfPCell(Rectangle.RIGHT, declarationParagraph, 1, Color.gray); cell.setPaddingTop((float) 4.0); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); innerTable.addCell(cell); return innerTable; }
From source file:org.areasy.common.doclet.document.tags.HtmlTag.java
License:Open Source License
/** * This method must be implemented by subclasses in order * to provide a mechanism to convert an HTML tag into * a PDF document object.//ww w . j a v a 2 s . c o m * * @param text The text with HTML tags. * @return The PDF Element representint that HTML code. */ public Element toElement(String text) { if (!isPre()) text = DocletUtility.stripLineFeeds(text); Phrase result = new Phrase(); result.add(new Chunk(text, getFont())); return result; }
From source file:org.areasy.common.doclet.document.tags.HtmlTag.java
License:Open Source License
/** * Creates a PDF Paragraph with the appropriate * alignment and the default leading and correct font. * * @param content The text that goes into the Paragraph. * @return The resulting PDF Paragraph object. *//*from ww w . ja v a2s .c om*/ public Paragraph createParagraph(String content) { return createParagraph(new Chunk(content, getFont())); }
From source file:org.areasy.common.doclet.document.tags.TagA.java
License:Open Source License
public Element toElement(String text) { String addr = getAttribute("href"); if (addr == null || !DefaultConfiguration.isLinksCreationActive()) addr = ""; if (!isPre()) text = DocletUtility.stripLineFeeds(text); Element aChunk;/*from w ww .j a va 2 s . co m*/ if (addr.startsWith("locallink")) { boolean plainText = addr.startsWith("locallinkplain"); String dest = addr.substring(addr.indexOf(':') + 1).trim(); setCode(!plainText); return new LinkPhrase(dest, text, Math.max(9, (int) getFont().size()), plainText); } else if (addr.equalsIgnoreCase("newpage")) return super.toElement(text); else if (addr.startsWith("http://") || addr.startsWith("https://")) { try { URL url = new URL(addr); return new Chunk(text, getFont()).setAnchor(url); } catch (MalformedURLException e) { log.error("Malformed URL: " + addr); } } else { String fileName = addr.trim(); String anchorName = ""; int hashIndex = addr.indexOf('#'); if (hashIndex >= 0) { fileName = addr.substring(0, hashIndex).trim(); anchorName = addr.substring(hashIndex + 1).trim(); } boolean isLocalAnchor = (fileName.length() == 0 && anchorName.length() > 0); File file = null; try { if (fileName.length() > 0) file = new File(DocletUtility.getFilePath(fileName)); else file = State.getCurrentFile(); } catch (FileNotFoundException e) { log.debug("Could not find linked file " + fileName); } if (isLocalAnchor || Destinations.isValidDestinationFile(file)) { String fullAnchor = Destinations.createAnchorDestination(file, anchorName); PdfAction action = new PdfAction("", ""); action.remove(PdfName.F); action.put(PdfName.S, PdfName.GOTO); action.put(PdfName.D, new PdfString(fullAnchor)); aChunk = new Phrase(); Chunk chunk = createChunk(text); ((Phrase) aChunk).add(chunk.setAction(action)); return aChunk; } } if (getAttribute("name") != null) setLink(false); // no underline for anchors Font font = getFont(); font.setColor(0, 0, 0); aChunk = new Chunk(text, font); setLink(false); return aChunk; }
From source file:org.areasy.common.doclet.document.tags.TagH.java
License:Open Source License
public Element[] openTagElements() { Element[] elements;//from w w w . j a va2s.co m Chunk anchor = addHeaderBookmarkEntry(); if (anchor == null) elements = new Element[2]; else elements = new Element[3]; Paragraph p1 = createParagraph(new Chunk(" ", Fonts.getFont(TEXT_FONT, 16))); p1.setLeading(parent.getLeading()); Paragraph p2 = createParagraph(""); if (anchor != null) { elements[0] = anchor; elements[1] = p1; elements[2] = p2; } else { elements[0] = p1; elements[1] = p2; } return elements; }
From source file:org.areasy.common.doclet.document.tags.TagH.java
License:Open Source License
public Element[] closeTagElements() { Element[] elements = new Element[2]; Paragraph p1 = createParagraph(new Chunk(" ", Fonts.getFont(TEXT_FONT, 16))); p1.setLeading((float) 10.0); Paragraph p2 = createParagraph(""); p2.setLeading(parent.getLeading());/*from www. j av a 2s. c o m*/ elements[0] = p1; elements[1] = p2; return elements; }
From source file:org.areasy.common.doclet.document.tags.TagLI.java
License:Open Source License
public Element toElement(String text) { listEntry.add(new Chunk(DocletUtility.stripLineFeeds(text), getFont())); return null; }
From source file:org.areasy.common.doclet.document.tags.TagOL.java
License:Open Source License
public Element[] openTagElements() { char typeChar = getTypeChar(); int first = getFirstListIndex(); switch (typeChar) { case 'a': case 'A': list = new List(false, true, 20); if (first > 0 && first <= 26) list.setFirst((char) (typeChar + (first - 1))); break;//from w w w .j a v a 2s . c o m case 'i': case 'I': list = new RomanList(typeChar == 'i', 20); if (first > 0) list.setFirst(first); break; case '1': default: list = new List(true, 20); if (first > 0) list.setFirst(first); } list.setListSymbol(new Chunk("", getFont())); Element[] elements = new Element[1]; elements[0] = new Paragraph((float) 8.0, " ", getFont()); return elements; }
From source file:org.areasy.common.doclet.document.tags.TagUL.java
License:Open Source License
public Element[] openTagElements() { Font symbolFont = new Font(Font.UNDEFINED, getFont().size()); list.setListSymbol(new Chunk(BULLET, symbolFont)); list.setIndentationLeft(12);//from www.java2 s. co m Element[] elements = new Element[1]; elements[0] = new Paragraph(" ", getFont()); return elements; }
From source file:org.areasy.common.doclet.utilities.PDFUtility.java
License:Open Source License
/** * Returns a Chunk that is an anchor destination for the given label. * The Chunk will be empty (have no text), so it can be placed anywhere. * The font size can make a difference in the PDF reader's behavior when * jumped to -- usually it will make sure to make the entire line height * visible.//from ww w . ja v a 2s . co m */ public static Chunk createAnchor(String destination, Font font) { final String EMPTY_TEXT = "\uFEFF"; Chunk anchorChunk = new Chunk(EMPTY_TEXT, font); anchorChunk.setLocalDestination(destination); return anchorChunk; }