Examples of DocumentBuilder


Examples of com.aspose.words.DocumentBuilder

      // System.out.printf("Process request from : %s\n", request
      // .getRemoteAddr());
      /* Create a simple document */
      long start = System.currentTimeMillis();
      Document wordDoc = new Document();
      DocumentBuilder wordDocBuilder = new DocumentBuilder(wordDoc);
      // Add Header / Footer
      wordDocBuilder.getPageSetup().setDifferentFirstPageHeaderFooter(
          false);
      wordDocBuilder.getPageSetup().setOddAndEvenPagesHeaderFooter(false);
      wordDocBuilder.getPageSetup().setHeaderDistance(20);
      wordDocBuilder.getPageSetup().setFooterDistance(20);
      wordDocBuilder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
      wordDocBuilder.writeln("My HEADER");
      wordDocBuilder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
      wordDocBuilder.writeln("My FOOTER");
      wordDocBuilder.moveToDocumentEnd();
      // Set font properties
      wordDocBuilder.setBold(true);
      wordDocBuilder.setItalic(true);
      // Add text
      wordDocBuilder.writeln("My Text");
      wordDocBuilder.writeln();
      // Add end footer note and foot note
      wordDocBuilder.insertFootnote(FootnoteType.ENDNOTE, "My End Note");
      wordDocBuilder
          .insertFootnote(FootnoteType.FOOTNOTE, "My Foot Note");
      wordDocBuilder.writeln();
      // Add hyperlink
      wordDocBuilder.insertHyperlink("LINK", "http://www.google.lu",
          false);
      wordDocBuilder.writeln();
      // Add a table
      wordDocBuilder.startTable();
      // --Row 1 with 2 cell
      Cell cell = wordDocBuilder.insertCell();
      cell.getCellFormat().setVerticalAlignment(
          CellVerticalAlignment.CENTER);
      wordDocBuilder.writeln("Row 1 Cell 1 Text");
      cell = wordDocBuilder.insertCell();
      cell.getCellFormat().setVerticalAlignment(
          CellVerticalAlignment.CENTER);
      wordDocBuilder.writeln("Row 1 Cell 2 Text");
      wordDocBuilder.endRow();
      // --Row 2 with 2 cell
      cell = wordDocBuilder.insertCell();
      cell.getCellFormat().setVerticalAlignment(
          CellVerticalAlignment.BOTTOM);
      wordDocBuilder.writeln("Row 2 Cell 1 Text");
      cell = wordDocBuilder.insertCell();
      cell.getCellFormat()
          .setVerticalAlignment(CellVerticalAlignment.TOP);
      wordDocBuilder.writeln("Row 2 Cell 2 Text");
      wordDocBuilder.endRow();
      // --Row 3 with 3 cell merged
      cell = wordDocBuilder.insertCell();
      cell.getCellFormat().setVerticalAlignment(
          CellVerticalAlignment.CENTER);
      cell.getCellFormat().setOrientation(TextOrientation.HORIZONTAL);
      cell.getCellFormat().setHorizontalMerge(CellMerge.FIRST);
      wordDocBuilder.writeln("Row 3 Cell 3 Text");
      cell = wordDocBuilder.insertCell();
      cell.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);
      wordDocBuilder.endRow();
      wordDocBuilder.endTable();
      // Add Comment
      Comment comment = new Comment(wordDoc);
      comment.setAuthor("D.Righetto");
      comment.getParagraphs().add(new Paragraph(wordDoc));
      comment.getFirstParagraph().getRuns().add(
          new Run(wordDoc, "My Comment text !!!"));
      wordDocBuilder.getCurrentParagraph().appendChild(comment);
      // Add break
      wordDocBuilder.insertBreak(BreakType.PAGE_BREAK);
      // Add image
      String imgUrl = "http://" + request.getServerName() + ":"
          + request.getServerPort() + request.getContextPath()
          + "/img/AsposeWords.gif";
      // System.out.printf("Insert image from : %s\n", imgUrl);
      wordDocBuilder.insertImage(imgUrl);
      System.out.printf("Document generated in %s ms\n", (System
          .currentTimeMillis() - start));

      /* Send document to client */
      response.setContentType("application/vnd.ms-word");
 

Examples of com.dotcms.repackage.javax.xml.parsers.DocumentBuilder

      VelocityEngine ve = VelocityUtil.getEngine();
      ve.getTemplate("/" + location + "/" + pageIdent + "." + VELOCITY_HTMLPAGE_EXTENSION).merge(context, sw);
      ITextRenderer renderer = new ITextRenderer();
      DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
      documentBuilderFactory.setValidating(false);
      DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
      builder.setEntityResolver(new DTDResolver());
      String s = sw.toString();
      s = escapeEspecialCharacter(s);

      s = processCSSPath(s, host, "css", "\\(", "\\)", ")", url);
      s = processCSSPath(s, host, "css", "\\\"", "\\\"", "\"", url);
      Tidy tidy = new Tidy();
      tidy.setXHTML(true);

      ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes());
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      tidy.parse(is, os);
      s = os.toString();

      is = new ByteArrayInputStream(s.getBytes());
      Document doc = builder.parse(is);

      NodeList nl = doc.getElementsByTagName("img");
      for (int i = 0; i < nl.getLength(); i++) {
        Node n = nl.item(i);
        Node srcNode = n.getAttributes().getNamedItem("src");

Examples of com.greplin.lucene.document.DocumentBuilder

  @Test
  public void testBasics() throws Exception {
    IndexWriter writer = new IndexWriter(this.directory,
        new IndexWriterConfig(
            Version.LUCENE_35, new WhitespaceAnalyzer(Version.LUCENE_35)));
    writer.addDocument(new DocumentBuilder().add("value", "5").build());
    writer.close();

    IndexReader reader = IndexReader.open(this.directory);
    IndexSearcher searcher = new IndexSearcher(reader);

Examples of com.tridion.tcdl.DocumentBuilder

  }

  public String evaluateBody(String originalBody, TransformContext context) throws TCDLTransformerException {
    StringWriter writer = new StringWriter();
    TagHandlerRegistry registry = getHandlerRegistry();
    DocumentBuilder documentBuilder = getDocumentBuilder();
    OutputDocument output = new OutputDocument();
    TagDispatcher dispatcher = new TagDispatcher(context, output, registry);
    TCDLParser parser = new TCDLParser(registry.getNamespaceList(), null);
    parser.parse(dispatcher, originalBody);
    documentBuilder.buildDocument(context, output, writer);
    return writer.toString();
  }

Examples of flex2.compiler.mxml.builder.DocumentBuilder

    DocumentInfo info = (DocumentInfo)unit.getContext().removeAttribute(MxmlCompiler.DOCUMENT_INFO);
    assert info != null;

    //  build MxmlDocument from MXML DOM
    MxmlDocument document = new MxmlDocument(unit, typeTable, info, mxmlConfiguration);
        DocumentBuilder builder = new DocumentBuilder(unit, typeTable, mxmlConfiguration, document);
    app.analyze(builder);

        if (ThreadLocalToolkit.errorCount() > 0)
        {
            return null;

Examples of hu.jokeman.xparser.document.DocumentBuilder

        _name.append ((char) firstChar);
    }

  public ParserState process (int ch) throws ParserException {
        char c = (char) ch;
        DocumentBuilder builder = getDocumentBuilder ();
       
    if (_isShort && c != '>') {
      throw new ParserException ("Invalid short tag.");
    }
       
    if (XMLCharacterSet.isNameChar (c)) {
      if (_isAdded) {
        return new AttributeState (builder, this, ch);
      }
      _name.append (c);
            return this;
    }
       
        if (XMLCharacterSet.isWhiteSpace (c)) {
      if (!_isAdded) {
        builder.createTagStart (_name.toString ());
        _isAdded = true;
      }
      return this;
    }
       
        if (c == '/') {
      _isShort = true;
      return this;
    }
       
        if (c == '>') {
      if (!_isAdded) {
        builder.createTagStart (_name.toString ());
      }
      builder.finishTagStart ();
      if (_isShort) {
        builder.addTagClose (_name.toString ());
      }
      return new NormalState (builder);
    }
   
    throw new ParserException ("Illegal character '" + c + "'.");

Examples of javax.xml.parsers.DocumentBuilder

   */
  protected org.w3c.dom.Element createMessage() {
    org.w3c.dom.Element ret=null;
   
    try {
      DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
     
      Document doc=builder.newDocument();
     
      ret = doc.createElement(TOP_LEVEL_ELEMENT_NAME);
     
    } catch(Exception e) {
      logger.error("Failed to create message", e);

Examples of javax.xml.parsers.DocumentBuilder

    try {
      // Transform the text representation to DOM
      DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
      fact.setNamespaceAware(true);
     
      DocumentBuilder builder=fact.newDocumentBuilder();
     
      // Check if XML document, and if not return as text node
      if (text.trim().length() == 0 || text.charAt(0) != '<') {
        org.w3c.dom.Document doc=builder.newDocument();
       
        // Assume is text node
        ret = doc.createTextNode(text);
      } else {
        java.io.InputStream xmlstr=
          new java.io.ByteArrayInputStream(text.getBytes());

        org.w3c.dom.Document doc=builder.parse(xmlstr);
       
        xmlstr.close();
     
        ret = doc.getDocumentElement();
      }

Examples of javax.xml.parsers.DocumentBuilder

public class XmlUtil {
    private static final DocumentBuilderFactory domBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
    private static final WeakHashMap domBuilders = new WeakHashMap();

    private static synchronized DocumentBuilder getDocumentBuilder() {
        DocumentBuilder domBuilder = (DocumentBuilder) domBuilders.get(Thread.currentThread());

        if (domBuilder != null) {
            return domBuilder;
        } else {
            try {

Examples of javax.xml.parsers.DocumentBuilder

     *
     *
     * @return ...
     */
    public static Document newDocument() {
        DocumentBuilder d = getDocumentBuilder();

        return d.newDocument();
    }
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.