This is an web application archive ready for deployment in a web container. This archive is aimed at silent printing and viewing of PDF 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 softwares. Simply deploy it and access the start page.
Sample WAR archives are self sufficient web application archive ready to be deployed under any web container. You require no other softwares for its functioning. Here are some examples of where to copy these files in the web server environment.
JBoss: Copy the WAR archives into JBoss installation/server/default/deploy directory.
Tomcat: Copy these WAR files to the installation/webapps/ directory.
Let us say the war archive name is silent_print_pdf_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_pdf_from_browser (name of the war file). Type an URL that
looks something like:
http://host:port/silent_print_pdf_from_browser/ or
https://host:port/silent_print_pdf_from_browser/
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:
file:///c:/pdf/sample.pdf or file:/c:/pdf/sample.pdf
file:Macintosh HD/pdf/sample.pdf
file:///tmp/sample.pdf
Examples of typing remote URL:
http://www.activetree.com/demo/pdf/tax_form_1040.pdf
https://www.paypal.com/en_US/pdf/PP_Sandbox_UserGuide.pdf
ftp://ftp.eia.doe.gov/pub/oiaf/1605/cdrom/pdf/ggrpt/057306.pdf
Back to Top
It is just like any other URL. Here is an example of a JSP page that generates a PDF when it is called.
http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp
It lets you specify a password for those password protected documents. See parameter table next to know more about how to provide password to the PDF view and print applet.
Back to Top
Following are the parameters name used by the printing and viewing APPLET. Possible values for the parameters are
mentioned. Look at the view_pdf.* and print_pdf*.* samples to see these parameters name
under "OBJECT" and "EMBED" tags. Applet class used for viewing and printing is the value for
CODE tag.
| Parameter name | Possible values | Details |
| LICENSE_KEY | license key | Samples already set with a TRIAL license key. Replace this demo key with your licensed key if this software is licensed by you. |
| PDF_LIST | One or more PDF files | This example shows it is printing 3 documents combining pages. Each
document is identified inside the "[" and "]" marker in the value field.
Even single document too is marked with the same syntax.
"[http://www.activetree.com/demo/pdf/tax_form_1040.pdf][http://www.activetree.com/demo
/pdfapplet/samples/Certificate of Foreign Intermediary
(fw8imy).pdf][http://www.activetree.com/demo/pdfapplet/samples/Instructions
for Forms 1098-E and 1098-T (i1098et).pdf]" |
| FIT_TO_PAPER | "true" or "false" | "true" if you want the actual page to fit in the printing media imageable area, "false" otherwise. |
| AUTO_MATCH_PAPER | "true" or "false" | "true" lets API search for a printing media that is of exact match with the actual page size of the document. This match is done for each page that is because each page in the document might be of different size. Use "false" for using the default media size or use the media size you pass as value to the PAPER argument. |
| IS_USE_PRINTER_MARGINS | "true" or "false" | "true" let the API validate the imageable area from printer and use the printer validated imageable area of the paper. Use "false" to try printing using full paper area as the imageable area. |
| PRINTER_NAME | Printer name to print to | A name that is found from a call to a PrintService.getName() . Example: "Brother MFC-8440 USB" |
| PRINTER_NAME_SUBSTRING_MATCH | "true" or "false" | "true" to indicate if the API should use a substring match of the printer name passed against "PRINTER_NAME" parameter. If "false" API will try to find a printer that is of exact match with the printer name in "PRINTER_NAME" parameter. |
| PAPER | Size of the paper in pixels | A value of "(612,792)" - indicates use "NA_LETTER" paper; WIDTH of which is 612 pixels and HEIGHT is 792 pixels. |
| COPIES | Number of copies to print | Example: 1 for one copy, 2 for two copies, 10 for ten copies etc. |
| COLLATE_COPIES | "true" or "false" | Used for printing more than one copy so one can let the output be collated. Use "true" for collate else "false". |
| JOB_NAME | Print job name | A string |
| SHOW_PRINT_DIALOG | "true" or "false" | If "true" a print dialog will appear for the end user to select the printing parameters. This will not longer then a "silent" print if option is "true". Use "false" for not showing any dialog instead pass all printing parameters mentioned here. |
| SINGLE_PRINT_JOB | "true" or "false" | "true" consolidates pages from all documents and prints as one print job. Pass "false" if each document should be printed as one print job. For printing single document at a time this is better be "false". |
| SHOW_PRINT_ERROR_DIALOG | "true" or "false" | "true" is used for showing any kind of printing errors if any while printing. For example if a document is password protected and user did not enter a password it will show an error dialog to the end user so error is more understandable. |
| PRINT_QUALITY | HIGH, NORMAL, or DRAFT | Print quality (depends on printer support). Default is HIGH. |
| SIDE_TO_PRINT | ONE_SIDED, DUPLEX, TUMBLE, TWO_SIDED_LONG_EDGE, or TWO_SIDED_SHORT_EDGE | Media side to print (depends on printer support). Default is ONE_SIDED. |
| PASSWORD | Password to unlock the document | Provide a password for a password protected document. |
| DEBUG | "true" or "false" | Usually used for debugging. If it is "true" lots of debug messages are displayed to the applet console panel. Open console to see the messages. |
Viewer is a fully customizable Swing component. You can create your own derived Swing Component in order to customize the existing viewer. These parameters are used for automatic viewing of PDF documents from a browser window.
| Parameter name | Possible values | Details |
| DOCUMENT | String | A string pointing to an existing PDF or an URL that can dynamically generate a PDF document for viewing.
Example: http://www.activetree.com/demo/pdf/tax_form_1040.pdf or
http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp |
| PASSWORD | String | Only applicable for those password protected documents. You may or may not pass a value for this parameter. If the document is NOT a password protected one a value passed for it will be ignored. |
This section is aimed at programmers wants to know about how to construct a custom URL using the printing or viewing parameters. This tutorial tells little more about how existing samples are working for silent printing and viewing of single or multiple PDF documents.
Back to Top
view_pdf.* (e.g. view_pdf.jsp, view_pdf.php etc.) -
responsible for showing a PDF in the browser window.print_pdf*.* (e.g.
print_pdf1.jsp, print_pdf1.php,
print_pdf2.jsp, print_pdf2.php etc.) - responsible for silent printing one or more PDF documents form browser window.view_pdf.*
or print_pdf*.* programs with an URL
consists of parameters name and value.
PDF viewer applet requires DOCUMENT and PASSWORD parameters.
Examples:
The document require a password set the password value.
http://www.activetree.com/silent_print_pdf_from_browser3/view_pdf.jsp?PASSWORD=docPassword&DOCUMENT=http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp
This document does not require a password set it empty (or a value will not harm anything).
http://www.activetree.com/silent_print_pdf_from_browser3/view_pdf.jsp?PASSWORD=&DOCUMENT=http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp
Constructing URL to silent print single PDF documentBack to TopThere are few
print_pdf*.*samples for printing PDFs.print_pdf1.jsp or print_pdf1.php- are for silent printing single PDF document. Here is how your URL should look like if you use these existing samples (print_pdf*.*).
http://www.activetree.com/silent_print_pdf_from_browser/print_pdf1.jsp?user_pdf_url=http://www.activetree.com/demo/pdf/tax_form_1040.pdf&JOB_NAME=SmartJPrint&FIT_TO_PAPER=true&SHOW_PRINT_ERROR_DIALOG=false&AUTO_MATCH_PAPER=true&DEBUG=true&PRINTER_NAME=&PRINTER_NAME_SUBSTRING_MATCH=false&PAPER=&COPIES=1&SHOW_PRINT_DIALOG=false&IS_USE_PRINTER_MARGINS=true&SINGLE_PRINT_JOB=true&PASSWORD=&COLLATE_COPIES=false&PRINT_QUALITY=HIGH&SIDE_TO_PRINT=ONE_SIDEDYou can also use
print_pdf1.jspis in thesilent_print_pdf_from_browser.wararchive.print_pdf1.jspfrom another demo web archivesilent_print_pdf_from_browser3.warshown next.Back to Top
http://www.activetree.com/silent_print_pdf_from_browser3/print_pdf1.jsp?user_pdf_url=http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp&JOB_NAME=SmartJPrint&FIT_TO_PAPER=true&SHOW_PRINT_ERROR_DIALOG=false&AUTO_MATCH_PAPER=true&DEBUG=true&PRINTER_NAME=&PRINTER_NAME_SUBSTRING_MATCH=false&PAPER=&COPIES=1&SHOW_PRINT_DIALOG=false&IS_USE_PRINTER_MARGINS=true&SINGLE_PRINT_JOB=true&PASSWORD=&COLLATE_COPIES=false&PRINT_QUALITY=HIGH&SIDE_TO_PRINT=ONE_SIDED
Constructing URL to silent print multiple PDF documents
print_pdf2.jsp or print_pdf2.php(in thesilent_print_pdf_from_browser.wararchive) - is the one capable of printing multiple PDFs. It takes a local parameter called "pdfs" as arguments to it. Value for this "pdfs" parameter is a list of PDF files separated by "|" character. This URL list consists of one URL that dynamically generates a PDF, a local Windows file URL and a remote web server URL pointing to an existing PDF document. All theprint_pdf*.*ultimately translates one or more PDF URLs as "[" "]" separated string used by the applet with"PDF_LIST"parameter. Even though theseprint_pdf*.*samples receive document URLs through local parameters (parameters not used by applet) (such as"pdfs"or"user_pdf_url") that all are translated as a "[" "]" separated list of PDF files to pass to the applet usingPDF_LISTparameter.
Example:
pdfs=http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp|file:/c:/temp/cid_sample.pdf|http://www.activetree.com/demo/pdfapplet/samples/Certificate of Foreign Intermediary (fw8imy).pdfHere is how the full URL look like if you call
print_pdf2.jspwith all printing parameters as arguments.
http://www.activetree.com/silent_print_pdf_from_browser/print_pdf2.jsp?pdfs=http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp|file:/c:/temp/cid_sample.pdf|http://www.activetree.com/demo/pdfapplet/samples/Certificate of Foreign Intermediary (fw8imy).pdf&JOB_NAME=SmartJPrint&FIT_TO_PAPER=true&SHOW_PRINT_ERROR_DIALOG=false&AUTO_MATCH_PAPER=true&DEBUG=true&PRINTER_NAME=&PRINTER_NAME_SUBSTRING_MATCH=false&PAPER=&COPIES=1&SHOW_PRINT_DIALOG=false&IS_USE_PRINTER_MARGINS=true&SINGLE_PRINT_JOB=true&PASSWORD=&COLLATE_COPIES=false&PRINT_QUALITY=HIGH&SIDE_TO_PRINT=ONE_SIDEDPDF_LIST - How does it look like?
This parameter name is used by the applet class for receiving number of PDF URLs as a string separated by "[" and "]". This parameter and its value look like
PDF_LIST=[URL-1] [URL-2] [URL3]. Existing samples translate the PDF URLs received through local parameter values (e.g.pdfs,user_pdf_url) to a list of this format. Shown next is an example.
pdfs=http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp|file:/c:/temp/cid_sample.pdf|http://www.activetree.com/demo/pdfapplet/samples/Certificate of Foreign Intermediary (fw8imy).pdftranslates to (by all
print_pdf*.*):
PDF_LIST=[http://www.activetree.com/silent_print_pdf_from_browser3/PdfJSPDemo2.jsp][file:/c:/temp/cid_sample.pdf][http://www.activetree.com/demo/pdfapplet/samples/Certificate of Foreign Intermediary (fw8imy).pdf]
You can receive your document URLs and other APPLET parameters value through any local parameters of your choice.
However, all such local parameters value must be translated
and be passed to the APPLET using the known parameters name mentioned in the table. To know more about how these parameters
(name and value) are constructed look at the
OBJECT and EMBED tags in the view_pdf.* and print_pdf*.* files.
All jar files located under browser_lib are used by the browser to print and view PDF documents.
All jars and classes located under WEB-INF/lib/ and WEB-INF/classes/ are used by server
side programs such as the included JSP, PHP, and other programs. If there are no jars in the "WEB-INF/lib" and
the "WEB-INF/classes" directory is empty that means included server programs are dependent only to the JRE.
Copyright © 2008 Activetree, Inc. All rights reserved.
Web: http://www.activetree.com
Email: sales@activetree.com
Tel: +1 408 716 8414 Fax: +1 408 716 8450