Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: [Help] Printing problem in Mac OSX Leopard
Date: Mon, 5 Nov 2007 18:10:47 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 219
Message-ID: <fgnmb7$ab5$1@fred.mathworks.com>
References: <fg5k90$6uk$1@fred.mathworks.com> <fg77g3$6jo$1@fred.mathworks.com> <fg7v7f$8cd$1@fred.mathworks.com> <fg81a0$ijr$1@fred.mathworks.com> <fgdj93$bsh$1@fred.mathworks.com> <fgf4a1$s68$1@fred.mathworks.com> <fgg2l2$mju$1@fred.mathworks.com> <fgneub$o5v$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1194286247 10597 172.30.248.38 (5 Nov 2007 18:10:47 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 5 Nov 2007 18:10:47 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1130080
Xref: news.mathworks.com comp.soft-sys.matlab:436153



Richard Quist <rquist_nospam@mathworks.com> wrote in message 
<fgneub$o5v$1@fred.mathworks.com>...
> 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.


Hi Richard,

   Thank you very much for you response. About the queue name problem, I 
did an experiment. I set up three printers each with different printing protocol 
. I gave each printer a queue name. So, we had

Name                   Queue Name
------              ------------
HP_IPP                    HP1320_IPP
HP_LPD                   HP1320_LPD
HP_Socket        (no queue name is required) 

Then I restarted my MBP, and opened Matlab. I created a simple plot, and 
used both Print Preview and Print button to print out the figure. Here is the 
results.

                     under Print Preview             use Print button
                    ---------------          ---------------
HP_IPP          sent w/out error                  sent w/out error
HP_LPD        sent w/out error                 sent w/out error
HP_Socket   sent w/out error                  sent w/out error

All of the printer settings worked fine when I tried to print the figure, no 
error message this time. But, the protocol HP_IPP can't finish the printing, 
which had a warning message in the printing job list (can be seen when open 
the Print Queue window in Mac). The other two settings worked very well.

So it tuned out that using a queue name was the solution to this problem, 
and IPP protocol was not functional in my case. At the end, I delete the IPP 
printer setting and use LPD printer setting.

I didn't modify the send.m file, and here is the content of printcap before I 
did my experiment. (I hide the IP address)

'-----------------------------------------------
# This file was automatically generated by cupsd(8) from the
# /private/etc/cups/printers.conf file.  All changes to this file
# will be lost.
_128_95_xxx_xxx-1|128.95.xxx.xxx 
HP:rm=127.0.0.1:rp=_128_95_xxx_xxx-1:
'--------------------------------------------------

Just one question left. I still need to stop by the printer and press the Print 
button to let the figure print out. I still have no idea about this one. I didn't 
have same situation when I used Mac OSX Tiger. Is it possible to be fixed if I 
re-install the Matlab? or is this the problem about X11?

Any comment is appreciated. Thank you very much for your help.


I use Mac OSX Leopard, Matlab 2007a Student version.

Niner