Printtopdf won't use the default printer


#1

The Help wizard says, for printtopdf:

“If this option (“printer”) is included, the printtopdf statement will immediately print instead of generating a PDF file (the path option is ignored, and can be left blank). If the printer is blank, the current default printer will be used.”

I have a Canon inkjet and a Brother mono-laser and, no matter how I set the printer default in System Preferences, Panorama X always wants to print via the Canon, even when the Canon is off and the Brother is on.

Prior posts indicate that printing from Panorama X is exceedingly fraught - is this likely to improve in the foreseeable future or is it going to be with us forever?


#2

I don’t know what prior posts you are referring to, but I am not aware of any open issues regarding printing. As far as I am aware printing in general works fine.

The default printer is set by this popup menu in System Preferences.

15%20PM

I looked into this, and unfortunately it appears you are correct. There appears to be an Apple bug. Panorama relies on Apple’s code to figure out where to print if no printer is specified. Panorama definitely has no way to know what printer is on, off, offline, or whatever. That information is all completely opaque to Panorama, as far as I know Apple does not provide any public API for that. If you always want to print to the Brother, you could hard code the name of that printer instead of leaving that parameter blank.

In fact, I discovered that Apple does not even provide any API that allows a third party program like Panorama to even find out what the default printer set by the System Preferences command is. They used to provide one ([NSPrintInfo defaultPrinter]) but it has been deprecated and removed, compile errors are generated if you try to use it, and there is no replacement API. Here is Apple’s documentation for this:

Who knows why they would do such a silly thing, but it’s not the first time, nor probably the last. I guess they expect you to use the standard print dialog and choose the printer from there. So unfortunately this is entirely out of my hands.


#3

When I searched for prior posts on printing, I saw a whole heap of problems - maybe they’ve all been fixed. I just checked and the print statement does indeed work (although the user has to click an OK button) so I’m happier than I was.

And thanks for the info on Apple’s strange move.


#4

I just did a quick check and, using the printonerecord statement, output is directed to the printer that I nominate as the default. The printtopdf statement doesn’t behave that way. I’ll do a more thorough test tomorrow - is it possible that the Panorama X implementation of the latter statements has a bug?


#5

I tried this:

message tagdata(shellscript({lpoptions}),{printer-info='},{'},1)

This returned the current default printer and was changed when I changed the default in the System Preferences panel. Don’t know if it could be used in this situation or not.


#6

I just noticed the info(“printer”) function which is suppose to return the current default printer name. I don’t know what method is used to procure the default name but if you change the default in the System Preferences it is not recognized by the info(“printer”) function which still returns the previous name. The lpoptions shell command does recognize the changed default printer and returns the correct name.


#7

I guess somehow I didn’t actually mention the info(“printer”) function in my post, but I discovered that as well. That was how I discovered that the API for determining the default printer had been deprecated. I don’t know how lpoptions is getting that information, perhaps there is a private, undocumented API.

For Michael’s purposes he should be able to use Gary’s discovery to advantage to print to the default printer:

printtopdf "","printer",tagdata(shellscript({lpoptions},{printer-info='},{'},1),... other pdf options...

#8

I believe it is operating through CUPS.


#9

Thanks guys - that’s useful info.