Class PrintCommand

java.lang.Object
com.oorian.messaging.commands.Command
com.oorian.messaging.commands.PrintCommand

public class PrintCommand extends Command
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 Details

    • PrintCommand

      public PrintCommand(String url)
      Constructs a new PrintCommand to print a URL.
      Parameters:
      url - the URL to print
    • PrintCommand

      public PrintCommand(String url, String name)
      Constructs a new PrintCommand to print a URL with a window name.
      Parameters:
      url - the URL to print
      name - the name of the print window
    • PrintCommand

      public PrintCommand(String url, String name, String params)
      Constructs a new PrintCommand to print a URL with a name and parameters.
      Parameters:
      url - the URL to print
      name - the name of the print window
      params - the window parameters (e.g., "width=800,height=600")
    • PrintCommand

      public PrintCommand(HtmlPage page)
      Constructs a new PrintCommand to print HTML content.
      Parameters:
      page - the HtmlPage object containing the content to print
    • PrintCommand

      public PrintCommand(HtmlPage page, String name)
      Constructs a new PrintCommand to print HTML content with a window name.
      Parameters:
      page - the HtmlPage object containing the content to print
      name - the name of the print window
    • PrintCommand

      public PrintCommand(HtmlPage page, String name, String params)
      Constructs a new PrintCommand to print HTML content with a name and parameters.
      Parameters:
      page - the HtmlPage object containing the content to print
      name - the name of the print window
      params - the window parameters (e.g., "width=800,height=600")
  • Method Details

    • toJson

      public JsonObject 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.

      Specified by:
      toJson in class Command
      Returns:
      a JsonObject containing the print command data