DataCenterRTF - Java RTF Server Application Tutorial
About RTF Server API
What archive to download?
License key
Typing the URL of your document
Run samples
Jar Files
PDF Generation
Silent printing RTF
Conversion of RTF to other formats
Examples
About RTF Server API
RTF server APIs lets you silent print of an existing RTF. It lets you convert
your RTF to other file formats such as PDF, TIFF, PostScript documents and image formats such as
PNG, GIF, JPG/JPEG, BMP, etc. When converting the RTF to image formats it lets you output each page
as resized (smaller or larger) ones. For example, to show a thumbnail image of a page you
can create a small image of a page. For clear view of the page, you can create an enlarged picture
of a page.
Your RTF can be a local file or a remote file or a server page that dynamically generates a PDF.
Back to Top
What archive to download?
Visit our website and download SmartJEditor server
archive that might look like SmartJEditor_productVersion_Server.zip. After downloading unzip this
ZIP archive to a local folder (let us say c:/rtf/).
Back to Top
License key
RTF API requires a license key for making it functional. All demo archives are
functional using the demo license key "A8EC-73AF-64A9-0375". One of the command line
arguments to the .bat (for Windows) or .sh (for Unix/Linux)
file might be the license key.
To find out what are the command line arguments are required for the sample scripts
to work simply type the script and press enter it will show you the "Usage" options.
Back to Top
Typing the URL of your document
Input an URL and does not matter if the document is located in local file system,
in a remote web server or a server program that dynamically generate one. An URL with
appropriate URL syntax is all that required for printing or
viewing it.
Examples of typing a local file URL:
Window: file:///c:/rtf/sample.rtf or file:/c:/rtf/sample.rtf
Mac OS: file:Macintosh HD/rtf/sample.rtf
Unix/Linux: file:///tmp/rtf/sample.rtf
Examples of typing remote URL:
HTTP: http://www.activetree.com/smartjeditor/rtf/sample.rtf
HTTPS: https://www.myserver.com/rtf/sample.rtf
FTP: ftp://ftp.myserver.com/rtf/sample.rtf
Back to Top
Run samples
There is an executable script file (.bat and .sh) for each of the demo JAVA sample in the "examples"
directory. For Rtf2PdfDemo.java sample there is a Rtf2PdfDemo.bat
(for Windows) and a Rtf2PdfDemo.sh (for Unix/Linux)
in the installation/SmartJEditor_x.y_Server/bin/server/ directory.
For running these *.bat or *.sh script files open a command shell, go to the
directory where this script are located, then simply type one of the script file name and press enter.
It will show you the "Usage" help for further trying the same but with the command line arguments.
There is a sample RTF file SampleDocument.rtf in the
"installation/SmartJEditor_x.y_Server/bin" directory.
Back to Top
Jar Files
When including RTF viewer Swing component to your application or running it as an independent
Java program you have to include the following jars in the class path. All jars mentioned (including
PDF generation jars mentioned next) might be already available in the downloaded archive. If not
found in the downloaded archive download it
from our website and include them in
the class path.
Required jars:
smartjeditor_license.jar
smartjcommon.jar
smartjeditor_server.jar
Optional jars:
smartjeditor_demo.jar - This jar is created out of those sample
.java files
available for you in the "examples" directory of the downloaded archive. If the demo programs are used
without modification include this jar in the class path.
Back to Top
PDF Generation
This API is currently supporting PDF conversion of an RTF file using our PDF generation API. You therefore
must include the following PDF creation jars in the class path (if PDF is enabled for your application).
PDF Jars
smartjpdfgen.jar
Back to Top
Silent printing RTF
RtfPrinter - is the class you use for silent printing of an RTF document. You primarily require
the RTF source and a PageFormat instance. If you do not pass a PageFormat it will use the default
PageFormat.
Following APIs can be called:
print() - for printing from a file, URL or byte[] content of your RTF. This method is overloaded
to take parameters in order to control the printing.
getPageable() - returns a java.awt.print.Pageable of the pages generated from the argument RTF. This method too
is overloaded with various parameters.
See the javadoc for more details of the methods and parameters of this class.
Back to Top
Conversion of RTF to other formats
Your RTF can be converted to these formats:
Document formats
PDF
TIFF
PostScript (PS)
Image formats
PNG
GIF
BMP
JPG/JPEG
Back to Top
Examples
There are some RTF server examples in the downloaded server archive in its "examples"
directory. We suggest you to take a look in these Java sample files and if necessary create your own
custom server programs.
RtfSilentPrintDemo - Takes an RTF input and prints to the default printer
Rtf2PdfDemo - Using an RTF input file it produce a PDF output file
Rtf2PostScriptDemo - With an RTF as input it produce a PostScript output file
Rtf2ResizedTiffDemo - Converts an RTF to a TIFF document
Rtf2ResizedBMPDemo - Converts RTF and creates BMP image for each page
Rtf2ResizedGIFDemo - Produces a GIF image for each page of the RTF
Rtf2ResizedJPEGDemo - Produces a JPEG image for each page of the RTF
Rtf2ResizedPNGDemo - Produces a PNG image for each page of the RTF
Back to Top