groff
[Top][All Lists]
Advanced

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

Re: [Groff] Groff to pdf/Windows


From: Keith Marshall
Subject: Re: [Groff] Groff to pdf/Windows
Date: Fri, 07 Mar 2014 20:00:32 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 07/03/14 17:35, Deri James wrote:
> On Thu 06 Mar 2014 17:24:09 Peter Schaffter wrote:
>>> Keith, is there any chance I could add something along these lines
>>> to pdfroff if the -T pdf switch is passed to pdfroff?
>>
>> I'm all for this.  pdfmom performs splendidly.  Nary a hitch with
>> forward references.  Non-mom users could really benefit from the
>> convenience.
> 
> Keith is correct. There is an occasion where three passes are needed. 
> When a hot link description includes a page number (\n[%]) if the 
> expansion to the text before this point causes it to move to the next page 
> the descriptive text, collected on the first pass, will be out of date. So a 
> third pass is necessary.
> 
> And the command becomes:-
> 
> groff -Tpdf -dPDF.EXPORT=1 -z $cmdstring 2>&1 | grep '^\.ds' | \
> groff -Tpdf -dPDF.EXPORT=1 -z - $cmdstring 2>&1 | grep '^\.ds' | \
> groff -Tpdf - $preconv $cmdstring

Here, you're making an assumption: that the layout will have stabilized
after the second pre-production pass.  In most cases, that will be true
but you can't be certain, because you don't validate it.

At the time, when I was developing pdfroff, Werner expressed concern
that there would be cases which may not stabilize in only two passes,
and that extreme cases may exist, which will never stabilize.  Thus,
pdfroff always performs one additional pre-production pass, which may be
considered redundant, except that it explicitly verifies the layout
stability, before progressing to the final production run.

Do note that layout stability cannot be verified within a command
pipeline, such as Deri proposes; the output from each pair of
consecutive pre-production passes must be captured, and compared.  Thus,
the pdfroff implementation of Deri's pipeline becomes:

lim=5; > $tmp1
groff -Tpdf -dPDF.EXPORT=1 -z $cmdstring 2>&1 | grep '^\.ds' > $tmp2
until { test $lim -le 0 || cmp $tmp1 $tmp2 2>&1 > /dev/null; }; do
  mv -f $tmp2 $tmp1
  groff -Tpdf -dPDF.EXPORT=1 -z $tmp1 $cmdstring 2>&1 \
    | grep '^\.ds' > $tmp2
  lim=`expr $lim - 1`
done
groff -Tpdf $tmp2 $preconv $cmdstring > outfile.pdf

(ideally with $tmp1 and $tmp2 sequestered in a securely allocated
temporary directory, and with added diagnostics for the $lim overrun case).

A further observation: isn't it possible that the $preconv settings
might affect the layout?  If so, the pre-production runs also need to
include the $preconv filter.

-- 
Regards,
Keith.



reply via email to

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