Using JavaScript with CorelDRAW

JavaScript can be used to automate tasks in both the Windows and Mac versions of CorelDRAW Graphics Suite. The simple JavaScript sample included in this tutorial will help you get started with JS scripts in CorelDRAW.

The JavaScript sample adds a watermark to the active page of your document. It calculates the page width and height, creates a new layer, and places two text objects on the page. One is the text Company Name that appears in the lower-right corner of the page. The other text object Watermark is placed in the middle of the page, at a 45-degree angle. The JS sample also specifies the color and transparency of the text objects.

To give the JavaScript sample a try, you will first need to create a JS script that includes the JS sample, from within CorelDRAW. Next, you will run the script.

Note: The procedures in this tutorial apply both to the Windows and Mac version of CorelDRAW, but the screen captures were taken on Windows.

To create the script

1. Copy the following JS sample.

//Calculate the page width and height, and store the values in pWidth and pHeight.pWidth = host.ActivePage.SizeWidth