LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   postscript hyperlinks (http://www.linuxquestions.org/questions/programming-9/postscript-hyperlinks-574701/)

Tischbein 08-04-2007 09:35 AM

postscript hyperlinks
 
Dear All,

Has anyone here ever made hyperlinks in postscript? Can you recommend a text or tutorial on it?

I draw quite a few diagrams (mathematical constructs mostly) in postscript and I like it so, whilst not ruling other languages out completely I'm quite keen to stick with postscript as a language. I'ts compact (so I spend little time typing) and readable providing that it's well commented.

I'd like to link areas in some diagrams to other pages, and sometimes to other points in the same diagram. I imagine that there is a command rather like stroke or fill that takes such an area and links it to an url.

This is what I've looked at so far:

- I've read on various web discussions that postscript doesn't support hyperlinks natively, but that there are dictionaries that can be imported that do the trick.

- The program html2ps generates postscript with hyperlinks. The way I've tested it is by calling:
html2ps simple.html > simple.ps
Then, because I don't have a postscript viewer on this box (and am too lazy to spend five minutes installing one)
ps2pdf simple.ps
Then look at the simple.pdf with a pdf viewer, and hey presto the links work!

- I've looked inside some output files of html2ps Even for a very simple 3 line html file this is 600 lines long. I've started reverse engineering it, however it'll take me some time and will be quite painful.

- I've heard of pdfmark in the context of postscript hyperlinks. The word appears in the html2ps output which kinda confirms this rumour. I've looked up pdfmark on the web but haven't found any nice short postscript examples of how to use it.

Any help would be greatly appreciated.

Regards, Tischbein

Tischbein 08-04-2007 06:17 PM

Solved. I just needed to read the Adobe pdfmark documentation and type a little more accurately.

http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/pdf_creation_apis_and_specs/pdfmarkReference.pdf


Here's a toy:

%!PS-Aobe-3.0

%%
% If pdfmark is defined, use it (for hyperlinks & other pdf-not-postscript features)
% otherwise give pdfmark a null definition so that we don't get any errors.

/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse

%
%%

%%
% Document metadata

[ /Author (A clutch of disembodied fingers)
/Title (Aspects)
/DOCINFO pdfmark

%
%%


%%
% A real drawing - an HSBC mark

newpath

100 100 moveto
100 100 rlineto
-100 0 rlineto
100 -100 rlineto
closepath fill

%
%%

%%
% A real hyperlink

[ /Rect [100 100 200 200]
/Border [16 16 1]
/Color [0 0 1]
/Action << /Subtype /URI /URI (http://www.google.com) >>
/Subtype /Link
/ANN pdfmark

showpage

%
%%

%%
% A link to another point in this document

% First an icon
newpath
300 600 50 0 360 arc
fill

% then a link
[ /Rect [250 550 350 650]
/Border [16 16 1]
/Page 1
/View [/XYZ 50 250 null]
/Subtype /Link
/ANN pdfmark

showpage
%
%%

naarkhoo 07-10-2011 09:50 AM

I am trying to rotate the object and its hyperlink boundary in consequent. I use a command like rotate 10 but it only works on the object, not its boundary. I am wondering how can I rotate the object and its boundary together.


All times are GMT -5. The time now is 11:27 PM.