Script Reference : Layout
Layout object is a print preview window. This class is accessible via global layout variable.
Name | Type | Description |
---|---|---|
Printer
printer |
string | Active printer |
tray | string | Input tray. |
size | Point | Output paper size in mm. You may change output size by changing this value. However not all sizes are supported by the real printer. Even in case if size is valid, you may need to define a form with this size in advance. See AdjustPaperSize script. |
Page
Layout
mode |
string | Layout mode. "Standard", "Booklet", "Poster". |
rows, CY | int | number of rows in the table |
columns, CX | int | number of columns in the table |
original | bool | orignial layout on/off |
orientation | string | "Portrait", "Landscape", "Auto" |
duplex | bool | Double sided mode on/off. |
gutter | bool | Gutter visibility mode on/off. |
gutterSize | float | Size of gutter in mm. |
gutterPos | int/string | Gutter position. "left", "top", "right", "bottom","horizontal", "vertical" |
gutterPrint | bool | Print gutter line on/off. |
hwMargins | bool | Hardware margins on/off. |
scaleMode | int | Source page scaling mode. 0 - unique scale, 1 - uniform scaling, 2 - custom scaling |
scaleFactor | float | Source page scale factor. Used only when scaleMode==2 |
repeat | bool | This option is related to Repeat checkbox in Page Layout tab. |
jobFromNewSheet | bool | This option is related to Job from New Sheet checkbox in Page Layout tab. |
pagesOrder | int | Pages order flags. It's a bit combination of: PG_ORDER_LEFT_TO_RIGHT 0x01 PG_ORDER_TOP_TO_BOTTOM 0x02 PG_ORDER_Y_MAJOR 0x04 |
hSeparator | float | Horizontal separator in mm |
vSeparator | float | Vertical separator in mm |
hSeparatorF | float | Horizontal form separator in mm |
vSeparatorF | float | Vertical form separator in mm |
Effects
bkColor |
Color | Page background color. In order to set black color, use color with non zero alpha. To remove background color set all members to 0. |
pageBorders | bool | Show and Print page borders |
grayscale | bool | Graysclae mode on/off |
nographics | bool | No graphics mode on/off |
blacktext | bool | Black text mode on/off |
brightness | float | Brightness amount. |
contrast | float | Contrast amount. |
economode | int | 0 - no, 50,100 are the levels of toner/ink saving mode. |
Booklet
blFromStart |
bool | Start from first page |
blSub | bool | Sub booklet mode. |
blSheetsPerBooklet | int | Maximum number of sheets per booklet. This parameter is for sub booklet mode. |
blCutUp | bool | Cut-Up booklets. |
blCutUpPrint | bool | print cut lines on/off |
RTL | bool | Right-to-Left text. This option for booklets mostly. |
1.
layout.mode="Standard";
layout.duplex= !layout.duplex;
2.
layout.gutter= true;//!layout.gutter;
layout.gutterSize=layout.gutterSize+1;
3.
local c=Color(0,0,0,255); // black color
layout.bkColor=c;
Name | Return Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Document GetDocument() | Document | Retrieves main document object. Same as window.GetDocument(); | ||||||||||||||||||||||||
Document GetDocumentF() | Document | Retrieves form document object. | ||||||||||||||||||||||||
void SelectAll(bool bSelect) | - | Select or unselect all paper sheets. | ||||||||||||||||||||||||
bool ApplyTheme(string) | bool | Load and apply theme file. File name could be full or short. In the last case theme should be in the theme folder. | ||||||||||||||||||||||||
bool SetForm(string) | bool | Load and apply form (letterhead) document. File name could be full or local one. | ||||||||||||||||||||||||
bool SetFormMode(string, ...) | bool | Sets form mode. Available modes are:
|
||||||||||||||||||||||||
bool SetMargins(Rect) | bool | Sets margins | ||||||||||||||||||||||||
bool SetMarginsF(Rect) | bool | Sets margins related to form page. | ||||||||||||||||||||||||
Rect GetMargins() | Rect | Returns the margins. | ||||||||||||||||||||||||
Rect GetMarginsF() | Rect | Returns the form margins. | ||||||||||||||||||||||||
bool SetLayout(int cx,int cy) | bool | This one is faster than using CX, CY. | ||||||||||||||||||||||||
Markups
int GetNumMarkups() |
int | Returns the number of global markups. | ||||||||||||||||||||||||
Markup GetMarkup(int i) | Markup | Return required markup. | ||||||||||||||||||||||||
Markup GetMarkupById(int i) | Markup | Return required markup by id. | ||||||||||||||||||||||||
Markup CreateMarkup(string type) | Markup | Create empty markup. Where type is type of markup. See Markup specification fro the list of possible values. | ||||||||||||||||||||||||
bool DeleteMarkup(int i/ Markup) | bool | Delete markup. Markup can be specified by index or Markup itself. | ||||||||||||||||||||||||
Sheets
int GetNumSheets() |
int | Gets the number of sheets. | ||||||||||||||||||||||||
Sheet GetSheet(int) | Sheet | Returns the specified sheet. | ||||||||||||||||||||||||
Sheet NewSheet([int index]) | Sheet | Creates new, empty sheet of paper. | ||||||||||||||||||||||||
bool DeleteSheet(int index) | bool | Deletes specified paper sheet. | ||||||||||||||||||||||||
void Clear() | Deletes all paper sheets. This method is useful for implementing very custom page layouts. Please note that changes of other layout options could case layout recreation with default settings. | |||||||||||||||||||||||||
Print
bool Print([Optional Table]) |
bool | Prints document to currently selected printer. Without extra
options method is
similar to clicking on "Print Now" button.
Additional options are:
|
||||||||||||||||||||||||
bool SaveAsPDF(string filename, [Optional Table]) | bool | Saves document to a PDF file. Options provided in the table
will override options specified in UI. This is synchronous method, after calling, PDF is fully ready. Additional options are:
|
||||||||||||||||||||||||
[] GetTrays() | array | Returns array of trays in current printer. Each item is name of the tray | ||||||||||||||||||||||||
[] GetPrinters() | array | Returns arrays of printers. Each item is name of printer. |
Sample 1:
layout.printer="Fax"; if(layout.tray=="Default Tray") layout.tray="Manual Feed"; else layout.tray="Default Tray"; print(layout.tray+"\n");
Sample 2.
local r=layout.GetMargins();
r.left+=1;
r.top+=1;
r.right+=1;
r.bottom+=1;
layout.SetMargins(r);
Sample: print the selection without Print dialog.
local count=layout.GetNumSheets(); for(local i=0;i<count;i++) { local p=layout.GetSheet(i); p.selected= ((i&1)==0); } layout.Print({dialog=false, selection=true, skipEmpty=false});
Sample: print first page 10 times without Print dialog.
layout.Print({dialog=false, from=0,to=0, skipEmpty=false,copies=10});
Sample: print first 2 pages, 4 times. options
local options={dialog=false, from=0,to=1, skipEmpty=false,copies=4,collate=1}; layout.Print(options);---
layout.SaveAsPDF("c:/temp/test.pdf", {dialog=1,protection="AES_128",pswView="1234",pswEdit="1234"});
layout.SaveAsPDF("c:/temp/test.pdf", {dialog=1,protection="none",imgMaxDPI=150,imgQuality=-1});
layout.SaveAsPDF("c:/temp/test.pdf", {dialog=1,protection="RC4_40",imgMaxDPI=200,imgQuality=0.85, pswView="",pswEdit="",pswFlags=0});
Sample: setFormMode
layout.SetFormMode("repeat","all"); layout.SetFormMode("repeat",0);
Custom layouts: Custom floating layout, Fixed layoyt with 3 pages per paper, Mixed layout
Layout maintains list of sheets and updates it automatically in order to reflect changes in layout properties or source document. So if you want to modify paper sheets or its content you should avoid actions which may drop your changes. For instance you may create additional sheets and put pages on the sheet in custom order, however after that you should not create additional pages or modify margins. Such things may rebuild paper sheets using current settings.