Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Print - method of the PmgRoot object

Description:
Print the open panel (or its part) to a printer or into the file.
Syntax:
Empty Print(String sOptions)
Parameters:
sOptions(String) Additional parameters that define the way of printing (crop, etc.). If not set, then the whole panel is printed with default settting. The value of the sOptions parameter is taken also from the static default object setting, see sFramePars default value. Entries are in the KeyVal format, for example "x:0;y:0;dx:300;dy:200;printer:select;printzoom:0;".
"x:nn;" (optional) - x-position of the left upper point of the cutout (in pixels, default 0).
"y:nn;" (optional) - y-position of the left upper point of the cutout (in pixels, default 0).
"dx:nn;" (optional) - Size of the x-crop (in pixels, default 0 = the whole panel).
"dy:nn;" (optional) - Size of the y-crop (in pixels, default 0 = the whole panel).
"printer:xx;" (optional) - It allows to select and configure the printer.
select (default) - The system window will be displayed for printer setup.
default - Print will be executed on default OS Windows printer.
file:filepath - The file name with the path (*.bmp, *.png, *.jpg, *.gif or *.tif), where the panel or its portion will be saved. The file extension specifies the graphic format. It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files and folders. The resulting size of the image in the file is determined by the size of the panel or the selected portion.
"printzoom:nn;" (optional) - The resulting size of the image in the file is determined by the size of the panel or the selected portion.
Note:
This method is also functional in Web panels. So far the sOptions parameter is not functional for the Web (the printing also does not work).
Example1:
Print the whole panel. Print in the onButtonUp event of the button (PmgButton object) in the panel.
The panel will be stretched to the size of the paper (aspect ratio kept) and printer selection and setup window will be displayed.
JavaScriptVBScriptSelect and copy to clipboard

pMe.Root.Print("");
Example2:
Print the cutout of the panel, where the cutout begins on the position 100,100 and its size is 300,200. Print in the onButtonUp event of the button (PmgButton object) in the panel.
The panel will be stretched to the size of the paper (aspect ratio kept) and printer selection and setup window will be displayed.
JavaScriptVBScriptSelect and copy to clipboard

pMe.Root.Print("x:100;y:100;dx:300;dy:200;");
Example3:
Print the whole panel into the #temp:Img/panel.png; file. Print in the onButtonUp event of the button (PmgButton object) in the panel.
The resulting size of the image in the file is determined by the size of the panel or the selected portion.
JavaScriptVBScriptSelect and copy to clipboard

pMe.Root.Print("printer:file:#temp:Img/panel.png;");
Solution suitable for automatic printing of panela with trends:
Script called from a suitable place in the application. Opening the panel with the parPrint parameter set to "yes" for printing. The opened panel must have the parPrint parameter set to sViewPars default value and Pmg object parameters.
JavaScriptVBScriptSelect and copy to clipboard

Pm.CreateView(pMe.Pm("/Workspace"), "/PanelTrend", "pars:{parPrint:yes;}", "target:blank;").Open();
Delayed start of panel printing and panel closing. Script in the onPanelStartEnd event of the print panel.
JavaScriptSelect and copy to clipboard

if (pMe.Root.GetPar("parPrint") == "yes")
{
function OnPrint()
{
pMe.Root.Print("printer:default;");
pMe.Root.AddEventTimer(2000, 1, pMe.GetPathName(), OnClose);
}
function OnClose()
{
pMe.Root.Close("");
}
pMe.Root.AddEventTimer(2000, 1, pMe.GetPathName(), OnPrint);
}

History:
Pm8.03.00: Created
Pm8.03.22: Fixed bug: Did not work while the panel was being opened.
PROMOTIC 9.0.17 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice