【问题标题】:simple line with two hyperlinks at end in postscript and pdfmaker在 postscript 和 pdfmaker 末尾带有两个超链接的简单行
【发布时间】:2011-10-26 10:23:50
【问题描述】:

这让我很困惑,因为 pdfmaker 和 postscript 的做法是一样的,但实际上编码风格却大不相同。

我知道如何用 Postscript 语言中的 moveto 和 lineto 和 arc 命令制作一条末端有 2 个圆圈的线,但是,显然由于超链接,我必须移至 pdfmark,pdfmark manual 超级难以理解,并且没有其他参考资料(书籍/在线教程)。

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

【问题讨论】:

    标签: pdf graphics hyperlink postscript


    【解决方案1】:

    这是最简单的版本。这会在 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/) >>
    

    【讨论】:

    • 我使用 ps2pdf 从 ps 中制作了 pdf,但输出不是我们期望看到的 :( 没有形状,没有线条……只是左下角的 www.example.com ! !
    • @user702846,我发布的是如何向 PDF 添加超链接,因为您说您已经知道如何完成其​​余的工作。超链接基本上位于您已经创建的内容之上,而不是在其中。因此,像以前一样创建形状和文本,然后使用此代码在其上添加超链接。
    猜你喜欢
    • 1970-01-01
    • 2018-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-10
    • 2023-04-07
    相关资源
    最近更新 更多