putting hyperlink in pdf/postscript around a circle
As you see, there are several IDs around the circle, I don't know exactly about their coordination (is difficult!). So, was wondering if anyone has an idea, to attach hyperlink for each ID, meaning that by clicking on ID, user diverted on the corresponding we开发者_开发问答bpage.
I put the code HERE
This circle, is generated by a postscript script!!
The text is drawn using constructions like this:
247 ux 160.65 uy moveto (GH6) show stroke
You need to add a pdfmark operation, the exact pdfmark you want to use depends on what you are trying to open, and where. If you want to open another PDF file you can use a Link Annotation with a GoToR action, if you want to open a web page you can use a Launch action or possibly a custom action, depending on what application is viewing the PDF file. I'm going to assume you want a Launch action.
The Launch pdfmark should look something like :
[/Rect [50 425 295 445] /Action /Launch /Border [0 0 2] /Color [.7 0 0] /URI (http://www.adobe.com) /Subtype /Link /ANN pdfmark
Obviously you need to calculate the Rect parameters so that clicking in the area of the text will launch the destination.
The way to do this is to use the PostScript path operators. First we need to save the current setup, then convert the text to a path, then calculate the bounding box of the path. Then we can use those co-ordinates for our Rect parameters.
Eg:
247 ux 160.65 uy moveto (GH6) dup % copy the string gsave % save the current environament exch % bring the string copy to the top of the stack [ /Rect % Put a mark and name on stack 3 -1 roll % Bring string copy to top true charpath % create a path equivalent to drawing the text flattenpath % flatten curves pathbbox % get the bounding box % we now have our box on the stack % stack is: (GH6) [ /Rect llx lly urx ury % So put the other parameters in place /Action /Launch /Border [0 0 2] /Color [.7 0 0] /URI (www.dummy.com) /Subtype /Link /Ann pdfmark % and execute the pdfmark grestore % put the graphics state back show stroke
Some of the text is shown via a slightly different idiom:
241 ux 84.65 uy moveto (45.0) dup stringwidth pop 2 div neg 0 rmoveto show
you can do exactly the same as above, just put the dup...grestore construction after the rmoveto and before the show.
Caveat: I haven't tested this at all, but it should show you how to proceed.
Whatever portion of the PostScript program draws the numerical IDs also needs to include a pdfmark which has a /Dest of the URI for the web page. It may well also need to specify an /AP appearance stream.
This is probably trivial to do in the original PostScript program but as BryanH implies, impossible to give pointers on without seeing the original PostScript.
Assuming, of course, that the numbers are drawn by the PostScript program, and the tool converting the PostScript to PDF understands the pdfmark extension operator.
The example from KenS is exactly what I've been looking for, but with one small change:
[ pathbbox ]
ie
/Arial findfont 20 scalefont setfont
100 200 moveto (riverdrums)
dup gsave exch
[ /Rect 3 -1 roll true charpath flattenpath [ pathbbox ]
/Action << /Subtype /URI /URI (http://riverdrums.com) >>
/Border [0 0 0]
/Subtype /Link
/ANN pdfmark
grestore
show
精彩评论