Вот самый простой из возможных вариантов. Это создает интерактивную область в левом нижнем углу PDF-файла, которая переходит в URL-адрес.
[/Rect [ 0 0 200 200 ] % Draw a rectangle
/Action % Define an action
<<
/Subtype /URI % Define the action's subtype as a hyperlink
/URI (http://www.example.com/) % Set the URL
>>
/Subtype /Link % Set the type of this PDFmark to a link
/ANN pdfmark % Add the annotation
По умолчанию будет нарисована граница, поэтому вы можете ее очистить:
[/Rect [ 0 0 200 200 ] % Draw a rectangle
/Action % Define an action
<<
/Subtype /URI % Define the action's subtype as a hyperlink
/URI (http://www.example.com/) % Set the URL
>>
/Border [0 0 0] % Remove the border
/Subtype /Link % Set the type of this PDFmark to a link
/ANN pdfmark % Add the annotation
Однако это создает только интерактивную область. Затем вам нужно нарисовать текст, чтобы нажать на него:
/Helvetica findfont 16 scalefont setfont % Set the font to Helvetica 16pt
5 100 moveto % Set the drawing location
(http://www.example.com/) show % Show some text
Наконец, pdfmark
технически не определен в стандарте, поэтому они рекомендуют, чтобы, если вы не используете Adobe Distiller, вы определили что-то для его обработки. Этот код просто игнорирует pdfmark
, если компилятор его не распознает:
/pdfmark where
{pop}
{
/globaldict where
{ pop globaldict }
{ userdict }
ifelse
/pdfmark /cleartomark load put
}
ifelse
А вот и полностью работающая программа PostScript:
%!PS-Adobe-1.0
/pdfmark where
{pop}
{
/globaldict where
{ pop globaldict }
{ userdict }
ifelse
/pdfmark /cleartomark load put
}
ifelse
[/Rect [ 0 0 200 200 ] % Draw a rectangle
/Action % Define an action
<<
/Subtype /URI % Define the action's subtype as a hyperlink
/URI (http://www.example.com/) % Set the URL
>>
/Border [0 0 0] % Remove the border
/Subtype /Link % Set the type of this PDFmark to a link
/ANN pdfmark % Add the annotation
/Helvetica findfont 16 scalefont setfont % Set the font to Helvetica 16pt
5 100 moveto % Set the drawing location
(http://www.example.com/) show % Show some text
showpage
ИЗМЕНИТЬ
Кроме того, ознакомьтесь с этим руководством для получения более подробных инструкций по pdfmark
ИЗМЕНИТЬ 2
Кроме того, также я должен отметить, что я разнес вещи в учебных целях. В большинстве случаев вы увидите /Action
в виде одной строки, например:
/Action << /Subtype /URI /URI (http://www.example.com/) >>
person
Chris Haas
schedule
25.08.2011