3

In the documentation of PDFTK is not mentioned how to do it. The command:

pdftk file.pdf attach_files attachDoc.pdf to_page 2 output -

will attach a file to page 2 of the original file.pdf and output the result to <stdout>.

attachDoc.pdf is the file name of the filesystem. But I can not specify any description for this to show the attachment in the final file with an appropriate notation-description.

This would be especially useful, as in the automatic generation operations, the attachments often have temporary names assigned by the server and a description would be necessary

Is there any way to do this?

4

1 に答える 1

3

簡潔な答え:

を使用している場合、(現在) 添付ファイルの説明を追加することはできませんpdftk
(ただし、この機能を追加するのはそれほど複雑ではないはずです。必要なのは、添付ファイル辞書への追加のキー エントリだけだからです...開発者/Descに機能リクエストを送信する必要がありますか?)pdftk

より長い答え:

(ごく最近のバージョンの) Ghostscript を使用して、目的を達成できる場合があります。ただし、かなり複雑なので注意してください。

pdfmarkoperatorを定義する特別な PostScript 拡張を使用する必要があります。この演算子は、PostScript 自体では使用できない高度な機能を PDF ファイルに挿入するために作成されました。

一連のpdfmark操作を使用してテキスト ファイルを PDF に挿入する別のファイルを使用して、それを示します。これは、テキスト ファイルの内容ですmypdfmark-for-attachments.ps

 [                                           /NamespacePush  pdfmark
 [ /_objdef {fstream} /type /stream          /OBJ            pdfmark
 [ {fstream} << /Type /EmbeddedFile >>       /PUT            pdfmark

 [ {fstream} (I only simulate text file content here...)
                                             /PUT            pdfmark
 [ /Name <feff 0044 005a 005a 005a 005a 005a>
   /FS<<
      /Desc  (dEsCrIpTiOn)
      /Type  /Filespec
      /F     (my.txt)
      /EF    <<
             /F {fstream}
             >>
      >>                                     /EMBED          pdfmark
 [ {fstream}                                 /CLOSE          pdfmark
 [                                           /NamespacePop   pdfmark

ご覧のとおり、/Descキーには説明テキストが保持されていますdEsCrIpTiOn

次の Ghostscript コマンドを実行します。

gs -o emb.pdf -sDEVICE=pdfwrite mypdfmark-for-attachments.ps -f some.pdf 

これは、Acrobat で表示された結果の PDF ファイルのスクリーンショットです。

アクロバットのスクリーンショット

于 2015-05-23T21:45:07.220 に答える