Script Reference : Page

Page is a class for source page. This page is a part of printer job.

Data Members
Name Type Description
size Point Page size in mm. Same as GetSize(0);
selected bool Property is True in case if page is selected
visibility bool Page is visible. Related to source page checkbox in priPrinter UI.
removed bool true if page is removed from document.
angle int, float [0,1,2,3] Page rotation angle, where 1 - 90º, 2 - 180º, 2 - 270º
document Document Initial page document. (Read only)
Point Current text cursor used by Print function. This is read write data member, however in order to change it please assign variable of Point type and do not modify x,y data members directly.
font Font Current font size used by Print function.
fontColor Color Current font color.


Name Description
---- Page Object may exist in Document only and can be retrieved or created by document methods only.


Name Return Type Description
Sheet GetSheet() Sheet Retrieves sheet of paper which owns this page.
void Print(string ) void Method prints text string on the surface of this page using current font, font size and color. Cursor position is updated.
Point GetSize(int area*=0)
Point Returns dimension or the whole page size. Size is in mm.
Point GetAreaSize(int area=0) Point Returns dimension or printable page area.
Point GetAreaOrg(int area=0) Point Returns origin of printable page area.
bool SetSize(Point) bool Methods allows to change original page size. Method returns false in case if parameter is of wrong type or current size is the same.
bool PageToSheet(Point,...) bool Converts a set of points from a coordinate space relative to page to a coordinate space relative to sheet of paper (Sheet). All coordinates are in mm.
bool SheetToPage(Point,...) bool Converts a set of points from a coordinate space relative to sheet of paper (Sheet) to a coordinate space relative to a source page. All coordinates are in mm.
Crop & Cut
Rect GetCrop()
Rect Returns coordinates of crop rectangle.
void SetCrop(Rect crop) void Sets new crop rectangle.
Rect GetCut(int index) Rect Retrieves coordinates of specified cut rectangle. Index of first cut area is 0.
bool SetCut(int index, Rect cut) bool Sets coordinates of already existed cut rectangle.
int NewCut(Rect cut) int Creates new cut rectangular area. In case of success methods returns index of created area. -1 is returned in case of error.
bool DelCut(int index) bool Deletes cut area. In case of success true is returned.
bool DelCutAll() void Method deletes all cut areas.
int GetNumCuts() int Method returns the number of existed cut areas in this page.
Rect AutoCrop() Rect Methods enumerates all graphic records in the page and computes rectangle which covers these records. In case if crop rectangle is large or equal to page work area NULL is returned. In case of error NULL returned as well. Result is in mm in original page space. See example
int GetNumMarkups()
int returns the number of assigned to page markups.
Markup GetMarkup(int i) Markup Returns required markup by its index.
Markup GetMarkupById(int i) Markup Return required markup by id.
Markup AddMarkupFromFile(string) Markup Loads markup from xml file.
Markup CreateMarkup(string type) Markup Creates empty markup
bool DeleteMarkup(int i/ Markup) bool Delete markup. Markup can be specified by index or Markup itself.
string GetText([Rect srcRect] [,Table params])
string Retrieves text from the whole page or from portion of the page. srcRect - is the optional parameter. Coordiantes are measured in original non cropped and non rotated page.
For instance you may ask for text in the known place of page. It may be email address, account number , company name, etc.
Optional parameters could be passed to this function.
charArea Part of character's area that should be inside of rectangle. 1.0 means that all parts of chracter should be inside rectangle. 0.5 - at least half of chracter should be inside. Default is 0.0 and this means that at least one character pixel should be inside.
See example
int Search(string [,Table params]) bool Method searches for occurrence of text string specified. Optional parameters can be passed in second parameter.
matchcase If set to true, the search will be case-sensitive. If false search will be case-insensitive.  false is default.
wholeword if true - search only for whole words that match the search string. false is default.
See example
bool SetTextColor(Color) bool Method sets color of all texts in this page. See example. New
bool SetTextFontName(string) bool Method sets font name of all texts in this page. See example. New
bool SetTextFontSize(float) bool Method sets size of all texts in this page. See example. New
bool DeleteRect(Rect)
bool Method deletes text and graphics inside specified rectangle.
File CopyRect(Rect) File Copies rectangle content to stream. You can insert this stream to any page. See example and description below.
bool Paste(File ,Point p) bool Paste previously copied content to a new position.
bool IsRectEmpty(Rect[,bool bSkipWhite]) bool Method checks for presence of any graphics inside specified rectangle. When optional bSkipWhite parameter is set to true, all white graphics commands will be skipped by this test. This parameter is false by default.
int GetNumBookmarks()
int Gets the number of bookmarks attached to this page.
Bookmark GetSubBookmark( int index ) Bookmark Returns bookmark by index.
Bookmark InsertBookmark( [int index]) Bookmark Creates bookmark. Index is optional. If index is not specified, bookmark will be inserted in the end of the list.
bool DeleteBookmark(int index or Bookmark) bool Method deletes bookmark. Bookmark to delete can be specified by index or by bookmark itself.
int DeleteAllBookmarks() int Reurns number of deleted bookmarks.


*Where iarea defines type of information to retrieve. Size of page may be different due to rotation and cropping.
0 - current page, 1 - original non rotated job page, 2 - original optionally rotated page.

GetText, DeleteRect, CopyRect, Paste, IsRectEmpty - coordiantes are measured in original non cropped and non rotated page. If you want to measure cooridnates for this functions in priPrinter, select Original layout, remove page rotation (if any) and move mouse cursor across point of interest. Or use measure tool.



local doc=window.GetDocument();
local page=doc.GetPage(0);



local doc=window.GetDocument();
local page=doc.GetPage(0);
local count=page.Search("const",{matchcase=true,wholeword=true});


local doc=window.GetDocument();
local page=doc.GetPage(0);
local text=page.GetText(Rect(11.0,38.0,110,47));
local area=Rect(18,25.0,31.0,30.3);
local text=page.GetText(area,{charArea=0.6}); 


local doc=window.GetDocument();
local count=doc.numpages;
for(local i=0;i<count;i++)
   local page=doc.GetPage(i);
   local r= page.AutoCrop();

Copy and Paste*

It's possible to copy rectangular area from one page to the same page or any other page. Method CopyRect copies content and returns stream with all objects and resources. This stream can be inserted unlimited number of times. You may copy stream to a file on the disk and use it later.

 File will be in priPrinter file format, however it can't be opened correctly in priPrinter itself.

If you want to move content across page canvas, copy area to stream, delete area and paste to a new position.

Sample below copies rectangle to a stream in memory and saves it to the disk. Code in the "else"  branch inserts previously copied content to another page.

local doc=window.GetDocument();
local page=doc.GetPage(0);

if(1)// copy
	local stream=page.CopyRect(Rect(42,40,154,47));
		local file=File("c:/temp/rect.priPrinter","w");
}else  //paste
	local file=File("c:/temp/rect.priPrinter","r");

There is one limitation, DPI of source and destination page should be same.

*Bookmark. This is preliminary documentation and is subject to change.