After using CorelDraw professionally for a few years I’ve come to find how extremely helpful implementing the use of scripts and macros can be in this program, especially with the repetitive little tasks that always end up just being a giant pain. Using the CorelDraw print merge function always leaves you still needing to combine pages and mass align objects but luckily there is a solution!
Recently I’ve added a few scripts such as moving all objects or groups from the entire document to page 1 (combining pages) or aligning all objects on page in a grid the width of the canvas and these have become an integral part of my day-to-day workflow. They have just generally made my life so much easier.
Now, if you’ve ever used CorelDraw for layout, design, or printing then you are definitely familiar with the dreaded ‘print merge’. Print merge is a function of Corel that can substitute text in a design from a text document, excel, or .csv file.
For example, if you have a certificate design that has a place for a name and serial number. Print merge would be able to take the names and serial number from an excel file and substitute that into the certificate design automatically and put those customized certificates on a separate pages.
This is a fantastic inclusion from Corel but being on separate pages make it such a pain when dealing with thousands that you have to lay it out to print or cut. Lucky these two scripts are going to make your time dealing with print merges so much easier!
How to Add New Scripts in CorelDraw
- In Corel turn on the Scripts Window. “Windows>Dockers>Scripts”
- Navigate to the Scripts Window
- Click on User Scripts ‘JavaScript>User Scripts’
- On the top of Scripts Window, click on ‘New’ then ‘New Macro’.
- Copy and paste the whichever script you want and click save on notepad.
- The script will be in the script window under JavaScript User Scripts. You can also rename it from here.
- You can run the script by double clicking on it.
Combine Pages after CorelDraw Print Merge
The following script was made to use after running a print merge to a new document. This will then take everything on each separate page in the document and move it to the first page. This is so you don’t have to waste an eternity dragging around the objects from each individual page.
Keep in mind that running this script will work even though it will give you error message.
var targetLayer = host.ActiveDocument.Pages.Item(1).Layers.Item("Layer 1");
for (var i = 2; i <= 300; i++) {
var currentPage = host.ActiveDocument.Pages.Item(i);
var currentPageShapes = currentPage.Shapes.All();
// Move all shapes on the current page to the target layer
currentPageShapes.CreateSelection();
host.ActiveSelection.MoveToLayer(targetLayer);
// Order the shapes to the front on the current page
for (var j = 1; j <= currentPageShapes.Count; j++) {
currentPageShapes.Item(j).OrderToFront();
}
}
Align all Objects or Groups on Page – CorelDraw Script
This script is meant for after you run a print merge and the above script. You can then run this and it will align all the objects or groups on page into a grid that is the width of the page. This is especially useful when you need to laser engrave name plates, badges, or something similar that you need to be side by side butting up next to each other.
Keep in mind when you run this script it will also leave one of the objects or groups in the center of the page, but after running it, you can then move that leftover one to wherever you need. Small price to pay considering how much weight this script pulls!
// Get the active page
var activePage = host.ActivePage;
// Get all objects or groups on the active page
var allObjects = activePage.Shapes.All();
// Define the desired width and height of each cell (based on the size of the first object)
var cellWidth = allObjects.Item(1).SizeWidth;
var cellHeight = allObjects.Item(1).SizeHeight;
// Calculate the number of columns based on the page's width
var pageWidth = activePage.SizeWidth;
var numCols = Math.floor(pageWidth / cellWidth);
// Calculate the number of rows necessary to accommodate all objects with the same size
var numRows = Math.ceil(allObjects.Count / numCols);
// Iterate through all objects and position them in the grid
for (var i = 0; i < allObjects.Count; i++) {
var object = allObjects.Item(i);
// Check if the object is not null
if (object != null) {
// Calculate the grid position
var row = Math.floor(i / numCols);
var col = i % numCols;
// Calculate the new position
var newX = col * cellWidth;
var newY = row * cellHeight;
// Set the new position for the object
object.PositionX = newX;
object.PositionY = newY;
}
}
Wrapping Up
Wow, CorelDraw really is an amazing program especially when you’re in the layout and design field. Having these scripts and macros on standby will make your day go by just that much easier! Hopefully you get as much use out of them as I have. If you’ve found use from these scripts don’t forget to show your support by sharing this article to someone else you think could benefit! Happy Designing!