Sferyx LogoSferyx Internet Based Systems
   

Sferyx JSyndrome PDF Generator
Java HTML to PDF Generator Component


Advanced Java PDF Generator component for your
Java applications from HTML / XHTML, Plain text and Image sources

Sferyx PDF Generator is powerful Java HTML to PDF convertor and generation component. It allows quick and easy conversion of HTML to PDF or text to PDF from any java application, Oracle Forms, SWT Eclipse and others. With only a few lines of code is possible to generate complex PDF files practically from any source or location and the resulting PDF can be written in a file, output stream or shown inside the PDF viewer. Support for all western Latin languages such as English, German, French, Italian, Spanish, Portuguese, Swedish, Norwegian and full support for Arabic, Cyrillic, Greek, Hebrew, Farsi, Chinese, Japanese etc.

 

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

Download HTML Editor Component
Sferyx JSyndrome PDF Generator Component Edition : PDFGeneratorDemo.zip
(ZIP file, ~ 0.9 MB)

  • 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.
  • Royalty free redistribution with your applications
  • Automatic multiple page layout, rendering and inclusion of all images, inline and linked 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 or higher
  • Support for Oracle Forms and full generation of PDF from Oracle Forms
  • Fully compatible with Swing, SWT/Eclipse, Oracle Forms
  • 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 - by using the code: pdfGenerator.setCharset("utf-8")
  • 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

import sferyx.administration.pdfgenerator.*;

PDFGenerator pdfGenerator=new PDFGenerator();
pdfGenerator.setMarginsForStandardPageFormat(10,10,10,10);
pdfGenerator.generatePDFFromURL
("http://your_url_here", "c:/pdfgenerator-test1.pdf", "A4", "Portrait");

or use OutputStream if necessary:

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

Generates or Converts HTML to PDF automatically for given URL. 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 OutputStream and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat

pdfGenerator.generatePDFFromContent("your HTML content here", destinationStream, new java.awt.PageFormat());

Generates or Converts HTML to PDF automatically for given html content. It will generate the file using the given PageFormat and and save the file to the given OutputStream.

pdfGenerator.generatePDFFromContent("your HTML content here", destinationStream, "Letter", "Portrait");

Generates PDF automatically for given 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 OutputStream and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat

pdfGenerator.setMarginsForStandardPageFormat(10,10,10,10);

pdfGenerator.generatePDFFromPlainTextContent("your text content here", destinationStream, "Letter", "Portrait");

Generates or converts text to PDF automatically for given plain text 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 OutputStream and page orientation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat

pdfGenerator.generatePDFFromPlainTextContent("your HTML content here", destinationStream, new java.awt.PageFormat());

Generates or converts text to PDF automatically for given plain text content. It will generate the file using the given PageFormat and and save the file to the given OutputStream.

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

Generates or converts PDF automatically for given URL source. It will display a PageFormat dialog and save the file to the given destination file

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

Generates or converts PDF automatically for given URL source. It will display a PageFormat dialog and file dialog for saving the generated file


HTML EDITOR COMPONENT

HTML EDITOR APPLET

PDF GENERATOR

User Manual
Oracle Forms
Licensing & Prices
Download

EQUATION EDITOR

PDFEXPORT ADD-ON


 

Latest News and Updates

 

Customers
 

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

Generates or converts PDF automatically for given URL source. It generate the file using the given java.awt.PageFormat and save the file to the given destination file

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

or

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

Generates or converts PDF automatically for given 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.generatePDFFromPlainTextContent("some text here", "c:/pdfgenerator-test1.pdf", "Letter", "Landscape");

Generates PDF automatically for given text 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 oriantation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat

pdfGenerator.generatePDFFromPlainTextContent("some HTML content here", "c:/pdfgenerator-test1.pdf", "Letter", "Landscape");

Generates pdf automatically for given 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 oriantation such as "Portrait" or "Landscape". You can also set the page margins using the method setMarginsForStandardPageFormat

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

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.

pdfGenerator.setFooter("<h3 style=\"color:blue;\">This is a Footer - you can put any HTML here </h3>");

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.

pdfGenerator.setDiscardEmptyPages(true);

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

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>");

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.

pdfGenerator.setDoNotBreakTablesAcrossPages(true);

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)

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

Further you can manage the page breaks through the standard CSS properties
page-break-before:always, page-break-after:always, page-break-inside:never, by specifying them inside the document like this:

<div style="page-break-before:always">some text</div>

or

<table style="page-break-after:always">some text ...</table>

or

<p style="page-break-inside:never">some text...</p>

 

Package sferyx.administration.pdfgenerator

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

Class Summary

CustomPageFormat This class provides a simplified way for assigning standard page formats
PDFGenerator General purpose PDF Generator - this class provides fully featured generation of PDF files from various sources containing HTML or plain text content.
PDFGeneratorOracleBean This 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

 void generatePDFFromContent(java.lang.String content, java.io.OutputStream destinationStream, java.lang.String standardPageFormat, java.lang.String orientation)
          Generates PDF automatically for given html content.
 void generatePDFFromContent(java.lang.String content, java.io.OutputStream destinationStream,  java.awt.print.PageFormat pageFormat)
          Generates PDF automatically for given html content.
 void generatePDFFromContent(java.lang.String content, java.lang.String destinationFile, java.lang.String standardPageFormat, java.lang.String orientation)
          Generates PDF automatically for given html content.
 void generatePDFFromPlainTextContent(java.lang.String content, java.io.OutputStream destinationStream, java.lang.String standardPageFormat, java.lang.String orientation)
          Generates pdf automatically for given text content.
 void generatePDFFromPlainTextContent(java.lang.String content, java.io.OutputStream destinationStream,  java.awt.print.PageFormat pageFormat)
          Generates pdf automatically for given text content.
 void generatePDFFromPlainTextContent(java.lang.String content, java.lang.String destinationFile, java.lang.String standardPageFormat, java.lang.String orientation)
          Generates PDF automatically for given text content.
 void generatePDFFromURL(java.lang.String sourceURL)
          Generates PDF automatically for given URL source.
 void generatePDFFromURL(java.lang.String sourceURL, java.io.File destinationFile, java.awt.print.PageFormat pageFormat)
          Generates PDF automatically for given URL source.
 void generatePDFFromURL(java.lang.String sourceURL, java.io.OutputStream destinationStream, java.awt.print.PageFormat pageFormat)
          Generates pdf automatically for given URL source.
 void generatePDFFromURL(java.lang.String sourceURL, java.lang.String destinationFile)
          Generates PDF automatically for given URL source.
 void generatePDFFromURL(java.lang.String sourceURL, java.lang.String destinationFile, java.awt.print.PageFormat pageFormat)
          Generates PDF automatically for given URL source.
 void generatePDFFromURL(java.lang.String sourceURL, java.lang.String destinationFile, java.lang.String standardPageFormat, java.lang.String orientation)
          Generates PDF automatically for given URL source.
 void setCharset(java.lang.String charset)
          Set character set for proper PDF generation in non western languages - for all languages use UTF-8 and 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(java.lang.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
java.lang.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>

 

| Home | Users Manual | LicenseDemo & Download

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