Package org.docx4j.convert.out

Examples of org.docx4j.convert.out.HTMLSettings


      throw new Docx4JException("Must setWmlPackage");
    }
   
    if (htmlSettings==null) {
      log.debug("Using empty HtmlSettings");
      htmlSettings = new HTMLSettings();     
    }   
   
    try {
      html(wmlPackage, result, htmlSettings);
    } catch (Exception e) {
View Full Code Here


 
  private void toHTML(WordprocessingMLPackage wordMLPackage) throws Docx4JException {

    // Back to XHTML

    HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
    htmlSettings.setWmlPackage(wordMLPackage);

    // Sample sdt tag handler (tag handlers insert specific
    // html depending on the contents of an sdt's tag).
    // This will only have an effect if the sdt tag contains
    // the string class=
View Full Code Here

  protected HTMLSettings htmlSettings = null;
 
  public HtmlExporterNonXSLT(WordprocessingMLPackage wordMLPackage,
      ConversionImageHandler conversionImageHandler) {
   
    htmlSettings = new HTMLSettings();
    htmlSettings.setWmlPackage(wordMLPackage);
    htmlSettings.setImageHandler(conversionImageHandler);
  }
View Full Code Here

    super(writerRegistry, HTML_MESSAGE_WRITER, settings, preprocessedPackage, conversionSectionWrappers, createRunFontSelector(preprocessedPackage));
  }
 
  @Override
  protected void initializeSettings(AbstractConversionSettings settings, OpcPackage localOpcPackage) {
  HTMLSettings htmlSettings = null;
    if (settings == null) {
      settings = new HTMLSettings();
    }
    else if (!(settings instanceof HTMLSettings)) {
      throw new IllegalArgumentException("The class of the settings isn't HtmlSettings, it is " + settings.getClass().getName());
    }
    htmlSettings = (HTMLSettings)settings;
    super.initializeSettings(htmlSettings, localOpcPackage);
    fontMapper = htmlSettings.getFontMapper();
    if (fontMapper == null) {
      fontMapper = getWmlPackage().getFontMapper();
    }
    userCSS = htmlSettings.getUserCSS();
    userScript = htmlSettings.getUserScript();
    userBodyTop = htmlSettings.getUserBodyTop();
    userBodyTail = htmlSettings.getUserBodyTail();
    styleElementHandler = htmlSettings.getStyleElementHandler();
    if (styleElementHandler == null) {
      styleElementHandler = DEFAULT_STYLE_ELEMENT_HANDLER;
    }
    scriptElementHandler = htmlSettings.getScriptElementHandler();
    if (scriptElementHandler == null) {
      scriptElementHandler = DEFAULT_SCRIPT_ELEMENT_HANDLER;
    }
  }
View Full Code Here

    }
  }

  @Override
  protected ConversionImageHandler initializeImageHandler(AbstractConversionSettings settings, ConversionImageHandler handler) {
  HTMLSettings htmlSettings = (HTMLSettings)settings;
    if (handler == null) {
      handler = new HTMLConversionImageHandler(
            htmlSettings.getImageDirPath(),
            htmlSettings.getImageTargetUri(),
            htmlSettings.isImageIncludeUUID());
    }
    return handler;
  }
View Full Code Here

      wordMLPackage = Docx4J.load(new java.io.File(inputfilepath));
    }

    // HTML exporter setup (required)
    // .. the HTMLSettings object
      HTMLSettings htmlSettings = Docx4J.createHTMLSettings();

      htmlSettings.setImageDirPath(inputfilepath + "_files");
      htmlSettings.setImageTargetUri(inputfilepath.substring(inputfilepath.lastIndexOf("/")+1)
          + "_files");
      htmlSettings.setWmlPackage(wordMLPackage);
     
     
      /* CSS reset, see http://itumbcom.blogspot.com.au/2013/06/css-reset-how-complex-it-should-be.html
       *
       * motivated by vertical space in tables in Firefox and Google Chrome.
       
          If you have unwanted vertical space, in Chrome this may be coming from -webkit-margin-before and -webkit-margin-after
          (in Firefox, margin-top is set to 1em in html.css)
         
          Setting margin: 0 on p is enough to fix it.
         
          See further http://www.css-101.org/articles/base-styles-sheet-for-webkit-based-browsers/     
      */
      String userCSS = "html, body, div, span, h1, h2, h3, h4, h5, h6, p, a, img,  ol, ul, li, table, caption, tbody, tfoot, thead, tr, th, td " +
          "{ margin: 0; padding: 0; border: 0;}" +
          "body {line-height: 1;} ";
      htmlSettings.setUserCSS(userCSS);
     
     
      //Other settings (optional)
//      htmlSettings.setUserBodyTop("<H1>TOP!</H1>");
//      htmlSettings.setUserBodyTail("<H1>TAIL!</H1>");
View Full Code Here

  /**
   *  Create the configuration object for conversions to html
   */ 
  public static HTMLSettings createHTMLSettings() {
    return new HTMLSettings();
  }
View Full Code Here

  public static void toHTML(WordprocessingMLPackage wmlPackage, String imageDirPath, String imageTargetUri, OutputStream outputStream) throws Docx4JException {

    StartEvent startEvent = new StartEvent( wmlPackage, WellKnownProcessSteps.HTML_OUT );
    startEvent.publish();
   
    HTMLSettings settings = createHTMLSettings();
    settings.setWmlPackage(wmlPackage);
    if (imageDirPath != null) {
      settings.setImageDirPath(imageDirPath);
    }
    if (imageTargetUri != null) {
      settings.setImageTargetUri(imageTargetUri);
    }
    toHTML(settings, outputStream, FLAG_NONE);
   
    new EventFinished(startEvent).publish();
  }
View Full Code Here

                } else {
                    Docx4J.toPDF(wordprocessingMLPackage, outputStream);
                    outputStream.flush();
                }
            } else if (ReportOutputType.html.equals(reportTemplate.getOutputType())) {
                HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
                htmlSettings.setWmlPackage(wordprocessingMLPackage);
                Docx4J.toHTML(htmlSettings, outputStream, Docx4J.FLAG_NONE);
                outputStream.flush();
            } else {
                throw new UnsupportedOperationException(String.format("DocxFormatter could not output file with type [%s]", reportTemplate.getOutputType()));
            }
View Full Code Here

      wordMLPackage = Docx4J.load(new java.io.File(inputfilepath));
    }

    // HTML exporter setup (required)
    // .. the HTMLSettings object
      HTMLSettings htmlSettings = Docx4J.createHTMLSettings();

      htmlSettings.setImageDirPath(inputfilepath + "_files");
      htmlSettings.setImageTargetUri(inputfilepath.substring(inputfilepath.lastIndexOf("/")+1)
          + "_files");
      htmlSettings.setWmlPackage(wordMLPackage);
     
     
      /* CSS reset, see http://itumbcom.blogspot.com.au/2013/06/css-reset-how-complex-it-should-be.html
       *
       * motivated by vertical space in tables in Firefox and Google Chrome.
       
          If you have unwanted vertical space, in Chrome this may be coming from -webkit-margin-before and -webkit-margin-after
          (in Firefox, margin-top is set to 1em in html.css)
         
          Setting margin: 0 on p is enough to fix it.
         
          See further http://www.css-101.org/articles/base-styles-sheet-for-webkit-based-browsers/     
      */
      String userCSS = "html, body, div, span, h1, h2, h3, h4, h5, h6, p, a, img,  ol, ul, li, table, caption, tbody, tfoot, thead, tr, th, td " +
          "{ margin: 0; padding: 0; border: 0;}" +
          "body {line-height: 1;} ";
      htmlSettings.setUserCSS(userCSS);
         
    // output to an OutputStream.   
    OutputStream os;
    os = new FileOutputStream(inputfilepath + ".html");

View Full Code Here

TOP

Related Classes of org.docx4j.convert.out.HTMLSettings

Copyright © 2018 www.massapicom. 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.