Convert easily Rich Text Format RTF to PDF in your Java applications

Sferyx JSyndrome PDF Generator and Converter


Advanced Java PDF Generator and Converter component - convert easily Rich Text Format RTF files to PDF and PDF/A.

Sferyx PDF Generator Component is powerful Java HTML to PDF Converter and Generator component. It converts easily Rich Text Format RTF files to PDF in any Java Application - Swing, JavaFX, SWT Eclipse and also Oracle Forms and produces perfectly paginated documents. With only a few lines of code is possible to generate complex PDF files from practically any source or location and the resulting PDF can be written in a file, OutputStream or shown inside the PDF viewer. Supports all UTF-8 languages including support for Greek, Arabic, Cyrillic, Hebrew, Farsi, Chinese,Japanese and more.

You can create the files dynamically by adding the content on-the-fly directly inside your application and also generate page breaks when needed.

 

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

Download Sferyx PDFGenerator Component Order Sferyx PDFGenerator Component
Sferyx JSyndrome PDF Generator Component Edition : Download Sferyx PDFGenerator - PDFGeneratorDemo.zip
 

 

  • Pure Java PDF Generation engine - allows fast and easy PDF creation from various sources and also convert even very complex HTML/XHTML documents with single line of code - 100% in house development - it does not depend on external packages.
  • It converts and generates quickly and easily PDF and PDF/A files directly from HTML, Plain Text, Microsoft Word Docx, Rich Text Format RTF, JPEG, GIF, PNG, BMP
  • Royalty free redistribution with your applications
  • Automatic multiple page layout, rendering and inclusion of all images including the inline Base64 encoded images, inline and linked CSS styles etc.
  • Possibility to specify the desired Page format and margins and whether to scale the content to fit inside or not
  • Works with any JRE/ JDK 1.3, 1.4, 1.5, 1.6, 1.7, 1.8 or higher
  • Support for Oracle Forms and full generation of PDF from Oracle Forms and CLOB 
  • Fully compatible with Swing, JavaFX, SWT/Eclipse, Oracle Forms, Java Servlets, JSP
  • Support for all western Latin languages such as English, German, French, Italian, Spanish, Portuguese, Swedish, Norwegian etc.
  • Support for Arabic, Cyrillic, Greek, Hebrew, Farsi, and many other languages through  UTF-8 pdfGenerator.setCharset("utf-8") character set encoding and Chinese language is also supported through the code: pdfGenerator.setCharset("ISO-10646-UCS-2")
  • Automatic embedding of all TTF fonts contained inside the document when the UTF-8 encoding is set using the code: pdfGenerator.setCharset("utf-8")
  • Support for PDF/A file specification when pdfGenerator.setCharset("utf-8") is set.
  • Compatible with Headless mode for server systems
  • Compact size and fast document generation
  • Possibility to specify whether to split the pages automatically or to generate a poster-like one page PDF file with automatically determining the page length to fit the content.
  • You can specify Headers, Footers and Page numbers in any formatting and position through full HTML formatting support.
  • Now all hyperlinks inside the HTML document are generated as links (annotations) automatically into the resulting PDF 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 PDFGenerator component is quite simple - with only a few lines of code is possible ot generate and convert practially any document to PDF and add headers, footers, page numbers etc.

If your document contains special fonts, characters or symbols you should set the chracters set to UTF-8 using the following method - pdfGenerator.setCharset("utf-8"); - this will also generate PDF/A compliant file. Here are some examples:

Generates PDF automatically for the Rich Text Format RTF URL:

It will generate the file using the standard page format string such as "A4", "Letter" etc. and and save the file to the specified OutputStream or File and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat. This method will recognize automatically if document is html, docx, rtf, txt or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc. Otherwise you can use the methods below for specific cases.

 

import sferyx.administration.pdfgenerator.*;

PDFGenerator pdfGenerator=new PDFGenerator();
pdfGenerator.setMarginsForStandardPageFormat (10,10,10,10);
pdfGenerator.setCharset ("utf-8"); Will embed all fonts and generate PDF/A compliant file and will add support for non-latin languages.
pdfGenerator.generatePDFFromRTFURL ("http://your_url_here.rtf", destinationFile, "Letter", "Portrait");

or using the file name as String:

 

import sferyx.administration.pdfgenerator.*;

PDFGenerator pdfGenerator=new PDFGenerator();
pdfGenerator.setMarginsForStandardPageFormat (10,10,10,10);
pdfGenerator.setCharset ("utf-8"); Will embed all fonts and generate PDF/A compliant file and will add support for non-latin languages.
pdfGenerator.generatePDFFromRTFURL ("http://your_url_here.rtf", "c:/pdfgenerator-test1.pdf", "A4", "Portrait");

 


Generates PDF automatically for the RTF content from the URL.

It will generate the PDF file using the standard page format string such as "A4", "Letter" etc. and and save the file to the specified OutputStream and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat. This method will recognize automatically if document is html, docx, rtf, txt or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc.

If you need you can use also OutputStream if necessary to save the resulting PDF file:

 

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.rtf", destinationStream, "Letter", "Portrait");


If you want to include automatically all TTF fonts inside the PDF/A document or you are using non western languages or special characters you should use the following method:

 

pdfGenerator.setCharset ("utf-8");


For generation of documents in Chinese language use the following setting:

 

pdfGenerator.setCharset ("ISO-10646-UCS-2");



Generate or convert PDF automatically from URL source.


Generates or converts PDF automatically for the URL source. It will display a PageFormat dialog and file dialog for saving the generated file. This method will recognize automatically if document is html, docx, rtf, txt or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc. 
 

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.rtf");


It will display a PageFormat dialog and save the file to the specified destination file. This method will recognize automatically if document is html, docx, rtf, txt or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc.   

 

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.rtf","c:/pdfgenerator-test1.pdf");


Generates or converts PDF automatically for the URL source. It will generate the file using the given java.awt.PageFormat and save the file to the given destination file. This method will recognize automatically if document is html, docx, rtf, txt or image and will convert it accordingly. To use this automatic conversion the URL must end with the corresponding extension like docx, txt, rtx, jpeg, gif, png etc.   

 

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.rtf", "c:/pdfgenerator-test1.pdf", new java.awt.PageFormat());

 

Generates or converts PDF automatically for the  html content. It will generate the file using the given standard page format string such  as "A4", "Letter" etc. and and save the file to the given File and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat

 

pdfGenerator.generatePDFFromDocxURL ("http://your_url_here/file.rtf", "c:/pdfgenerator-test1.pdf", "A4", "Portrait");

or

pdfGenerator.generatePDFFromURL ("http://your_url_here/file.rtf", "c:/pdfgenerator-test1.pdf", "Letter", "Landscape");


Generate the Header for each page in the document.

The parameter content can be any plain text or HTML string - it will be parsed and rendered as a header on the pages. You can includes any HTML element such as images, tables, colors etc. Keep in mind to adjust the top margin in order to make enough room for the header if necessary.bsp;

pdfGenerator.setHeader ("<h1 style=\"color:red;background-color:yellow;border:1px solid blue;\">This is a Header - you can put any HTML here</h1>");

 

Generate the Footer for each page in the document.

The parameter content can be any plain text or HTML string - it will be parsed and rendered as a footer on the pages. You can includes any HTML element such as images, tables, colors etc. Keep in mind to adjust the bottom margin in order to make enough room for the footer if necessary.
 

pdfGenerator.setFooter ("<h3 style=\"color:blue;background-color:yellow:border-top:2px solid green;\">This is a Footer - you can put any HTML here </h3>");

 

Specifies to automatically discard all pages that do not contain text and are practically a blank pages.



pdfGenerator.setDiscardEmptyPages (true);

 

Generate Page Numbers for each page in the document.

The parameter content can be any plain text or HTML string - it will be parsed and rendered practically as footer in the pages and will parse the special directive "@#SferyxPDFGenerator-PageNumber#@" in order to place the page number inside the custom formatting. You can includes any HTML element such as images, tables, colors etc. Keep in mind to adjust the top margin in order to make enough room for the page numbering if necessary.

 

pdfGenerator.setGeneratePageNumbers(true,"<p align=center style=\"padding-top:30px;border-top:1px solid #0000FF;\"><font face=\"arial\" color=\"blue\">Page: @#SferyxPDFGenerator-PageNumber#@</font> - you can put any HTML here </p>");

 

Avoid breaking tables across the pages when possible

If set to true, the PDFGenerator will try to not break tables when page break is encountered if the table is not longer than the page height. The default value is false
 

pdfGenerator.setDoNotBreakTablesAcrossPages (true);



Avoid breaking lists across the pages when possible


If set to true, the PDFGenerator will try to not break tables when page break is encountered if the table is not longer than the page height. The default value is false

 

pdfGenerator.setDoNotBreakListsAcrossPages (boolean disablebreak);



 

 

Package sferyx. administration. pdfgenerator

Fully featured easy-to-use PDF Generator from HTML and plain text content

Class Summary

CustomPageFormatThis class provides a simplified way for assigning standard page formats
PDFGeneratorGeneral purpose PDF Generator - this class provides fully featured generation of PDF files from various sources containing HTML, Word Docx, images or plain text content.
PDFGeneratorOracleBeanThis class has been optimized to deliver correct generation of Rich Text content for Oracle Reports and provide general PDF generation capabilities for OracleForms.
 

 

Method Summary

 voidgeneratePDFFromContent (String htmlContent, java.io.OutputStream destinationStream, String standardPageFormat, String orientation)
          Generates PDF automatically for given html content.
 void generatePDFFromContent (String htmlContent, java.io.OutputStream destinationStream,  java.awt.print.PageFormat pageFormat)
          Generates PDF automatically for given html content.
 void generatePDFFromContent (String htmlContent, String destinationFile, String standardPageFormat, String orientation)
          Generates PDF automatically for given html content.
 voidgeneratePDFFromPlainTextContent (String content, java.io.OutputStream destinationStream, String standardPageFormat, String orientation)
          Generates pdf automatically for given text content.
 voidgeneratePDFFromPlainTextContent (String content, java.io.OutputStream destinationStream,  java.awt.print.PageFormat pageFormat)
          Generates pdf automatically for given text content.
 void generatePDFFromPlainTextContent (String content, String destinationFile, String standardPageFormat, String orientation)
          Generates PDF automatically for given text content.
 void generatePDFFromURL (String sourceURL)
          Generates PDF automatically for given URL source.
 void generatePDFFromURL (String sourceURL, java.io.File destinationFile, java.awt.print.PageFormat pageFormat)
          Generates PDF automatically for given URL source.
 voidgeneratePDFFromURL (String sourceURL, java.io.OutputStream destinationStream, java.awt.print.PageFormat pageFormat)
          Generates pdf automatically for given URL source.
 void generatePDFFromURL(String sourceURL, String destinationFile)
          Generates PDF automatically for given URL source.
 void generatePDFFromURL(String sourceURL, String destinationFile, java.awt.print.PageFormat pageFormat)
          Generates PDF automatically for given URL source.
 void generatePDFFromURL (String sourceURL, String destinationFile, String standardPageFormat, String orientation)
          Generates PDF automatically for given URL source.
voidpublic void generatePDFFromDocxURL (String sourceURL, String destinationFile,String standardPageFormat, String orientation) throws FileNotFoundException, java.net.MalformedURLException - Generates pdf automatically for given URL source containing a MS Word Docx file. It will generate the file using the given standard page format string such as "A4", "Letter" etc. and and save the file to the given File and page oriantation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat
voidpublic void generatePDFFromDocxURL (String sourceURL, File destinationFile, java.awt.print.PageFormat pageFormat) throws FileNotFoundException, java.net.MalformedURLException - Generates pdf automatically for given URL source containing a MS Word Docx file. It generate the file using the given PageFormat and save the file to the given File
 
voidpublic void generatePDFFromRTFURL (String sourceURL, String destinationFile,String standardPageFormat, String orientation) throws FileNotFoundException, java.net.MalformedURLException - Generates pdf automatically for given URL source containing Rich Text Format RTF file. It will generate the file using the given standard page format string such as "A4", "Letter" etc. and and save the file to the given File and page oriantation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat
voidpublic void generatePDFFromRTFURL (String sourceURL, File destinationFile, java.awt.print.PageFormat pageFormat) throws FileNotFoundException, java.net.MalformedURLException - Generates pdf automatically for given URL source containing Rich Text Format RTF file. It generate the file using the given PageFormat and save the file to the given File
 void

setCharset(String charset)
          Set character set for proper PDF generation in non western languages - for all languages use UTF-8 - it will embed all fonts inside the PDF and will generate PDF/A files. For Chinese use ISO-10646-UCS-2

 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 setScaleToFitWidth (boolean scale)
          Indicates whether to rescale the page in order to fit the given PageFormat - the default is true
void setHeader (String content)
         
Generates the header for each page in the document. The parameter content can be any plain text or HTML string - it will be parsed and rendered as a header on the pages. You can includes any HTML element such as images, tables, colors etc. Keep in mind to adjust the top margin in order to make enough room for the header if necessary.
void setFooter (String content)
          
Generates the footer for each page in the document. The parameter content can be any plain text or HTML string - it will be parsed and rendered as a footer on the pages. You can includes any HTML element such as images, tables, colors etc. Keep in mind to adjust the bottom margin in order to make enough room for the footer if necessary.
void setDiscardEmptyPages (boolean discard)
 
          Specifies to automatically discard all pages that do not contain text and are practically a blank pages.
void setTTFFontFolderName (String folderName)  - sets the absolute path to the folder which contains the TrueType fonts to be used when generatiing the PDF documents. Please make sure that this feature is enabled by setting the character set to UTF-8
String getTTFFontFolderName() - returns the name of the True Type fonts if previously set. Otherwise it will return null and for the generation of the PDF files will be used the system font folders.
void setDoNotBreakListsAcrossPages (boolean disablebreak) - if set to true, the PDFGenerator will try to not break tables when page break is encountered if the table is not longer than the page height.
void setDoNotBreakTablesAcrossPages (boolean disablebreak) - if set to true, the PDFGenerator will try to not break tables when page break is encountered if the table is not longer than the page height.
boolean isDoNotBreakListsAcrossPages() returns whether the PDFGenerator should not allow to the lists to break across the pages
boolean isDoNotBreakTablesAcrossPages() returns whether the PDFGenerator should not allow to the tables to break across the pages
void setGeneratePageNumbers (boolean generate, String text)
           Generates page numbers for each page in the document. The parameter content can be any plain text or HTML string - it will be parsed and rendered practically as footer in the pages and will parse the special directive "@#SferyxPDFGenerator-PageNumber#@" in order to place the page number inside the custom formatting. You can includes any HTML element such as images, tables, colors etc. Keep in mind to adjust the top margin in order to make enough room for the page numbering if necessary.
Example: <p align=center style="padding-top:30px; border-top:1px solid #0000FF;"><font face="arial" color="blue">Page: @#SferyxPDFGenerator-PageNumber#@</font></p>
 
 

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-2018 Sferyx Srl. All rights reserved. Sferyx and the Sferyx logo are registered trademarks of Sferyx Srl. http://www.sferyx.com