List of usage examples for com.lowagie.text ElementTags ITEXT
String ITEXT
To view the source code for com.lowagie.text ElementTags ITEXT.
Click Source Link
From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java
License:Open Source License
private int createPasswordLetterContent(DocumentPrintContext dpc) throws ContentCreationException { IWBundle iwb = getIWApplicationContext().getIWMainApplication() .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER); System.out.println("Default locale: " + getIWApplicationContext().getApplicationSettings().getDefaultLocale().toString()); String sAddrString = ""; PdfContentByte cb = dpc.getPdfWriter().getDirectContent(); Document document = dpc.getDocument(); Locale locale = dpc.getLocale(); PrintMessage msg = dpc.getMessage(); // String mail_zip = iwb.getProperty("commune.mail_zip"); // String mail_name = iwb.getProperty("commune.mail_name"); try {// w w w. j a v a 2 s . co m sAddrString = getAddressString(dpc.getMessage().getOwner()); } catch (Exception nouser) { handleNoAddressUser(); System.err.println(nouser.getMessage()); // nouser.printStackTrace(); return ADDRESS_ERROR; } try { if (addTemplateHeader()) { ColumnText ct = new ColumnText(cb); float margin = getPointsFromMM(14); float lly = getPointsFromMM(297 - 22); float ury = lly + 60f; float urx = 595f - margin - 60f - 5f; float llx = 110f + margin; Phrase Ph0 = new Phrase(sAddrString, new Font(Font.HELVETICA, 12, Font.BOLD)); ct.setSimpleColumn(Ph0, llx, lly, urx, ury, 15, Element.ALIGN_LEFT); ct.go(); document.add(new Paragraph("\n\n\n\n\n\n\n")); } { User owner = msg.getOwner(); HashMap tagmap = new CommuneUserTagMap(getIWApplicationContext(), owner); tagmap.putAll(getMessageTagMap(msg, locale)); XmlPeer date = new XmlPeer(ElementTags.CHUNK, "date"); date.setContent(new IWTimestamp().getDateString("dd.MM.yyyy")); tagmap.put(date.getAlias(), date); System.out.println("Date tag: " + date.getTag()); String letterUrl = getXMLLetterUrl(iwb, locale, "password_letter.xml"); if (msg.getBody().indexOf("|") > 0) { StringTokenizer tokenizer = new StringTokenizer(msg.getBody(), "|"); XmlPeer peer = new XmlPeer(ElementTags.ITEXT, "letter"); tagmap.put(peer.getAlias(), peer); if (tokenizer.hasMoreTokens()) { peer = new XmlPeer(ElementTags.CHUNK, "username"); peer.setContent(tokenizer.nextToken()); tagmap.put(peer.getAlias(), peer); } if (tokenizer.hasMoreTokens()) { peer = new XmlPeer(ElementTags.CHUNK, "password"); peer.setContent(tokenizer.nextToken()); tagmap.put(peer.getAlias(), peer); } } javax.xml.parsers.SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); SAXmyHandler handler = new SAXmyHandler(document, tagmap); handler.setControlOpenClose(false); parser.parse(letterUrl, handler); } } catch (Exception e) { throw new ContentCreationException(e); } return 0; }
From source file:org.apache.maven.doxia.docrenderer.itext.AbstractITextRender.java
License:Apache License
/** * Merge all iTextFiles to a single one/*w ww . j a v a2s . com*/ * * @param iTextFiles * @return a document * @throws org.apache.maven.doxia.docrenderer.DocumentRendererException if any * @throws java.io.IOException if any */ private Document generateDocument(List<File> iTextFiles) throws DocumentRendererException, IOException { Document document; try { document = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new DocumentRendererException("Error building document :" + e.getMessage()); } document.appendChild(document.createElement(ElementTags.ITEXT)); // Used only to set a root for (File iTextFile : iTextFiles) { Document iTextDocument; try { iTextDocument = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().parse(iTextFile); } catch (SAXException e) { throw new DocumentRendererException("SAX Error : " + e.getMessage()); } catch (ParserConfigurationException e) { throw new DocumentRendererException("Error parsing configuration : " + e.getMessage()); } // Only one chapter per doc Node chapter = iTextDocument.getElementsByTagName(ElementTags.CHAPTER).item(0); try { document.getDocumentElement().appendChild(document.importNode(chapter, true)); } catch (DOMException e) { throw new DocumentRendererException( "Error appending chapter for " + iTextFile + " : " + e.getMessage()); } } return document; }
From source file:org.apache.maven.doxia.docrenderer.pdf.itext.ITextPdfRenderer.java
License:Apache License
/** * Merge all iTextFiles to a single one. * * @param iTextFiles list of iText xml files. * @return Document./*ww w. jav a 2 s. c o m*/ * @throws DocumentRendererException if any. * @throws IOException if any. */ private Document generateDocument(List<File> iTextFiles) throws DocumentRendererException, IOException { Document document = DOCUMENT_BUILDER.newDocument(); document.appendChild(document.createElement(ElementTags.ITEXT)); // Used only to set a root for (File iTextFile : iTextFiles) { Document iTextDocument; try { iTextDocument = DOCUMENT_BUILDER.parse(iTextFile); } catch (SAXException e) { throw new DocumentRendererException("SAX Error : " + e.getMessage()); } // Only one chapter per doc Node chapter = iTextDocument.getElementsByTagName(ElementTags.CHAPTER).item(0); try { document.getDocumentElement().appendChild(document.importNode(chapter, true)); } catch (DOMException e) { throw new DocumentRendererException( "Error appending chapter for " + iTextFile + " : " + e.getMessage()); } } return document; }
From source file:org.apache.maven.doxia.module.itext.ITextSink.java
License:Apache License
/** {@inheritDoc} */ public void body() { if (writeStart) { writeStartElement(ElementTags.ITEXT); writeAddAttribute(ElementTags.TITLE, header.getTitle()); writeAddAttribute(ElementTags.AUTHOR, header.getAuthors()); writeAddAttribute(ElementTags.CREATIONDATE, header.getDate()); writeAddAttribute(ElementTags.SUBJECT, header.getTitle()); writeAddAttribute(ElementTags.KEYWORDS, ""); writeAddAttribute(ElementTags.PRODUCER, "Generated with Doxia by " + System.getProperty("user.name")); writeAddAttribute(ElementTags.PAGE_SIZE, ITextUtil.getPageSize(ITextUtil.getDefaultPageSize())); writeStartElement(ElementTags.CHAPTER); writeAddAttribute(ElementTags.NUMBERDEPTH, numberDepth); writeAddAttribute(ElementTags.DEPTH, depth); writeAddAttribute(ElementTags.INDENT, "0.0"); writeStartElement(ElementTags.TITLE); writeAddAttribute(ElementTags.LEADING, DEFAULT_CHAPTER_TITLE_LEADING); writeAddAttribute(ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME); writeAddAttribute(ElementTags.SIZE, ITextFont.getSectionFontSize(0)); writeAddAttribute(ElementTags.STYLE, ITextFont.BOLD); writeAddAttribute(ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE); writeAddAttribute(ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN); writeAddAttribute(ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED); writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER); // startChunk( ITextFont.DEFAULT_FONT_NAME, ITextFont.getSectionFontSize( 0 ), // ITextFont.BOLD, ITextFont.DEFAULT_FONT_COLOR_BLUE, ITextFont.DEFAULT_FONT_COLOR_GREEN, // ITextFont.DEFAULT_FONT_COLOR_RED, "top" ); writeStartElement(ElementTags.CHUNK); writeAddAttribute(ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME); writeAddAttribute(ElementTags.SIZE, ITextFont.getSectionFontSize(0)); writeAddAttribute(ElementTags.STYLE, ITextFont.BOLD); writeAddAttribute(ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE); writeAddAttribute(ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN); writeAddAttribute(ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED); // writeAddAttribute( ElementTags.LOCALDESTINATION, "top" ); write(header.getTitle());/*ww w . j a va2s . c o m*/ writeEndElement(); // ElementTags.CHUNK writeEndElement(); // ElementTags.TITLE } actionContext.setAction(SinkActionContext.BODY); }