pdf - 在 postscript 和 pdfmaker 末尾带有两个超链接的简单行

标签 pdf graphics hyperlink postscript

它对我来说非常令人困惑,因为 pdfmaker 和 postscript 正在做同样的事情,但实际上编码风格却大不相同。

我知道如何使用 Postscript 语言中的 moveto 和 lineto 和 arc 命令在其末端制作一 strip 有 2 个圆圈的线,但是,显然由于超链接,我必须移动到 pdfmark,pdfmark manual super 难懂,没有其他引用资料(书籍/在线教程)。

所以,我将不胜感激,如果有人能用一点描述来生成这样的东西(如图所示)。

enter image description here

最佳答案

这是最简单的版本。这会在 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技术上没有在标准中定义,所以他们建议如果你不使用 Adob​​e 的 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

编辑

另外,check out this manual有关 pdfmark 的更深入说明

编辑 2

另外,我还应该指出,为了教学目的,我已经将东西隔开。在大多数情况下,您会看到 /Action写成一行,例如:
/Action << /Subtype /URI /URI (http://www.example.com/) >>

关于pdf - 在 postscript 和 pdfmaker 末尾带有两个超链接的简单行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7051024/

相关文章:

ios - 我可以通过编程方式向 PDF 添加链接注释吗?

JavaScript 图形

java - 坐标网格中球的真实反弹(离线)

ruby-on-rails-3 - 生产服务器上的 wicked_pdf

android - 如何在 android 中使用 jquery 和 phonegap 打开 pdf 文件?

javascript - 单击超链接后如何防止重定向?

css - 使 block 元素内联后在排列 block 元素时遇到问题

python-3.x - 如何使用电视马拉松在消息中插入用户个人资料或聊天的链接?

php - TCPDF:如何以正确的方式设置字体大小

c++ - 在 C++ 中绘制线条