octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fltk printing


From: Michael D Godfrey
Subject: Re: fltk printing
Date: Sat, 07 Aug 2010 13:04:44 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Thunderbird/3.1.1

On 08/07/2010 10:45 AM, Ben Abbott wrote:
On Aug 6, 2010, at 10:02 PM, Michael D Godfrey wrote:

> On 08/06/2010 06:53 PM, Ben Abbott wrote:
>> 
> 
>> On Aug 6, 2010, at 6:30 PM, Michael D Godfrey wrote:
>> 
>>> On 06 Aug, 2010,at 04:29 PM, bpabbott <address@hidden> wrote:
>>> 
>>>> On 06 Aug, 2010,at 12:43 PM, Michael D Godfrey <address@hidden> wrote:
>>>> 
>>>>> The last changeset mainly works well, but I got the following:
>>>>> 
>>>>> octave:3> print test.pdf
>>>>> GPL Ghostscript 8.71: Unrecoverable error, exit code 1
>>>>> warning: print.m: ghostscript failed to convert output to file 'test.pdf'.
>>>>> No such file or directory
>>>>> warning: print.m: failed to delete temporay file, '/tmp/oct-v6IZoF.eps'.
>>>>> octave:4> refresh
>>>>> octave:5> print('test.pdf', '-color');
>>>>> octave:6> quit
>>>>> ========================
>>>>> The print('test.pdf','-color');  produced correct output, but the output
>>>>> from print test.pdf was a blank page.  Previously,
>>>>> print test.pdf  (or test.ps, since before the latest updates pdf was
>>>>> not implemented)  worked as expected.  Now, print test.ps also
>>>>> fails just like print test.pdf
>>>>> 
>>>>> Also, as an even more minor point, in the line:
>>>>> warning: print.m: failed to delete temporay file, '/tmp/oct-v6IZoF.eps'
>>>>> 
>>>>> temporay should be temporary.
>>>>> 
>>>>> Michael 
>>>>  
>>>> I'm not able to reproduce your result. Please try the example below. I've attached the resulting pdf.
>>>> 
>>>> octave:84> close all
>>>> octave:85> plot (1:10)
>>>> octave:86> print test.pdf -debug
>>>> ---- begin /var/tmp/oct-UhqG3X.ps ----
>>>> %!PS-Adobe-3.0
>>>> << /Margins [0 0] /.HWMargins [0 0 0 0] /PageOffset [18 180] >> setpagedevice
>>>> %EOF
>>>> ----- end /var/tmp/oct-UhqG3X.ps -----
>>>> Ghostscript command: /sw/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dEmbedAllFonts=true -dOptimize=true -sPAPERSIZE=letter -dFIXEDMEDIA -sOutputFile=test.pdf /var/tmp/oct-UhqG3X.ps /var/tmp/oct-XcT2VQeps
>>>> 
>>>> My ghostscript version is ...
>>>> 
>>>> $ gs -v
>>>> GPL Ghostscript 8.61 (2007-11-21)
>>>> Copyright (C) 2007 Artifex Software, Inc.  All rights reserved.
>>>> 
>>>> Ben
>>>> 
>>> Ben,
>>> 
>>> You asked for:
>>> 
>>> [qss:octave] gs -v
>>> GPL Ghostscript 8.71 (2010-02-10)
>>> Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
>>> 
>>> octave:1> plot(1:10)
>>> octave:2> print test.pdf -debug
>>> GPL Ghostscript 8.71: Unrecoverable error, exit code 1
>>> ---- begin /tmp/oct-q2Hi98.ps ----
>>> %!PS-Adobe-3.0
>>> << /Margins [0 0] /.HWMargins [0 0 0 0] /PageOffset [18 180] >> setpagedevice
>>> %EOF
>>> ----- end /tmp/oct-q2Hi98.ps -----
>>> Ghostscript command: /usr/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dEmbedAllFonts=true -dOptimize=true -sPAPERSIZE=letter -dFIXEDMEDIA -sOutputFile=test.pdf /tmp/oct-q2Hi98.ps /tmp/oct-qAirIj.eps
>>> warning: print.m: ghostscript failed to convert output to file 'test.pdf'.
>>> No such file or directory
>>> warning: print.m: failed to delete temporay file, '/tmp/oct-qAirIj.eps'.
>>> octave:3> 
>>> But, in /tmp are:
>>> -rw-rw-r-- 1 godfrey godfrey   97 Aug  6 15:03 /tmp/oct-q2Hi98.ps
>>> -rw-rw-r-- 1 godfrey godfrey 6308 Aug  6 15:03 /tmp/oct-qAirIj.eps
>>> 
>>> And, if I run the gs command after exiting Octave, it runs and produces the intended test.pdf.
>>> And, the file Aug  6 15:03 /tmp/oct-qAirIj.eps is still in /tmp.
>>> 
>>> And, in Octave, I tried:
>>> octave:2> system('gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dEmbedAllFonts=true -dOptimize=true -sPAPERSIZE=letter -dFIXEDMEDIA -sOutputFile=test.pdf /tmp/oct-q2Hi98.ps /tmp/oct-qAirIj.eps')
>>> ans = 0
>>> And, the expected test.pdf was created.
>>> 
>>> So, I do not know what has gone wrong.  Remember also that print('test.pdf') works fine.
>>> 
>>> Anything more I can provide?
>>> 
>>> Michael
>> 
>> It looks like the eps file isn't recognized as existing when ghostscript is called ... and still isn't recognized when unlinked.
>> 
>> Please check that the file is present by adding "dir (opts.ghostscript.source)" to __fltk_print__.m in the position indicated below.
>> 
>>  case {"ps", "ps2", "psc", "psc2", "pdf"}
>>    opts.ghostscript.source = strcat (tmpnam (), ".eps");
>>    file2unlink = opts.ghostscript.source;
>>    if (strcmp (opts.devopt, "pdf"))
>>      opts.ghostscript.device = "pdfwrite";
>>    else
>>      opts.ghostscript.device = "pswrite";
>>    endif
>>    opts.ghostscript.output = opts.name;
>>    drawnow ("eps", opts.ghostscript.source);
>>    dir (opts.ghostscript.source)
>>    if (opts.tight_flag)
>>      __tight_eps_bbox__ (opts, opts.ghostscript.source);
>>    endif
>> 
>> Now if you try "print test.pdf", does the dir() command indicate the eps file exists?
>> 
>> Ben
> 
> This is likely an important point.  I think that (system(...) returns when the call (gs)
> thinks it is done.  That is not the same as the files have actually been written.  My systems
> NFS mount from a server, so files actually showing up can be delayed.
> 
> I will try your suggestion when I can.  In any case, it will likely be a good idea to wait
> until the files generated by gs actually show up before trying to use them.
> 
> Think a bit about why, under the same conditions, print('test.pdf'),  always works.
> 
> Michael
Michael, I'm surprised the temp files are on a server? Does tmpnam() actually return a file to be opened on a server?

In either event, it does appear to be a synchronization / timing problem.

Reading through the Matlab docs, if new files are created programmatically they will not be seen by Matlab until the next command prompt. To overcome this "rehash()" should be run. I'm not familiar with what Octave does in this case, but it looks quite similar.

Explicitly updating the path looks like a better solution than using a while-loop and waiting until Octave sees the file.

Shai, Is "rehash" implicit when "drawnow ("eps", opts.name)" is called? .,, should it be?

Michael, if you'd like to test this solution, place a "rehash()" after each "drawnow(...)" in __fltk_print__.m.

Ben

p.s.  Some of this dropped off the list, so I've reconstructed the thread and cc'd the list.



Ben,

I think we have misunderstood what is going on.  I tried your suggestion
above. Then I tried putting drawnow(); then rehash();  and then pause(10); ahead of the test
for the eps file.  The eps file was still not present.  But, after the command completes
it is there.  There is some side-effect of using print test.pdf  instead of
print('test.pdf') that is causing this problem.  Any ideas?

Michael


reply via email to

[Prev in Thread] Current Thread [Next in Thread]