Package com.oorian.messaging.commands
Class PrintCommand
java.lang.Object
com.oorian.messaging.commands.Command
com.oorian.messaging.commands.PrintCommand
Command to print a document from a URL or HTML content.
This command opens a print dialog for the specified URL or dynamically generated HTML content. It supports window naming and parameter configuration, allowing control over the print window's appearance before printing.
Features:
- Initiates browser print dialog
- Supports URL-based or HTML content-based printing
- Configurable print window parameters
- Named print windows
- URL encoding for safe transmission
Usage:
// Print a URL
PrintCommand print1 = new PrintCommand("http://example.com/report.html");
// Print with window name
PrintCommand print2 = new PrintCommand("http://example.com/report.html", "reportWindow");
// Print with name and parameters
PrintCommand print3 = new PrintCommand(
"http://example.com/report.html", "reportWindow", "width=800,height=600");
// Print HTML content
HtmlPage page = new HtmlPage();
PrintCommand print4 = new PrintCommand(page, "invoiceWindow");
- Since:
- 2007
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPrintCommand(HtmlPage page) Constructs a new PrintCommand to print HTML content.PrintCommand(HtmlPage page, String name) Constructs a new PrintCommand to print HTML content with a window name.PrintCommand(HtmlPage page, String name, String params) Constructs a new PrintCommand to print HTML content with a name and parameters.PrintCommand(String url) Constructs a new PrintCommand to print a URL.PrintCommand(String url, String name) Constructs a new PrintCommand to print a URL with a window name.PrintCommand(String url, String name, String params) Constructs a new PrintCommand to print a URL with a name and parameters. -
Method Summary
Modifier and TypeMethodDescriptiontoJson()Generates the JSON representation of this print command.Methods inherited from class com.oorian.messaging.commands.Command
getElementId, getId, setElementId, toString
-
Constructor Details
-
PrintCommand
Constructs a new PrintCommand to print a URL.- Parameters:
url- the URL to print
-
PrintCommand
Constructs a new PrintCommand to print a URL with a window name.- Parameters:
url- the URL to printname- the name of the print window
-
PrintCommand
Constructs a new PrintCommand to print a URL with a name and parameters.- Parameters:
url- the URL to printname- the name of the print windowparams- the window parameters (e.g., "width=800,height=600")
-
PrintCommand
Constructs a new PrintCommand to print HTML content.- Parameters:
page- the HtmlPage object containing the content to print
-
PrintCommand
Constructs a new PrintCommand to print HTML content with a window name.- Parameters:
page- the HtmlPage object containing the content to printname- the name of the print window
-
PrintCommand
Constructs a new PrintCommand to print HTML content with a name and parameters.- Parameters:
page- the HtmlPage object containing the content to printname- the name of the print windowparams- the window parameters (e.g., "width=800,height=600")
-
-
Method Details
-
toJson
Generates the JSON representation of this print command.The JSON includes the command ID, URL (if URL-based), window title/name, parameters, and HTML content (if content-based). URLs are encoded for safe transmission.
-