PostScript - table of hyperlinks but only one link being used for all

孤者浪人 提交于 2021-02-19 05:47:03

问题


The requirement is to show some text in a pdf which has a hyperlink underneath to a site/pdf/etc - similar to HTML where you will see please click here and here opens up a link.

I'm using PlanetPress to create the pdf, which basiclly is PostScript code with added vitamins and iron.

Acrobat automatically creates links when http:// is found within the text, as a consequence PlanetPress does not handle links directly (because they are created automatically by Acrobat).

I can create static links that meet our requirements by passing PDFMark PostScript code directly through PlanetPress however when I try to do the same dynamically for a number of lines of code, the final link within the list becomes the link for each line.

In PlanetPress I'm basiclly looping through an XML file and sending the results to the .ps file.

Here is my PDFmarks code:

        passthrough('[ /Rect [ 0 0 16 '+inttostr(floattoint(&j))+' ]')
        passthrough('/Action << /Subtype /URI /URI ('+&CentreCodeLink+') >>')
        passthrough('/Count '+IntToStr(&i)+'')
        passthrough('/Subtype /Link')
        passthrough('/Border [ 1 1 1 ]')
        passthrough('/ANN pdfmark')

I've used the /count filed to determine that different values are being read/passed to the PostScript File. I've used the /rect & /border fields to create a hyperlink area. I thought that the rectangle would be the boundries of the hyperlink area however this isn't the case it seems. I've tried using moveto to ensure the cursor is moving along the page but this has no effect on the end result at all. passthrough(' '+inttostr(floattoint(&width*72))+' '+inttostr(floattoint(&j))+' moveto')

I don't really know PostScript but I think this is a chunk of the output of two links (I've cut the links down because they were real links)

0 0 *m
213.9994 30.00256 *m
0 35.00296 *m
*gr
*gs
[1 0 0 1 0 70.75305]concat
 /^PP$ {systemdict /show get exec} *bd
&body /$ 1 index 2 get store /_ 1 index 6 get store 1 get *sf
 /^PP$ {systemdict /show get exec} *bd
&bold /$ 1 index 2 get store /_ 1 index 6 get store 1 get *sf
36 12.00037 *m
36 12.00037 *m (London - Hammersmith) $
165.6 12.00037 *m
&weblinkstyle dup 0 get [9 0 0 -9 0 0] *mf *sf
 /^PP$ {systemdict /show get exec} *bd
[] 0 setdash
/$ 1 index 5 get dup 0 {1 1 0 0 *sc}*bi put store /_ exch 8 get dup 0 {1 1 0 0 *sc}*bi put store
165.6002 12.00037 *m (London - Angel) $
([ /Rect [ 0 0 540 16 ]) cvx exec
(/Action << /Subtype /URI /URI \(http://WelcomePacka5LondonAngel/\) >>) cvx exec
(/Count 1) cvx exec
(/Subtype /Link) cvx exec
(/Border [ 1 1 1 ]) cvx exec
(/ANN pdfmark) cvx exec
( 540 16 moveto) cvx exec
 /^PP$ {systemdict /show get exec} *bd
&bold /$ 1 index 2 get store /_ 1 index 6 get store 1 get *sf
36 24.00073 *m
36 24.00073 *m (London - London Bridge) $
165.6 24.00073 *m
&weblinkstyle dup 0 get [9 0 0 -9 0 0] *mf *sf
 /^PP$ {systemdict /show get exec} *bd
[] 0 setdash
/$ 1 index 5 get dup 0 {1 1 0 0 *sc}*bi put store /_ exch 8 get dup 0 {1 1 0 0 *sc}*bi put store
165.6002 24.00073 *m (London - Bridge / Borough High Street) $
([ /Rect [ 0 0 540 28 ]) cvx exec
(/Action << /Subtype /URI /URI \(http://WelcomePacka5LondonBridge/\) >>) cvx exec
(/Count 2) cvx exec
(/Subtype /Link) cvx exec
(/Border [ 1 1 1 ]) cvx exec
(/ANN pdfmark) cvx exec
( 540 28 moveto) cvx exec
 /^PP$ {systemdict /show get exec} *bd

Any ideas why these don't work? I was thinking maybe I need to have a break between each pdfmark box as they seem to share a border now but I don't know how to do this. Thanks


回答1:


The /Rect does define the rectangle for the link. But it looks like the code has the lower left value of the rectangle at 0, 0 for all the rectangles. So the rectangles are overlapping, thus the top one (the last one created) would be the one that gets activated when clicked. Remember, /Rect is [ "lower left x" "lower left y" "upper right x" "upper right y" ], so the first two values define the lower left point of the rectangle and the last two values define the upper right point of the rectangle.

"Now I just need to figure out how to redraw the rectangle repeatidly using all 4 points"

I am not sure I undertsand this additional question. Are you asking, "Now that I have the correct values for the /Rect for the hyperlink, how do I draw a rectangle there?"

To find all four points of the rectangle you simply use the information from the /Rect values. So for example, say /Rect [ 70 680 110 690 ], then the four points for the rectangle are (70,680), (70,690), (110,680), and (110,690). You can use appropriate drawing commands to draw that rectangle.



来源:https://stackoverflow.com/questions/13144121/postscript-table-of-hyperlinks-but-only-one-link-being-used-for-all

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!