Free

Free coded apps to suit all. No sign up, no email, usable offline, updates when I can, feedback welcome. Send feedback

Behind the scenes

Automating Layout by Zaweba from the command line

Run Layout by Zaweba commands by id with JSON, and export PDF, PNG, EPUB and more from the command line with no window, for batch and repeat jobs.

Automating Layout by Zaweba from the command line

Automation in Layout by Zaweba comes in two linked forms: a command API, where every command can be run by its id with JSON arguments, and a command line that can export files or run a list of requests without opening a window. Most people never need either. For anyone producing many similar files, they turn hours of repetitive clicking into a single step.

Commands by id

Every command can be run by id, given JSON arguments, and returns a JSON result. Each command run this way is one undo step. The command ids include commands.list, which lists the commands, document commands, pages.list and page.add for pages, frames.list, frame.get, frame.add, frame.set and frame.delete for frames, text.get and text.set for text, and selection.get and selection.set for the selection.

That set covers the basics of reading and changing a document: find the pages, find the frames, read or change their properties and text. A tool that keeps product details elsewhere could use it to fill text frames, for example.

Exporting from the command line

The command line export takes a file or folder and a format: ZawebaLayout.exe --export with the file or folder, then --format followed by pdf, png, jpeg, tiff, svg, epub, html, text, rtf or package. Optional switches are --out for where the results go, --preset to name an export preset, and --subfolders to include folders inside the one you gave.

Point it at a folder of documents with --format pdf and a preset, and you get a PDF of each one. Use --format package to collect each document with what it needs. Use png or jpeg for preview images. No window opens, so it can run while you do something else, or from a scheduled task.

Running a list of requests

The --run switch takes a requests.json file, a list of commands to run, and --out results.json writes the results. It also runs with no window. This is how you'd chain several commands together, such as adding a page, adding a frame and setting its text, as one repeatable job.

When automation is worth it

It pays off when a job repeats. A weekly price list that only changes its numbers, a set of documents that all need exporting to PDF and EPUB, or a folder of files that need preview pictures for a website are the sort of work where a command line run saves real time.

For one-off jobs, the normal app is quicker. Writing a requests file takes longer than clicking through a single export.

Automation mistakes to avoid

Test on copies. A request that sets the text of the wrong frame will do it to every document you run it on.

Keep export presets named and stable. If the command line uses --preset, changing that preset in the app changes every automated export that uses it.

Check results. With no window, it's easy to assume everything worked; the results file and the exported files are where you find out.

For most people, Layout by Zaweba is a desktop app you drive with a mouse. For the times you need it to work unattended, the command API and command line are there.