[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] pdfmark, URI and coordinates of output text
From: |
Carlos J. G. Duarte |
Subject: |
Re: [Groff] pdfmark, URI and coordinates of output text |
Date: |
Thu, 20 Nov 2003 14:57:52 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031014 Thunderbird/0.3 |
Werner LEMBERG wrote:
For the moment I suggest to use Gaius's solution, in combination with
a yet-to-be-written script `makepdfmark' which processes the lines
written by \O2 to stderr:
groff -Z foo > /dev/null 2> foo.log
makepdfmark < foo.log > foo.aux
groff foo.aux foo > foo.ps
Hi Werner, thanks for your thoughts on my problem, but I've found a
solution meanwhile. Basically I force the output of the string with a
break, then use the .n register to find the length of the previous line.
Now the \O will place the correct values into opminx and others
registers. To get back to the previous position I go up a line and go
right the amount of .n.
Like this:
\O1stuff\c
.br \" force the break, so \O1 is going to be interpreted first than the
following \n[]...
.\" use those for what I want ==\n[opminx] \n[opmaxx] \n[opminy]
\n[opmaxy]==
.\" get one line up, then forward to end of stuff
.sp -\n[.v]u
\h'|\n[.n]u'\c
blablabla \" continuation of text...
It will fail if the break causes a new page, but hey, who wants to make
references on the last line uh?!
For completition here goes my complete macro:
.de PSHREF \" HREF continuation_char NAME border_width
. \" border_width = 0, no border; 1, 2, 3...
. \" exemplo: .PSHREF http://www.compuquali.com .
"CompuQuali" 1
.nr wid 0
.if !'\\$4'' .nr wid \\$4
.ie !'\\$3'' \\O1\\$3\c
.el \\O1\\$1\c
.br
.nr px0 \\n[opminx]/1p
.nr px1 \\n[opmaxx]/1p
.nr py0 \\n[opminy]/1p
.nr py1 \\n[opmaxy]/1p
.sp -\\n[.v]u
\h'|\\n[.n]u'\c
\X'ps: exec [ /Rect [\\n[px0] \\n[py0] \\n[px1] \\n[py1]] /Border [0 0
\\n[wid]] /Action << /Subtype /URI /URI
(\\$1) >> /Subtype /Link /ANN pdfmark'\c
.ie !'\\$2'' \&\\$2
.el \&
..
UPDATE: you say there is a ps "u" def that converts units to points, so
this can be made much more simple by using directly the op*** registers.
The following is untested, do not try this at home:
.de PSHREF \" HREF continuation_char NAME border_width
. \" border_width = 0, no border; 1, 2, 3...
. \" exemplo: .PSHREF http://www.compuquali.com .
"CompuQuali" 1
.nr wid 0
.if !'\\$4'' .nr wid \\$4
.ie !'\\$3'' \\O1\\$3\c
.el \\O1\\$1\c
.br
\X'ps: exec [ /Rect [\\n[opminx] u \\n[opminy] u \\n[opmaxx] u
\\n[opmaxy] u] /Border [0 0 \\n[wid]] /Action << /Subtype /URI /URI
(\\$1) >> /Subtype /Link /ANN pdfmark'\c
.sp -\\n[.v]u
\h'|\\n[.n]u'\c
.ie !'\\$2'' \&\\$2
.el \&
..
best regards,
--
carlos