List of usage examples for com.lowagie.text.pdf PdfString PdfString
public PdfString(String value, String encoding)
PdfString
-object containing a string in the specified encoding. From source file:net.sf.jasperreports.engine.export.PdfGlyphRenderer.java
License:Open Source License
@Override public void draw() { if (addActualText) { PdfDictionary markedContentProps = new PdfDictionary(); markedContentProps.put(PdfName.ACTUALTEXT, new PdfString(allText, PdfObject.TEXT_UNICODE)); pdfContentByte.beginMarkedContentSequence(PdfName.SPAN, markedContentProps, true); }/*from w w w .j av a 2 s.c o m*/ TabSegment segment = segments.get(segmentIndex); segment.layout.draw(pdfGraphics2D, x + drawPosX, // + leftPadding, y + topPadding + verticalAlignOffset + drawPosY); if (addActualText) { pdfContentByte.endMarkedContentSequence(); } return; }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfLogicalPageDrawable.java
License:Open Source License
protected void drawImageMap(final RenderableReplacedContentBox content) { if (version < '6') { return;/*from www . j a v a 2 s. c om*/ } final ImageMap imageMap = RenderUtility.extractImageMap(content); // only generate a image map, if the user does not specify their own onw via the override. // Of course, they would have to provide the map by other means as well. if (imageMap == null) { return; } final ImageMapEntry[] imageMapEntries = imageMap.getMapEntries(); for (int i = 0; i < imageMapEntries.length; i++) { final ImageMapEntry imageMapEntry = imageMapEntries[i]; final String link = imageMapEntry.getAttribute(LibXmlInfo.XHTML_NAMESPACE, "href"); final String tooltip = imageMapEntry.getAttribute(LibXmlInfo.XHTML_NAMESPACE, "title"); if (StringUtils.isEmpty(tooltip)) { continue; } final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final int x = (int) (translateX + StrictGeomUtility.toExternalValue(content.getX())); final int y = (int) StrictGeomUtility.toExternalValue(content.getY()); final float[] translatedCoords = translateCoordinates(imageMapEntry.getAreaCoordinates(), x, y); final PolygonAnnotation polygonAnnotation = new PolygonAnnotation(writer, translatedCoords); polygonAnnotation.put(PdfName.CONTENTS, new PdfString(tooltip, PdfObject.TEXT_UNICODE)); writer.addAnnotation(polygonAnnotation); } }
From source file:org.sejda.impl.itext.component.FormFieldsAwarePdfCopier.java
License:Apache License
public FormFieldsAwarePdfCopier(File outputFile, PdfVersion version) throws TaskException { try {//from w w w . j ava2 s . co m outputStream = new FileOutputStream(outputFile); if (version == null) { pdfCopy = new PdfCopyFields(outputStream); } else { pdfCopy = new PdfCopyFields(outputStream, version.getVersionAsCharacter()); } pdfCopy.getWriter().getInfo().put(PdfName.CREATOR, new PdfString(Sejda.CREATOR, PdfObject.TEXT_UNICODE)); } catch (FileNotFoundException e) { throw new TaskException(String.format("Unable to find the output file %s", outputFile.getPath()), e); } catch (DocumentException e) { throw new TaskException("An error occurred opening the PdfCopyFields.", e); } }
From source file:org.xhtmlrenderer.pdf.ITextOutputDevice.java
License:Open Source License
private void writeNamedDestinations(RenderingContext c) { Map idMap = getSharedContext().getIdMap(); if ((idMap != null) && (!idMap.isEmpty())) { PdfArray dests = new PdfArray(); try {/*from w w w. j a v a 2 s . c o m*/ Iterator it = idMap.entrySet().iterator(); while (it.hasNext()) { Entry entry = (Entry) it.next(); Box targetBox = (Box) entry.getValue(); if (targetBox.getStyle().isIdent(CSSName.FS_NAMED_DESTINATION, IdentValue.CREATE)) { String anchorName = (String) entry.getKey(); dests.add(new PdfString(anchorName, PdfString.TEXT_UNICODE)); PdfDestination dest = createDestination(c, targetBox); if (dest != null) { PdfIndirectReference ref = _writer.addToBody(dest).getIndirectReference(); dests.add(ref); } } } if (!dests.isEmpty()) { PdfDictionary nametree = new PdfDictionary(); nametree.put(PdfName.NAMES, dests); PdfIndirectReference nameTreeRef = _writer.addToBody(nametree).getIndirectReference(); PdfDictionary names = new PdfDictionary(); names.put(PdfName.DESTS, nameTreeRef); PdfIndirectReference destinationsRef = _writer.addToBody(names).getIndirectReference(); _writer.getExtraCatalog().put(PdfName.NAMES, destinationsRef); } } catch (IOException e) { throw new RuntimeException(e); } } }
From source file:org.xhtmlrenderer.pdf.util.XHtmlMetaToPdfInfoAdapter.java
License:Open Source License
private void parseHtmlMetaTags(Document doc) { NodeList headNodeList = doc.getDocumentElement().getElementsByTagName(HTML_TAG_HEAD); XRLog.render(Level.FINEST, "headNodeList=" + headNodeList); Element rootHeadNodeElement = (Element) headNodeList.item(0); NodeList metaNodeList = rootHeadNodeElement.getElementsByTagName(HTML_TAG_META); XRLog.render(Level.FINEST, "metaNodeList=" + metaNodeList); for (int inode = 0; inode < metaNodeList.getLength(); ++inode) { XRLog.render(Level.FINEST, "node " + inode + " = " + metaNodeList.item(inode).getNodeName()); Element thisNode = (Element) metaNodeList.item(inode); XRLog.render(Level.FINEST, "node " + thisNode); String metaName = thisNode.getAttribute(HTML_META_ATTR_NAME); String metaContent = thisNode.getAttribute(HTML_META_ATTR_CONTENT); XRLog.render(Level.FINEST, "metaName=" + metaName + ", metaContent=" + metaContent); if (metaName.length() != 0 && metaContent.length() != 0) { PdfName pdfName = null;/* w w w . jav a 2 s.co m*/ PdfString pdfString = null; if (HTML_META_KEY_TITLE.equalsIgnoreCase(metaName) || HTML_META_KEY_DC_TITLE.equalsIgnoreCase(metaName)) { pdfName = PdfName.TITLE; pdfString = new PdfString(metaContent, PdfObject.TEXT_UNICODE); this.pdfInfoValues.put(pdfName, pdfString); } else if (HTML_META_KEY_CREATOR.equalsIgnoreCase(metaName) || HTML_META_KEY_DC_CREATOR.equalsIgnoreCase(metaName)) { pdfName = PdfName.AUTHOR; pdfString = new PdfString(metaContent, PdfObject.TEXT_UNICODE); this.pdfInfoValues.put(pdfName, pdfString); } else if (HTML_META_KEY_SUBJECT.equalsIgnoreCase(metaName) || HTML_META_KEY_DC_SUBJECT.equalsIgnoreCase(metaName)) { pdfName = PdfName.SUBJECT; pdfString = new PdfString(metaContent, PdfObject.TEXT_UNICODE); this.pdfInfoValues.put(pdfName, pdfString); } else if (HTML_META_KEY_KEYWORDS.equalsIgnoreCase(metaName)) { pdfName = PdfName.KEYWORDS; pdfString = new PdfString(metaContent, PdfObject.TEXT_UNICODE); this.pdfInfoValues.put(pdfName, pdfString); } } } }