Re: [Help] Printing problem in Mac OSX Leopard



Niner wrote:
<<snip>>


The [7] you see in the debug output is the handle of the figure being printed... it's either the figure you created or a temporary copy created by print preview.

I think the issue is that the operating system lpr command (used by MATLAB to send the file to your printer) doesn't recognize the IP address as a printer. I would expect that if you print to a ps file (test.ps) and then from a system prompt (or using MATLAB's "bang" command) if you executed the following you would see the same/similar error.
From MATLAB: !lpr -P128.95.xxx.xxx test.ps
From a shell prompt: lpr -P128.95.xxx.xxx test.ps
(filling in the complete ip address, of course)

I think what you need to do is add the printer to your Mac, specifying that it is an IP printer and entering both the IP address as well as giving it a queue name, such as "networkprinter". Once that's done, restart MATLAB and choose the queue name you specified as the printer to print to (either from the list of printers shown in the dialog box or with the print command's -P option

--

Richard Quist
Software Developer
The MathWorks, Inc.


Hi Richard,

Thank you very much for your response. The printer I am using has already added to Mac' printer list. I use the System Preference --> Print & Fax to setup the printer. Here is the info about setting the printer.

---------------------------------------------------
IP Printer
Protocol : Line Printer Daemon - LPD (this is Mac's default. The other two options are "Internet Printing Protocol, IPP" and "HP Jetdirect - Socket")
Address : 128.95.xxx.xxx
Queue : (there's a note: "Leave blank for default queue." So I leave it blank)
Name : HP LaserJet 1320 (I name this printer.)
Location: (I leave it blank)
Print Using: HP LaserJet 1320 series (the driver for the HP printer)
---------------------------------------------------

After setting the printer, I view the general info of the printer.

-----------------------------------
Name: HP LaserJet 1320
Location: (blank)
Queue Name: HP_LaserJet_1320
Host Name: localhost
Driver Version: 4.0.0.080
URL: lpd://128.95.xxx.xxx/
----------------------------------

This works fine with the applications installed in my MBP, except Matlab. I can see the printer "HP LaserJet 1320" in the list when I open Print Widow in Matlab. But it got errors when I click "Print" button. As you mentioned, I can't print the *.ps file by the command "lpr -P" under either Matlab command window or Mac's bash shell. Why? What is the reason that the shell command can't recognize the printer? However, if just use command "lpr", the printing works fine, except that I have to stop by the printer and press the "Print" button.

I had tried to restart Matlab and MBP several times, and it was no good.

I think that command "lpr" would print the file by the default printer, and this sends the signal to Mac's default printer. In Matlab, it looks like the "print" command tries to use "lpr -P" command, which doesn't work. This is weird to me. Before I upgraded my Mac OSX to Leopard, the printing had no problem in Matlab under Tiger. After upgrading, I re-set the printer and the problem occurred. There's mystery somewhere.

Is there any way that I can reset the printer in Matlab, like delete the printer settings? Maybe after resetting, let Matlab look for the printer again. This may solve the problem. What do you think?

Any comment is appreciated. Thank you.




Niner




There aren't any printer-specific settings in MATLAB - we query the OS for the information on what printers are available.

In the print preview case, we don't check whether you're selecting the default printer (in which case the lpr command without the -P option could be used); we always provide the -P option to explicitly tell the OS to use the specific printer.

It looks like something has changed in your print settings during the Leopard upgrade. Instead of returning the printer NAME ('HP LaserJet 1320') the OS is giving us the IP address. Can you post the printcap entry for this printer? It should be in the /etc/printcap file.

As a possible workaround, one of my co-workers pointed out that adding the -H option to the lpr command, telling lpr what server to find the printer on, may work. Since the OS is giving you the IP address that's the value you'd set for the -H parameter. To make this change in MATLAB you'd need to edit the file send.m in the <matlabroot>/toolbox/matlab/graphics/private directory.
In that file you'll find a section (starting around line 94) that looks like this:
if ~isempty( pj.PrinterName )
%If user specified a printer, add it to the printing command
if notBSD
cmdOption = '-d';
else
cmdOption = '-P';
end
lprcmd = [ lprcmd ' "' cmdOption pj.PrinterName '"' ];
end
Underneath the line that reads
cmdOption = '-P';
add the following (above the end statement)
lprcmd = [ lprcmd ' "-H' pj.PrinterName '"' ];

Note - this isn't a great solution - and it will fail for any printer for which the OS gives you the real name instead of the IP address...but it may be sufficient while you're working through the problem.


I also took a quick look at Apple's support site - looking specifically for IP printer issues with Leopard and found at least one user who suggests NOT leaving the queue name blank when setting up the printer. For example, see:
http://discussions.apple.com/thread.jspa?messageID=5683220&#5683220
Even though you're only having issues with MATLAB printing, it may be worth a try to set the queue name explicitly on the printer setup dialog.

--

Richard Quist
Software Developer
The MathWorks, Inc.
.



Relevant Pages

  • Re: [Help] Printing problem in Mac OSX Leopard
    ... I think the issue is that the operating system lpr command (used by ... MATLAB to send the file to your printer) doesn't recognize the IP ... HP LaserJet 1320 series ...
    (comp.soft-sys.matlab)
  • Re: [Help] Printing problem in Mac OSX Leopard
    ... I can print the figure using command "print" in the command ... Matlab 2007a Student version. ... lpr: The printer or class was not found. ... If you're adventurous you can set a breakpoint in MATLAB's print command ...
    (comp.soft-sys.matlab)
  • Re: Matlab -- Venting, Plus Miscellaneous Questions
    ... There are no command lines. ... Matlab is obviously intensively command-driven -- which means, ... print or online documentation. ... calculations, but symbolic calculations keep showing some ridiculous ...
    (sci.math.symbolic)
  • Re: Matlab -- Venting, Plus Miscellaneous Questions
    ... that I am -- I don't want to type in a special command syntax each ... Matlab is obviously intensively command-driven -- which means, ... print or online documentation. ... calculations, but symbolic calculations keep showing some ridiculous ...
    (sci.math.symbolic)
  • Re: [Help] Printing problem in Mac OSX Leopard
    ... I think the issue is that the operating system lpr command (used by MATLAB to send the file to your printer) doesn't recognize the IP address as a printer. ... I think what you need to do is add the printer to your Mac, specifying that it is an IP printer and entering both the IP address as well as giving it a queue name, such as "networkprinter". ...
    (comp.soft-sys.matlab)