Generate JViewPro Reports without Using JViewPro
Ideally, a JViewPro report is generated by JViewPro itself. But, if your server
platform's JDK is not JDK 1.2 or Java Swing compliant, you can still generate JViewPro
reports without using JViewPro.
A JViewPro report can be defined by script, which uses JViewPro's relevant properties and
methods. A report script example is provided at the bottom. As you can see, the script is
fairly self explaining. As such, you can use any programming languages (including any
version of Java JDK, C/C++ etc) to generate JViewPro reports without using JViewPro.
For your convenience, a Java class, 'Script' has been provided for generating JViewPro
reports without using JViewPro. The class can be used by any version of Java JDK. Click here to download
ScriptSample.java, which includes the class and the sample project showing how to use
the class to generate a JViewPro report.
How to Generate
Use the 'Script' class to generate and save report script.
-To set a JViewPro property (or some relevant methods), use the class's addLine
method;
-To add a text or graphics object, use the class's addObject method that has the
same arguments as the corresponding JViewPro's; and
-To save the script, use the saveScript method.
How to View and Print
The generated script can be loaded, viewed and printed using JViewPro JavaBean embedded in
your applets or applications. The related JViewPro methods are loadScrip, loadScriptURL,
preview and printPages. For test purpose, you can also view and print the script using the
Mini Viewer supplied with the trial copy (the program is in the Viewer sub-directory under
the demo directory).
Sample JViewPro Report Script
//--------------------------------------------
//Sample JViewPro report script
//default unit: 1 inch = 72
vp.setUnit(72.0);
//paper size
vp.setPageWidth(612.0);
vp.setPageHeight(792.0);
//-----first page (page index=0)
vp.setPageIndex(0);
//portrait
vp.setPageAttrib("orientation=1");
//draw a string (objectType=8)
vp.addObject("myStringObject", 8, 0.0, 72.0, 0.0, 0.0, "Hello World",
"", "fontSize=18;fontBold=true;textColor=RGB(255,0,0)");
//draw a table (objectType=11)
vp.addObject("myTableObject", 11, 0.0, 144.0, 0.0, 0.0,
"Header1|Header2|Header3;col1|col2|col3","tableFormat=72|72|144",
"objectBorderOn=true;fontSize=12");
//store the page
vp.storePage();
//-----second page (page index=1)
vp.setPageIndex(1);
vp.setPageAttrib("orientation=0");
//draw a table
vp.addObject("myTableObject2", 11, 0.0, 72.0, 0.0,
0.0,"Header1|Header2|Header3;col1|col2|col3", "tableFormat=72|72|144",
"objectBorderOn=true;fontSize=12");
vp.storePage();