<< Click to Display Table of Contents >> VPE Java Control |
The VPE Java Control is shipped in two different versions: the GUI and the Non-GUI version.
The GUI version is only available for Windows and offers an optional preview window.
The Non-GUI version has some special features on the Windows platform:
•Printing documents directly to printers
•Exporting pages as image files
•Mailing documents
The version on non-Windows platforms lacks the above features, but is in all other aspects 100% identical to the Windows-Version.
The GUI version can be found in the file
<vpe-installation-directory> / deploy / vpegui.jar
The Non-GUI version is available for all platforms and can be found in the file
<vpe-installation-directory> / deploy / vpe.jar
Make sure that any of the two VPE JAR files is in your classpath.
For the Non-GUI version the recommended way of using VPE is to export a created document to PDF and to use a PDF Reader (like Adobe Acrobat) for displaying and/or printing the document, or to send the PDF document via HTTP to a client browser.
For the use with server applications on the Windows platform, the Non-GUI version is recommended.
The common sequence of function calls is:
•Set the properties for behavior and appearance of VPE during runtime before calling the method openDoc()
•Open a document with the method "OpenDoc”
•Use all possible methods to insert VPE objects (like Write(), etc.)
•Use "PageBreak” to generate new pages
•Use "Preview” to show the preview to the user, this is optional and only supported in the GUI version for the Windows platform
•Use "PrintDoc” to print the document (only supported in the GUI version for the Windows platform), or WriteDoc() to export it
Example:
Create a file named “VpeTest.java” with the following code:
import com.idealSoftware.vpe.*;
import com.idealSoftware.vpe.events.*;
class VpeTest {
public static void main(String[] args) { |
VpeControl doc = new VpeControl(); |
doc.openDoc(); |
doc.print(1, 1, "Hello World!");
doc.writeDoc("hello world.pdf");
doc.closeDoc();
} |
}
Compile with: javac -classpath ..\deploy\vpe.jar VpeTest.java
Execute with: java -cp .;../deploy/vpe.jar VpeTest
Make sure to adjust the classpath, so that it points to the VPE JAR file in your environment.
For the Windows platform, here is a version which shows a preview window:
Please note that the major difference to the previous version is one additional line of code with a call to “Doc.preview()” (and a method pause()).
Create a file named “VpeGuiTest.java” with the following code:
import com.idealSoftware.vpe.*;
import com.idealSoftware.vpe.events.*;
import java.io.*;
class VpeGuiTest {
static void pause() |
{ |
try |
{ |
System.out.printf("\n\n Press ENTER..."); |
System.in.read(); |
while (System.in.available() > 0) |
System.in.read(); // flush the buffer |
} |
catch (IOException e) |
{ |
System.out.printf("Error\n"); |
} |
} |
public static void main(String[] args) { |
VpeControl doc = new VpeControl(); |
doc.openDoc(); |
doc.print(1, 1, "Hello World!"); |
doc.preview(); |
doc.writeDoc("hello world.pdf"); |
pause(); |
doc.closeDoc(); |
} |
}
Compile with: javac -classpath ..\deploy\vpegui.jar VpeGuiTest.java
Execute with: java -cp .;../deploy/vpegui.jar VpeGuiTest
Make sure to adjust the classpath, so that it points to the VPE JAR file in your environment.
This example is very simple. A document is created, the text "Hello World!" is inserted at position (1, 1) and afterwards the document is exported to the PDF file named “hello word.pdf”.
For a detailed explanation of the basic programming techniques, please continue reading in the "Programmer's Manual" chapter 4 "Programming Techniques".