使用PostScript创建PDF超链接

Ala*_*lan 3 pdf postscript hyperlink ghostscript

基本上我试图通过修改postscript将超链接添加到PDF中.

这是adobe为通过postscript生成链接而提供的代码:

[/Rect [ 0 425 295 445 ] /Action << /Subtype /URI /URI (http://www.adobe.com/) >> /Border [ 0 0 2 ] /Color [ .7 0 0 ] /Subtype /Link ANN pdfmark

这是我试图修改的代码示例:

%PDF-1.4
%âãÏÓ
6 0 obj
>stream
    1 w
    [] 0 d
    0.0 g
    36 775 m
    576 775 l
    s
endstream
endobj
7 0 obj
>stream
  BT
     36 777 Td
    0 Tr
    /F1 16 Tf
    0.0 g
    (Test PDF) Tj
  ET
endstream
endobj
1 0 obj
>/ProcSet[/PDF]>>/Parent 8 0 R/MediaBox[0 0 612 792]/Contents[6 0 R 7 0 R]/Type/Page>>
endobj

9 0 obj
>/ProcSet[/PDF]>>/Parent 8 0 R/MediaBox[0 0 612 792]/Contents[10 0 R 11 0 R]/Type/Page>>
endobj
8 0 obj
>
endobj
12 0 obj
>
endobj
13 0 obj
>
endobj
xref
0 14
0000000000 65535 f 
0000017066 00000 n 
0000000015 00000 n 
0000000116 00000 n 
0000000212 00000 n 
0000000319 00000 n 
0000000422 00000 n 
0000003831 00000 n 
0000025138 00000 n 
0000024976 00000 n 
0000017226 00000 n 
0000021450 00000 n 
0000025207 00000 n 
0000025253 00000 n 
trailer
]>>
startxref
25381
%%EOF

Kur*_*fle 8

这是一个你没有要求的建议,但它可以帮助你实现目标:使用Ghostscript转换你的PDF并添加超链接.

这是如何做.示例假定您使用Windows.在Linux或Mac OS X上,使用gs(代替gswin32c.exe\用作行继续而不是^:

gswin32c.exe ^
  -o with-hyperlink.pdf ^
  -sDEVICE=pdfwrite ^
  -c "[ /Rect [0 425 295 465]" ^
  -c "  /Border [0 0 2]" ^
  -c "  /Color [.7 0 0]" ^
  -c "  /Page 1" ^
  -c "  /Action <</Subtype /URI" ^
  -c "  /URI (http://stackoverflow.com/questions/4663409/creating-a-pdf-hyperlink-with-postscript/4674664#4674664)>>" ^
  -c "  /Subtype /Link" ^
  -c "  /ANN pdfmark" ^
  -f without-hyperlink.pdf
Run Code Online (Sandbox Code Playgroud)

此命令将原始PDF(without-hyperlink.pdf)重新提炼为with-hyperlink.pdf.生成的PDF将在第1页上显示超链接.

在文本编辑器中操作PDF的内容是可能的,但是太麻烦了.但是你需要成为一名真正的PDF专家才能为大多数PDF做到这一点.