Printtopdf doesn't recognise either 'portrait' or 'landscape' as an orientation value



I get a similar message for landscape. My code is:

openform "CertBodyReport"
printtopdf "orientation","portrait", "Height",30,"Width",21

Dimensions are metric.


I think you need other options before that. For instance

printtopdf "~/Desktop/Envelopes.pdf","Form","Envelope","Height",9.5,"Width",4.125,"orientation","landscape"

works for me.


I’m actually trying to replace a print "" statement so I should have included a "printer',"" option in the list. That gets rid of the orientation problem. Do I need to specify paper dimensions or will the printer software handle that, having specified the orientation?

So far, all I’m getting (from what should be a two-page report with lots of stuff on it) is a single, near-empty page with nothing but the footer on it.


I specify dimensions because my printer chooses the tray according to the size. I think it will change the page setup if you use a different size, so specifying the dimensions is a good idea.

I use Print Preview a lot to get things right. It might be best to print the pages separately (two different forms) until the printing gremlins go away. I have always done that to get side by side pages, and now I do that to print a letter followed by an envelope.


Jim suggests that this might not happen.

I may have confused you - the report is two pages long, not two separate pages - it’s just one print statement. Even when it’s only one page, the problem persists.


Let’s take a closer look at this original code to understand why the error is occuring.

The first parameter of the printtopdf statement is always the name (and optionally the path) of the file you want the PDF saved into. Even if you are going to print directly without generating a PDF file, you still have to include this parameter (when direct printing you can use "" as the file name).

So in Michael’s code, this statement is going to save the PDF to a file named orientation. So things are out of whack from the start.

The second parameter is the name of an option. The code specifies "portrait", but that is not one of the available options (legal options include “form”, “database”, “onerecord”, “orientation”, and a few others). So the error message is not saying that “portrait” is not a legal orientation, it is saying that there is no option named “portrait” at all.

Here is an example with an orientation that Panorama doesn’t understand.

printtopdf "test.pdf","orientation","tall"

In this case, you’ll get an orientation specific error message

PrintToPDF failed because orientation tall is not recognized

You only need to specify the paper dimensions if it is non-standard. If you leave the paper dimensions off, the default paper size will be used (usually 8.5 x 11 in the US, not sure about other countries).

Nope, sorry, as the documentation states, the dimensions are in inches unless the value is 72 or more, in which case it is in points. So your original code would specify a height of 30 inches by 21 inches. Centimeters are not allowed.


Oh dear! At least I spelled printtopdf correctly. :frowning_face: