DataCenter™RTF - Java RTF Viewer Tutorial

  • About RTF viewer
  • What archive to download?
  • License key
  • Typing the RTF URL in the viewer
  • Run samples
  • Jar Files
  • PDF Generation
  • Viewer Components
  • Simple RTF viewer
  • Customizing RTF viewer
  • Examples

  • About RTF viewer

    This has a Java RTF viewer components which are just like any other Swing components. Viewer components can be added to your existing Swing UI application. RTF Swing components allow opening, editing and saving as RTF files. It also has API to save the RTF as a PDF document.

    Back to Top
    What archive to download?

    Visit our website and download SmartJEditor Viewer archive that might look like SmartJEditor_productVersion_Viewer.zip. Once downloaded 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 RTF URL in the viewer

    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 a executable script file for each of the demo JAVA sample in the "examples" directory. For SmartJEditorDemo.java sample there is SmartJEditorDemo.bat in the installation/SmartJEditor_x.y_Viewer/bin/client/ directory.
    For running this SmartJEditorDemo.bat script file open a command shell, go to the directory where this script is located, simply type this batch file and press enter. It will show you the RTF viewer window with a sample RTF document loaded from the demo jar file. For trying there is another sample RTF file SampleDocument.rtf in the installation/SmartJEditor_x.y_Viewer/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_client.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 downloded archive. If the demo programs are used without modification include this jar in the classpath.

    Back to Top
    PDF Generation

    This API 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
    Examples

    There are some RTF viewer examples in the RTF viewer archive in the "examples" directory.

  • SmartJEditorDemo - One shows RTF Viewer supported by this API. It shows how to attach listeners for edit, veto user action and more.
  • CustomJEditorDemo - Also shows an RTF editor but with some customization in removing, adding more menu and toolbar options.
  • Back to Top