PDF generation from command line

Hello all,

My colleagues and I are working on using Dorico as a step in an automated workflow to prepare PDFs for publication.

As part of this, I’m looking for a way to use the command line to generate PDFs-- of all layouts, as if I selected them all and exported them using the Graphics tab in Dorico. But I want to call it via a command line and not start Dorico itself.

For comparison, this is possible in MuseScore via the mscore command, as documented here:

mscore -o 'My Score.pdf' 'My Score.mscz'

Is this possible? Or has anyone tried some kind of UI automation workaround (using Automator, Windows Application Driver, etc)? Our team uses Macs, but we’re opening to using Windows for this particular task if necessary.

Thanks,

Moses

1 Like

On Mac — I would advide in checking out Keyboard Maestro, which could help automate things that are not easily accessible for automation. It would invoke the GUI, and there will be significant overhead compared to a command line option (which I am not aware of) but it will work given some time setting up the macro.

There’s nothing natively in Dorico to do this.

What’s your entire workflow? Any reason it couldn’t start with the PDF itself? For instance, I have lots of scripts for manipulating PDFs, which I use in combination with Folder Actions to automatically perform actions on PDF files when they are saved, e.g. making booklets, adding page numbers, etc.

The act of saving the PDF from Dorico into automated workflows is my way of announcing that the project is finished and ready for the next step.

It would be surprising if the developers have no way to run Dorico entirely from a script, for automatic testing and replaying sessions up to the point where a problem occurred, etc, but I don’t think there is any user-level documentation for it.

There’s no specific reason that it can’t start with the PDF other than that it’s simply an extra step we should be able to avoid. We are using GitLab to version control and run our automation. From a production standpoint, the PDFs are not source code, they are a compilation artifact, so it introduces possibility for error if we have to check them into source and not generate them automatically from the current version of a Dorico file (for example, someone might check in a version but forget to update the resultant PDFs, or check in old PDFs, which would result in old work being reviewed rather than current work).

In short, it’s a step that takes time and effort to remember to do, and we want to not do it if possible, as 5-10 minutes of work generating the PDFs over many revisions, as well as the possibility of human error / mismatch, works out to a lot of time.

As for the other parts of our workflow, we are also auto-generating title pages, front and back matter, and assembling the PDFs, adding barcodes, blank pages for booklet printing, etc. The other parts are already via script; the Dorico part is the only thing we’re missing.

Thanks for this suggestion, I will check it out. Obviously, we would prefer to not have to invoke the GUI, but we were prepared to have to and use macros, so we might go this path. The amount of overhead is annoying but not a dealbreaker, since it will happen on a central runner away from people’s workstations, so a 1-minute run time and a 10-second run time aren’t that different.

You can use Dorico’s Lua scripting to print to PDF (including all the print options), but you’ll still need some method of launching Dorico, selecting and triggering the script, but that might minimize the GUI macro part.

You can assign a keyboard shortcut for Export All Layouts As PDF…

1 Like

True, but you’ll already have to set up the print options and destination folder.

If you leave them untouched they’re predictable: you get a normal print job exported to the same folder as the Dorico file.

I can confirm that there’s no specific command-line switch for Dorico to export PDFs from a project passed in as an argument, but I’ll make a note of this and we’ll look into adding support for it in future.

My colleague and I tried the Export All Layouts as PDF keyboard shortcut. It seems to work, but the generated PDFs only have the first page.

Have we done something wrong? We are using version 2.2.20 build 1286.

It sounds like, on at least one of the layouts, a range is set in Print mode (page 1 to some other number). You need to ensure that each layout is set to Job Type > Normal > All Pages.

All the layouts are set to print all pages already. If we do it by clicking the Export button, it generates full files. It’s only if we use the keyboard shortcut for Export All Layouts that we get PDFs with only one page.

Are you 100% sure that with Graphics Export selected, all the layouts are set to export all pages? That’s what I meant, even if I didn’t explain it entirely explicitly!

This is what our window looks like (we are on macOS)


Again, if we simply click the Export button at the bottom right, it generates all pages. This one-page behavior only happens when using the Export All Layouts as PDF keyboard shortcut.

Does that screenshot accurately describe what you see if you Shift+select all layouts in the left panel?

I also regularly find Dorico has only exported the first page of my layouts, despite never using the option. To print only one page. If I just reselect the layouts and try again, it usually works on the second or third try.

It seems to be some strange timeout issue, where if the program takes too long in calculating things it gives up and only exports the first page. Sometimes if I’m selecting many parts, the first few include all the pages and then rest just the first page.

Here is what it looks like with all layouts selected.

We tried the keyboard shortcut again, and got the same results (first page of layout in the PDF).

Yes, that’s an expected setting when you select all layouts, unfortunately. You need to then manually select the desired output.

Read here too: https://www.steinberg.net/forums/viewtopic.php?f=246&t=154730