silent_print_rtf_from_browser.warThis is a web application archive ready for deployment in a web container. This archive is aimed at silent printing and viewing of RTF documents (existing or dynamically generated from a server program) located anywhere in the world.
Back to Top
No.
This web application is a self sufficient WAR archive and does not require any
other third-party software. Simply deploy it and access the start page.
silent_print_rtf_from_browser.war
Visit our web site and download this archive.
When you click on the download link your browser might prompt to "Save As..." a ".zip" extension which you
must change to ".war". Alternatively, you can save first and later rename to change the extension to ".war".
This WAR archive is a self sufficient web application archive ready to be deployed under any web container.
Here are some examples of how to deploy silent_print_rtf_from_browser.war WAR (Web Application Archive) archive:
These are not the only web servers to deploy. You can deploy it to any other web server of your choice. These are just
examples.
JBoss: Copy to installation/server/default/deploy directory.
Tomcat: Copy it to the installation/webapps/ directory.
If the web server is up and running simply copying the .war will cause the web server to automatically deploy it by
creating a directory silent_print_rtf_from_browser.
Let us say the war archive name is silent_print_rtf_from_browser.war which you have copied to
one of the web server location mentioned above. The context path for the application when deployed is
silent_print_rtf_from_browser (name of the war file). Type an URL that
looks something like:
http://host:port/silent_print_rtf_from_browser/ or
https://host:port/silent_print_rtf_from_browser/
If your web server port is 80 you do not need to type the port number.
Back to TopInput 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:
file:///c:/rtf/sample.rtf or file:/c:/rtf/sample.rtf
file:Macintosh HD/rtf/sample.rtf
file:///tmp/sample.rtf
Examples of typing remote URL (these URL may not exist):
http://www.activetree.com/smartjeditor/rtf/sample.rtf
https://www.myserver.com/rtf/sample.rtf
ftp://ftp.myserver.com/rtf/sample.rtf
Back to Top
It is just like any other URL. Here is an example of a JSP report generation URL generates a report and converts it to a RTF. The output form this URL is therefore a RTF document and can be viewed or silent printed like ant other URL pointing to an existing RTF. You can find this dynamic RTF generation sample in this WAR archive.
http://www.activetree.com/silent_print_rtf_from_browser/demo/dynamic_rtf_generation.jsp
Calling the RTF viewer URL with a RTF as argument will display it in the browser window.
There are JSP and PHP script files to call for printing or viewing. In this tutorial we
will use the JSP script in our examples.
Downloaded archive silent_print_rtf_from_browser.war has few JSP scripts to call.
For viewing a RTF call view_rtf.jsp.
Here is how the RTF viewer URL looks like:
http://host:port/silent_print_rtf_from_browser/view_rtf.jsp
Here is an example:
http://www.activetree.com/silent_print_rtf_from_browser/view_rtf.jsp
Pass one or more of these parameters to the view_rtf.jsp.
| Parameter name | Possible values | Details |
| DOCUMENT | URL String | A string pointing to an existing RTF or an URL that can dynamically generate a RTF document for viewing.
Example: http://www.activetree.com/smartjeditor/rtf/sample.rtf |
| REMOTE_SAVE_ENABLED | "true" or "false" | When viewing from browser you can let the viewer show you an additional menu and toolbar button to do
a "remote save as..." option. With this operation you can save the opened RTF back by
overwriting the same document or save to a persistent store such as a database.
Value "true" if used you must also specify an URL that will be used by the viewer to call for the "remote save as..."
operation using the |
| REMOTE_SAVE_ACTION_URL | URL string | If REMOTE_SAVE_ENABLED is "true", you must provide an URL which the RTF viewer can call and post the RTF data as byte[].
From your action URL you should read the byte[] data and save it some where in the server side (e.g. as file, in a
database etc.). You might need additional parameters such as file name, database name, user name, time, location to save etc.
in your remote save as action URL for psisting the data. Put any parameters and values together as one string and pass to the
viewer using the "REMOTE_SAVE_ACTION_URL_ARGS" mentioned next.
Example: |
| REMOTE_SAVE_ACTION_URL_ARGS | key value pairs separated by "|" character | If you haved enabled the "remote save as..." operation, using this parameter you can pass some parameters and their values
to your "remote save as action url" where you can parse and use them for persisting the byte[] of data action URL receive.
This WAR archive has a demo |
| DEBUG | "true" or "false" | Set to "true" for seeing debug messages on Java console. |
These examples are pointing to an existing deployment.
| Details | URL |
| Existing RTF | http://www.activetree.com/silent_print_rtf_from_browser/view_rtf.jsp?DOCUMENT=http://www.activetree.com/smartjeditor/rtf/sample.rtf |
| URL generates RTF dynamically | http://www.activetree.com/silent_print_rtf_from_browser/view_rtf.jsp?DOCUMENT=http://www.activetree.com/silent_print_rtf_from_browser/demo/dynamic_rtf_generation.jsp |
This web archive lets you 'silent print' an existing RTF or a RTF dynamically generated from an URL to a printer. Learn more next about the parameters with examples about how you can control "silent print" RTF.
Back to Top
You call silent_print_rtf.jsp script from this web application with one or more parameters to it.
For understanding this web application we'll use silent_print_rtf.jsp script from a deployment in our website.
We'll pass one or more parameters to this URL in order to control silent printing. At least one
parameter is required which is a RTF document URL.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp
DOC_LIST is the parameter to use for specifying the RTFs to print. This parameter is always enclosed with a leading
"[" and a trailing "]" character. This example is going to silent print an existing RTF
http://www.activetree.com/smartjeditor/rtf/sample.rtf from a remote web site.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]
DOC_LIST is still is the parameter name for printing multiple RTF files.
Each RTF file must be separated by "[" and "]" characters. In this example URL we are printing
two RTF files:
http://www.activetree.com/smartjeditor/rtf/sample.rtf
and
http://www.activetree.com/silent_print_rtf_from_browser/demo/dynamic_rtf_generation.jsp
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf][http://www.activetree.com/silent_print_rtf_from_browser/demo/dynamic_rtf_generation.jsp]
Job name is controlled using JOB_NAME name parameter.
This example is using "SmartJEditor" is the job name for this parameter.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor
This is controlled by FIT_TO_PAPER parameter. RTF page area may be different than the paper it is printer.
Therefore it is important to turn this flag on so the
RTF page content be fit into the paper area and no part be lost. If the RTF page area is smaller than the paper
area turning this flag on will result the smaller content be enlarged to fit to the biger area.This example
is a value "true" for this flag and the print out will fit into the paper area by enlarging or shrinking the RTF
page content. Default value is set to true.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true
PAPER - parameter is used with a paper size value for which should look like
"(topMargin, leftMargin, bottomMargin, rightMargin, paperWidth, paperHeight)" in pixels. The paper width and paper height
in this parameter must be the width and height of the papers defined in ISO standard. Margin values can be some thing of your choice
depending on kind of margin you want to have for the output.
Example: For NA_LETTER paper it is PAPER=(72,72,72,72,612,792)
where:
topMargin = 72 pixels
leftMargin = 72 pixels
bottomMargin = 72 pixels
rightMargin = 72 pixels
paperWidth = 612 pixels
paperHeight = 792 pixels
Therefore, the imageable width of the paper is (paperWidth - (leftMargin + rightMargin)) e.g. (612-(72+72))=486 pixels and
imageable height of the paper is (paperHeight - (topMargin + bottomMargin)) e.g. (792-(72+72))=648 pixels.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)
PASSWORD parameter is used for setting the password. Only one password is supported even when you
are printing multiple RTF files. We therefore suggest, if you are printing multiple RTF files
where more than one RTF is password protected print one RTF at a time.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&PASSWORD=myDocPassword
There are no flag to print to a default printer. However, if you want to print to a named printer
look for PRINTER_NAME and PRINTER_NAME_SUBSTRING_MATCH parameters next.
PRINTER_NAME and PRINTER_NAME_SUBSTRING_MATCH parameters are used in combination to print to
a particular printer identified by a name. PRINTER_NAME value is either full name of
the printer or a substring of it. On the other hand PRINTER_NAME_SUBSTRING_MATCH tells whether or not
API should look for a printer that is of exact match (value if false) with the string in PRINTER_NAME
or API should try to find a printer taking the PRINTER_NAME value and do a substring match (value if true)
with all the available printers.
If it do not find a matched printer using these two parameters it will print to default printer.
In this example PRINTER_NAME=HP LaserJet 4200 PCL&PRINTER_NAME_SUBSTRING_MATCH=false used to indicate that an exact match
should be performed for finding a printer named "HP LaserJet 4200 PCL". When PRINTER_NAME_SUBSTRING_MATCH=true the first
printer found using a substring match will be used even there are other printer name might match this substring.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&PASSWORD=myDocPassword&PRINT_QUALITY=High&PRINTER_NAME=HP LaserJet 4200 PCL&PRINTER_NAME_SUBSTRING_MATCH=false
PRINT_QUALITY parameter is used for setting the printout quality. Possible values are High, Normal and Draft.
For laser printers this parameter may not make any difference in output quality. It is important for other kinds of printer
such as a thermal printer.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&PASSWORD=myDocPassword&PRINT_QUALITY=High
SIDE_TO_PRINT parameter is used for this purpose. Possible values are
ONE_SIDED, DUPLEX, TUMBLE, TWO_SIDED_LONG_EDGE, or TWO_SIDED_SHORT_EDGE.
Actual outcome for this parameter will depend on whether or not the printer supports it.
In this example a value of DUPLEX is used with the expectation that the output
be printed on both sides of the pages. Duplex mode saves paper and is recommended if
your printer support it.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&PASSWORD=myDocPassword&PRINT_QUALITY=High&SIDE_TO_PRINT=DUPLEX
IS_USE_PRINTER_MARGINS parameter is used for validating the paper size with the printer.
A printer might be configured to keep certain amount of margins around the page. RTF content if printed ignoring
this margins it might produce the content near the boundary of the paper is cut off. Set this flag to true if you
want to use the printer margins, otherwise, set this flag to false. Default value is true.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&IS_USE_PRINTER_MARGINS=true
COPIES parameter takes an integer number as the number of copies to be printed.
Default value is 1 copy. This example is using COPIES=2 for printing 2
copies.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&IS_USE_PRINTER_MARGINS=true&COPIES=2
COLLATE_COPIES parameter takes boolean true if you want the copies to be collated
false otherwise. This is used when printing multiple copies. Default value for this parameter
is true.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&IS_USE_PRINTER_MARGINS=true&COPIES=2&COLLATE_COPIES=true
SINGLE_PRINT_JOB parameter takes boolean true if you want all the DOC_LIST documents
be printed as one print job, false otherwise. This is used when printing multiple RTF documents. One print
job will cause the API to put together pages from all of the RTF documents and print them together as one
document. If this flag it set to false it will print each RTF document as one print job post fixed
with a number.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf][http://www.activetree.com/silent_print_rtf_from_browser/demo/dynamic_rtf_generation.jsp]&SINGLE_PRINT_JOB=true
SHOW_PRINT_DIALOG parameter can be set to true if you want to select all of these printing parameters
from a dialog window, false otherwise. This flag makes the printing non-silent since it will wait for user input
before printing. Moreover it will ignore all the parameter values and will use what user select from this dialog. Only parameter
API will use from the URL parameters is the PASSWORD value.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&PASSWORD=myDocPassword&SHOW_PRINT_DIALOG=true
SHOW_PRINT_ERROR_DIALOG parameter if true shows a dialog displaying any kind of printing
error if any, false otherwise. Error dialog is shown only if there are printing errors. Default value
is true. This example set this flag to false so no dialogs are shown. (See DEBUG
parameter later in this tutorial to trace the printing debug messages).
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&IS_USE_PRINTER_MARGINS=true&SHOW_PRINT_ERROR_DIALOG=false
STATUS_UPDATE_ENABLED parameter if true it shows messages in the browser window while printing is happening.
Messages such as RTFs to print, total number of pages, printer it is printing to etc. are displayed when printing is in progress.
Default value is true. When you run without this parameter it will display messages in the browser window. Set this to
false if do not want to see any messages in the browser window.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&IS_USE_PRINTER_MARGINS=true&SHOW_PRINT_ERROR_DIALOG=false&STATUS_UPDATE_ENABLED=false
DEBUG parameter if true it shows API debug messages in the Java console
window while printing is in progress. This is helpful for the end user as well as developers when trying
to print and report a problem if any. This example is using a value false for not recording any debug
messages.
Default value is set to true.
http://www.activetree.com/silent_print_rtf_from_browser/silent_print_rtf.jsp?DOC_LIST=[http://www.activetree.com/smartjeditor/rtf/sample.rtf]&JOB_NAME=SmartJEditor&FIT_TO_PAPER=true&PAPER=(72,72,72,72,612,792)&IS_USE_PRINTER_MARGINS=true&SHOW_PRINT_ERROR_DIALOG=false&STATUS_UPDATE_ENABLED=false&DEBUG=false
This WAR archive contains two demo samples built using the view_rtf.jsp
and silent_print_rtf.jsp explained earlier in this tutorial. These demo
script files are located under demo directory. In the demo
directory there is this demo_main.jsp works as a common page with links
to both the demo samples.
This demo is located under demo directory. This consists of two scripts
demo_main.jsp and demo_uploader.jsp.
demo_main.jsp:
- read list of RTF files available in the demo/sample_rtf/ directory. For each of
the RTF found in this directory it provides a link for the browser to edit and save them back.
- It also provides a link to demo-2 (a dynamic RTF creator sample) in the same page.
In this sample (demo_main.jsp) all parameters are embedded as part of the "silent print"
(using silent_print_rtf.jsp) or "view" (using view_rtf.jsp).
When you "silent print" a RTF using this demo, it will display some messages to the "Printing Status" pane
at the bottom of this page (if the STATUS_UPDATE_ENABLED is enabled in this script file).
This demo dynamic_rtf_generation.jsp is located under demo directory. A link to this
dynamic RTF generation script is made available to the demo_main.jsp in this demo directory.
This server program shows how to use RTF report generation model to add report objects, generate a report and convert the report pages to a RTF document for viewing or silent printing from a browser.
URL to this dynamic RTF generation script:
http://www.activetree.com/silent_print_rtf_from_browser/demo/dynamic_rtf_generation.jsp
Copyright © 2004 Activetree, Inc. All rights reserved.
Web: http://www.activetree.com
Email: sales@activetree.com
Tel: +1 408 716 8414 Fax: +1 408 716 8450