Sferyx JSyndrome DOCXGenerator and Converter Component

Generate dynamically and convert easily HTML, RTF, Plain Text and Images to DOCX in your Java applications and merge multiple DOCX files together automatically


Advanced Java HTML, RTF, Plain Text to DOCX Generator and Converter component - convert easily HTML files to Microsoft Word DOCX, Rich Text Format to Microsoft Word DOCX and create DOCX documents dynamically from various formats and sources. Merge different file types including multiple DOCX files into single DOCX document.

Sferyx DOCXGenerator Component is an advanced and powerful Java HTML, RTF and Text to DOCX Generator and Converter component. It can convert easily HTML and RTF to Microsoft Word Docx in any Java Application - Java Swing, JavaFX, SWT Eclipse and also Oracle Forms and produces perfectly formatted documents embedding all external images. It will include at the beginning and at the end the headers and footers and will insert also the existing page breaks from the original documents. With only a few lines of Java code is possible to generate complex DOCX files from almost any HTML source or location, any RTF file, plain text documents and also different image types such as JPEG, TIFF, BMP, PNG, GIF - all these images will be embedded automatically inside the DOCX and saved as DOCX documents. The resulting DOCX can be written to a local file, java.io.OutputStream or shown automatically inside the default viewer. The HTML and RTF to DOCX Converter Java component supports all UTF-8 languages including support for Greek, Arabic, Cyrillic, Hebrew, Farsi, Chinese, Japanese, Hindi, Tamil and more. The Sferyx DOCXGenerator and Converter component is ready for use out of the box and does not depend on external packages.

You can create DOCX files dynamically by adding the content on-the-fly from different formats and sources.

Convert Docx, RTF and Text to HTML in Java

 

All Sferyx products are signed with  
Trusted Code Signing Security Certificate from Thawte

Download Sferyx HTMLGenerator Java Docx and RTF to HTML Component Buy Java Docx and RTF to HTML Generator and Converter Component
Version 23.0

Sferyx JSyndrome DOCXGenerator and Converter Component Edition: DOCXGeneratorDemo.zip
 
 
 

 

  • Pure Java HTML, RTF to DOCX Generation engine - allows fast and easy DOCX creation from various sources and also convert even very complex HTML and RTF documents with single line of code - 100% in house development - it does not depend on external packages.
  • Converts and generates quickly and easily DOCX files directly from HTML documents
  • Converts and generates quickly and easily DOCX files directly from Rich Text Format RTF documents
  • Creates self contained DOCX files directly from JPEG, TIFF, BMP, GIF, PNG etc - all images will be embedded inside the DOCX.
  • Royalty free redistribution with your applications
  • Inclusion of all images including the inline Base64 encoded images, inline and linked CSS styles etc.
  • Works with any JRE/ JDK 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17 or higher
  • Support for Oracle Forms and full generation of DOCX from HTML and RTF from Oracle Forms and CLOB 
  • Fully compatible with Java Swing, JavaFX, SWT Eclipse, Oracle Forms, Java Servlets, JSP
  • Compatible with Headless mode for server systems
  • Compact size and fast document generation
  • Now all hyperlinks inside the HTML and RTF documents are generated as links (annotations) automatically into the resulting DOCX file
  • Support for disabling the table breaking across multiple pages
  • Support for disabling lists breaking across multiple pages
  • Support for the CSS page break elements page-break-before:always, page-break-after:always, page-break-inside:never

 

Example usage


The use of the DOCXGenerator component is quite simple - with only a few lines of code is possible to generate and convert practically any HTML, RTF, Text or Images to DOCX documents. Simply add the DOCXGenerator.jar to your CLASSPATH and start generating.

Here are some examples of converting the different document types:

Convert HTML to Word Docx to from URL to File

This method will convert the Docx to HTML and will save it to given file. The destinationFile parameter is a java.io.File object:

 

import sferyx.administration.docxgenerator.*;

DOCXGenerator docxGenerator=new DOCXGenerator ();
docxGenerator.generateDOCXFromHTMLURL ("http://your_url_here.htm", destinationFile);

or using the file name as String:

 

import sferyx.administration.docxGenerator.*;

DOCXGenerator docxGenerator=new DOCXGenerator ();
docxGenerator.generateDOCXFromHTMLURL ("http://your_url_here.docx", "c:/docxgenerator-test1.docx");

Convert HTML to Word Docx from URL to OutputStream

It will convert the specified HTML document to DOCX using the standard page format string such as "A4", "Letter" etc. and and save it to the specified OutputStream. This method will recognize automatically if the document is HTML file and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like htm or html.

 

docxGenerator.generateDOCXFromHTMLURL ("http://your_url_here/file.htm", destinationStream);


 

Convert Rich Text Format RTF to DOCX from URL to File

This method will convert the RTF to DOCX and will save it to given file. The destinationFile parameter is a java.io.File object:

 

import sferyx.administration.htmlgenerator.*;

DOCXGenerator docxGenerator=new DOCXGenerator ();
docxGenerator.generateDOCXFromRTFURL ("http://your_url_here.rtf", destinationFile);

or using the file name as String:

 

import sferyx.administration.docxGenerator.*;

DOCXGenerator docxGenerator=new DOCXGenerator ();
docxGenerator.generateHTMLFromRTFURL ("http://your_url_here.rtf", "c:/docxgenerator-test1.docx");

 

Convert Rich Text Format RTF to DOCX from URL to OutputStream

It will convert the specified RTF document to DOCX and and save it to the specified OutputStream. To use this automatic conversion the URL must end with the corresponding extension like rtf.

 

docxGenerator.generateDOCXFromRTFURL ("http://your_url_here/file.rtf", destinationStream);

Convert automatically HTML, RTF, Plain Text or Images to DOCX using the method generateHTMLFromURL


This method will recognize automatically from the file extension if the document is HTML file, RTF file, Text or images and will convert it accordingly. The output can be saved to java.io.File, java.io.OutputStream etc. To use this automatic conversion the URL must end with the corresponding extension like htm, rtf, txt etc. 
 

docxGenerator.generateDOCXFromURL ("http://your_url_here/file.rtf", "c:/docxgenerator-test1.docx");

 

Dynamically Generate DOCX from HTML, DOCX, RTF, Plain Text, Images and merge multiple different file types into single DOCX document in Java with the Sferyx DOCXGenerator

You can generate even very complex DOCX documents dynamically in your Java application by simply providing all the formatting in HTML and inserting page breaks when new pages are needed - the DOCXGenerator will take care automatically for all the pagination of long formatted text spanning through multiple pages and also tables, lists etc. This functionality is perfect for creating various reports and other documents which need to be generated dynamically with rich text formatting. You can insert dynamically also Docx files which will be converted and merged automatically into single DOCX file. You can merge Rich Text Format, DOCX, HTML, images, Plain Text etc. - everything will be converted automatically and saved as DOCX into a single document.

 
import sferyx.administration.docxgenerator.*;

DOCXGenerator docxGenerator=new DOCXGenerator();
//Open the content buffer to  insert the content - HTML, Docx, RTF, Text etc - everything can be merged together.

docxGenerator.openContentBuffer();
//Append the content to the content buffer - you can insert styles, images and any kind of formatting.

docxGenerator.appendHTMLContentToContentBuffer("<style>body{font-size:12pt;color:blue;} h1{background-color:yellow;}</style>");
docxGenerator.appendHTMLContentToContentBuffer("<h1>This is H1 header</h1>Some other text <b>very important <i>stuff</i></b> with page break after");
//Insert page break to create new page - the HTMLGenerator will handle automatically all the pagination for long text if more pages are needed, tables and everything.
docxGenerator.addPageBreakToContentBuffer();
//Append the content for the new page.

docxGenerator.appendHTMLContentToContentBuffer("<h2 style=\"background-color:green;border-bottom:1px solid red;color:white\">This is second H2 header</h2>Some other text <span style=\"color:orange\">extremely interesting <u>stuff</u></b></span><br>");
//Append Plain Text Content
docxGenerator.appendPlainTextContentToContentBuffer("Here we put some plain text\nin new line other text\n\ttab space other stuff here... with page break after");
//Insert another page break...
docxGenerator.addPageBreakToContentBuffer();
docxGenerator.appendHTMLContentToContentBuffer("<style>table{border-collapse:collapse;} td{border:1px solid red;}</style>");
//Create table dynamically...
docxGenerator.appendHTMLContentToContentBuffer("<table style=\"border:1px solid black;\" ><tr><td>row 1 col 1</td><td>row 1 col 2</td></tr><tr><td style=\"background-color:yellow\">row 2 col 1</td><td>row 2 col 2</td></tr></table> with page break after the table");
//Insert another page break...

docxGenerator.addPageBreakToContentBuffer();
docxGenerator.appendHTMLContentToContentBuffer("<h1 style=\"border-bottom:1px solid orange;\">Some other text here and the beginning of the Docx file:</h1>");
....
docxGenerator.addPageBreakToContentBuffer();
....
//Append MS Word Docx file directly to the content buffer and it will be converted to DOCX in the same document
docxGenerator.appendDocxToContentBuffer(new java.net.URL("file:///c:/test/demo.docx"));
...
//Append Rich Text Format RTF file directly to the content buffer and it will be converted to DOCX in the same document
docxGenerator.appendRTFFileToContentBuffer(new java.net.URL("file:///c:/test/Sample06-1.rtf"));
.....
//Close the content buffer and create the DOCX document - there is a possibility to write it to File, OutputStream etc.
docxGenerator.closeBufferAndGenerateDOCX("c:/test/dynamic.docx");

Command line arguments for the DOCXGenerator.jar file

You can easily execute the DOCXGenerator.jar from the command line and perform document conversions without writing code using the available command line arguments as follows:

Usage:
java -jar DOCXGenerator.jar absolute_url destination_file

Example:
C:\test>java -jar "C:\test\DOCXGenerator.jar" http://your_url_here c:/test/test-html.docx A4 Portrait

Methods available in the sferyx.administration.docxgenerator.DOCXGenerator class

Method Summary
 void addPageBreakToContentBuffer()
          Adds a page break to the content buffer and all the content appended after that will be on the next page when printed
 void appendDocxToContentBuffer(java.io.File file)
          Appends the whole content of the Docx file from the File to the content buffer.
 void appendDocxToContentBuffer(java.net.URL file)
          Appends the whole content of the Docx file from the given URL to the content buffer.
 void appendHTMLContentToContentBuffer(java.lang.String content)
          Appends new HTML string to existing content buffer.
 void appendPlainTextContentToContentBuffer(java.lang.String content)
          Appends the Plain Text string content to the content buffer.
 void appendRTFBase64EncodedStringToContentBuffer(java.lang.String base64EncodedRTFString)
          Appends RTF content encoded as Base64 string to the content buffer.
 void appendRTFFileToContentBuffer(java.io.InputStream is)
          Appends RTF file from the InputStream to the content buffer.
 void appendRTFFileToContentBuffer(java.net.URL file)
          Appends RTF file from the URL to the content buffer.
 void clearContentBuffer()
          Closes the content buffer and clears the content.
String closeBufferAndGenerateDOCX()
          Generates the DOCX content automatically for given content buffer created prevuiously by using openContentBuffer() and appendContentXXX() methods.
 void closeBufferAndGenerateDOCX(java.io.OutputStream destinationStream)
          Closes the existing content buffer and generates the resulting content from the DOCX Generator - it will be saved in the given OutputStream.
 void closeBufferAndGenerateDOCX(java.lang.String destinationFile)
          Generates the DOCX content automatically for given content buffer created prevuiously by using openContentBuffer() and appendContentXXX() methods.
 String generateDOCXFromContent(java.lang.String content)
          Generates DOCX automatically for given image or HTML content.
 void generateDOCXFromContent(java.lang.String content, java.io.File destinationFile)
          Generates DOCX automatically for given html content.
 void generateDOCXFromContent(java.lang.String content, java.io.OutputStream destinationStream)
          Generates DOCX automatically for given image or html content.
 void generateDOCXFromContent(java.lang.String content, java.lang.String destinationFile)
          Generates the DOCX automatically for given html content.
 String generateDOCXFromHTMLURL(java.lang.String sourceURL)
          Generates DOCX automatically for given URL source containing a HTML file.
 void generateDOCXFromHTMLURL(java.lang.String sourceURL, java.io.File destinationFile)
          Generates DOCX automatically for given URL source containing a HTML file.
 void generateDOCXFromHTMLURL(java.lang.String sourceURL, java.lang.String destinationFile)
          Generates DOCX automatically for given URL source containing a HTML file.
String generateDOCXFromHTMLURL(java.net.URL sourceURL)
          Generates DOCX automatically for given URL source containing a HTML file.
 void generateDOCXFromHTMLURL(java.net.URL sourceURL, java.io.File destinationFile)
          Generates DOCX automatically for given URL source containing a HTML file.
 void generateDOCXFromHTMLURL(java.net.URL sourceURL, java.io.OutputStream fos)
          Generates DOCX automatically for given URL source containing a HTML file.
 String generateDOCXFromPlainTextContent(java.lang.String content)
          Generates DOCX automatically for given Plain text content.
 void generateDOCXFromPlainTextContent(java.lang.String content, java.io.File destinationFile)
          Generates DOCX automatically for given Plain text content.
 void generateDOCXFromPlainTextContent(java.lang.String content, java.io.OutputStream destinationStream)
          Generates DOCX automatically for given Plain text content.
 void generateDOCXFromPlainTextContent(java.lang.String content, java.lang.String destinationFile)
          Generates DOCX automatically for given Plain text content.
 void generateDOCXFromRTFContentBase64String(java.lang.String rtfString, java.io.OutputStream outputStream)
          Generates DOCX automatically for given URL source containing a base64 encoded Rich Text Format RTF string.
String generateDOCXFromRTFInputStream(java.io.InputStream rtfStream)
          Generates DOCX automatically for given InputStream containing a Rich Text Format RTF file.
 void generateDOCXFromRTFInputStream(java.io.InputStream rtfStream, java.io.OutputStream outputStream)
          Generates DOCX automatically for given InputStream containing a Rich Text Format RTF file.
 String generateDOCXFromRTFURL(java.lang.String sourceURL)
          Generates DOCX automatically for given URL source containing a Rich Text Format RTF file.
 void generateDOCXFromRTFURL(java.lang.String sourceURL, java.io.File destinationFile)
          Generates DOCX automatically for given URL source containing a Rich Text Format RTF file.
 void generateDOCXFromRTFURL(java.lang.String sourceURL, java.lang.String destinationFile)
          Generates DOCX automatically for given URL source containing a Rich Text Format RTF file.
String generateDOCXFromRTFURL(java.net.URL sourceURL)
          Generates DOCX automatically for given URL source containing a Rich Text Format RTF file.
 void generateDOCXFromRTFURL(java.net.URL sourceURL, java.io.File destinationFile)
          Generates DOCX automatically for given URL source containing a Rich Text Format RTF file.
 void generateDOCXFromRTFURL(java.net.URL sourceURL, java.io.OutputStream fos)
          Generates HTML automatically for given URL source containing a Rich Text Format RTF file.
 void generateDOCXFromURL(java.lang.String sourceURL)
          Generates DOCX automatically for given URL source.
 void generateDOCXFromURL(java.lang.String sourceURL, java.io.File destinationFile)
          Generates DOCX automatically for given URL source and saves the result to destinationFile as string.
 void generateDOCXFromURL(java.lang.String sourceURL, java.io.OutputStream destinationStream)
          Generates DOCX automatically for given URL source and saves the result to the given OutputStream as a string.
 void generateDOCXFromURL(java.lang.String sourceURL, java.lang.String destinationFile)
          Generates DOCX automatically for given URL source and saves the result to destinationFile as a string.
 String generateDOCXFromURL(java.net.URL sourceURL)
          Generates DOCX automatically for given URL source and saves the result will be returned as Base64 Encoded String.
 void generateDOCXFromURL(java.net.URL sourceURL, java.io.OutputStream destinationStream)
          Generates DOCX automatically for given URL source and saves the result to destinationStream as string.
 boolean getXMLMode()
          Returns the XML mode for the renderer.
 boolean isResizePageToFitContent()
           Returns is the page resizing to fit the content is set. The default is false
 void openContentBuffer()
          Opens the new content buffer for inserting content to be used for dynamic HTML generation.
 void setMarginsForStandardPageFormat(int top, int bottom, int left, int right)
          Sets the margins to be used when the page format is set using the standard string like "A4" or "Letter" - this values will not be considered it PageFormat object is used to set the page format
 void setPageFormat(java.awt.print.PageFormat pageFormat)
          Sets the page format to be used for generating the docx document as PageFormat.
 void setResizePageToFitContent(boolean resize)
           If set to true the page will resize automatically to fit the width of the content. The default is false
 void setStandardPageFormat(java.lang.String standardPageFormat, java.lang.String orientation)
          Sets the standard page format to be used for generating the docx document as string such as "A4", "Letter" etc. and page oriantation such as "Portrait" or "Landscape".
 void setXMLMode(boolean mode)
          Sets the XML mode for the renderer - this will define how custom XML tags will be rendered.

Customers

Sferyx customer base counts more than 1000 corporate customers and institutions from over 40 countries and different industrial sectors as follows: Media and publishing companies, Internet Service Providers, Research  Labs, Fortune 500 companies, Universities, Colleges and Schools, Software Developers, Content Management Systems developers, Web design agencies.

More than 1000 corporate customers, among them:

 

| Home | Users Manual | LicenseDemo & Download

Copyright © 2001-2025 Sferyx Srl. All rights reserved. Sferyx and the Sferyx logo are registered trademarks of Sferyx Srl. http://www.sferyx.com