List of usage examples for com.lowagie.text.pdf PdfBorderDictionary PdfBorderDictionary
public PdfBorderDictionary(float borderWidth, int borderStyle)
From source file:org.xhtmlrenderer.pdf.ITextOutputDevice.java
License:Open Source License
private void processLink(RenderingContext c, Box box) { Element elem = box.getElement(); if (elem != null) { NamespaceHandler handler = _sharedContext.getNamespaceHandler(); String uri = handler.getLinkUri(elem); if (uri != null) { if (uri.length() > 1 && uri.charAt(0) == '#') { String anchor = uri.substring(1); Box target = _sharedContext.getBoxById(anchor); if (target != null) { PdfDestination dest = createDestination(c, target); if (dest != null) { PdfAction action = new PdfAction(); if (!"".equals(handler.getAttributeValue(elem, "onclick"))) { action = PdfAction.javaScript(handler.getAttributeValue(elem, "onclick"), _writer); } else { action.put(PdfName.S, PdfName.GOTO); action.put(PdfName.D, dest); }/* ww w . j av a 2s .c o m*/ com.lowagie.text.Rectangle targetArea = checkLinkArea(c, box); if (targetArea == null) { return; } targetArea.setBorder(0); targetArea.setBorderWidth(0); PdfAnnotation annot = new PdfAnnotation(_writer, targetArea.getLeft(), targetArea.getBottom(), targetArea.getRight(), targetArea.getTop(), action); annot.put(PdfName.SUBTYPE, PdfName.LINK); annot.setBorderStyle(new PdfBorderDictionary(0.0f, 0)); annot.setBorder(new PdfBorderArray(0.0f, 0.0f, 0)); _writer.addAnnotation(annot); } } } else if (uri.indexOf("://") != -1) { PdfAction action = new PdfAction(uri); com.lowagie.text.Rectangle targetArea = checkLinkArea(c, box); if (targetArea == null) { return; } PdfAnnotation annot = new PdfAnnotation(_writer, targetArea.getLeft(), targetArea.getBottom(), targetArea.getRight(), targetArea.getTop(), action); annot.put(PdfName.SUBTYPE, PdfName.LINK); annot.setBorderStyle(new PdfBorderDictionary(0.0f, 0)); annot.setBorder(new PdfBorderArray(0.0f, 0.0f, 0)); _writer.addAnnotation(annot); } } } }
From source file:org.xhtmlrenderer.pdf.RadioButtonFormField.java
License:Open Source License
private void createField(RenderingContext c, ITextOutputDevice outputDevice, PdfContentByte cb, PdfWriter writer, PdfFormField group, RadioButtonFormField fieldElem, RadioButtonFormField checked) { Box box = fieldElem.getBox(); Element e = box.getElement(); String onValue = getValue(e); float width = outputDevice.getDeviceLength(fieldElem.getWidth()); float height = outputDevice.getDeviceLength(fieldElem.getHeight()); PdfFormField field = PdfFormField.createEmpty(writer); FSColor color = box.getStyle().getColor(); FSColor darker = box.getEffBackgroundColor(c).darkenColor(); createAppearances(cb, field, onValue, width, height, true, color, darker); createAppearances(cb, field, onValue, width, height, false, color, darker); field.setWidget(outputDevice.createTargetArea(c, box), PdfAnnotation.HIGHLIGHT_INVERT); // XXX createTargetArea already looks up the page, but hopefully a document // won't have enough radio buttons to matter Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); PageBox page = c.getRootLayer().getPage(c, bounds.y); field.setPlaceInPage(page.getPageNo() + 1); field.setBorderStyle(new PdfBorderDictionary(0.0f, 0)); field.setAppearanceState(fieldElem == checked ? onValue : OFF_STATE); if (isReadOnly(e)) { field.setFieldFlags(PdfFormField.FF_READ_ONLY); }/*from www. ja v a 2 s. c om*/ group.addKid(field); }