List of usage examples for com.lowagie.text Font setColor
public void setColor(int red, int green, int blue)
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private Font createLinkFont() { /*//from w w w .ja va2 s . c o m * Font for anchors (links) */ Font linkFont = new Font(); linkFont.setStyle(Font.UNDERLINE); linkFont.setColor(0, 0, 255); linkFont.setSize(linkFontSize); return linkFont; }
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);/* ww w . j ava2 s .c o 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: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;/*w ww.j ava 2s. c om*/ 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; }