Graphics Programs Reference
In-Depth Information
The embedded file itself is simply included in a stream object, with /Type /Embedded
File as an additional entry in the stream dictionary. The code for a sample embedded
file is shown in Example 7-5 .
Example 7-5. An embedded file
8 0 obj
<< /Type /EmbeddedFile /Length 35 >>
stream
This is a text file attachment...
endstream
endobj
The embedded file stream is referenced in two quite different ways: one for attachments
to the whole document, another for attachments to particular pages.
To attach to the whole document, an /EmbeddedFiles entry is included in the name
dictionary referenced by the /Names entry in the document catalog. The code is shown
in Example 7-6 .
Example 7-6. PDF Code for an attachment at the document level. The embedded file is object 8 (see
Example 7-5 ).
9 0 obj
<< /Names
<< /EmbeddedFiles
<< /Names
[ (attachment.txt) << /EF << /F 8 0 R >> /F (attachment.txt) /Type /F >> ] >>
>>
/Pages 1 0 R
/Type /Catalog >>
endobj
To attach to a single page, a special kind of annotation is used, listed as usual in
the /Annots dictionary in the page dictionary. The code is shown in Example 7-7 .
Example 7-7. PDF code for an attachment to a particular page. The embedded file is object 8 (see
Example 7-5 ).
9 0 obj
<<
/Type /Page
(Other dictionary entries as usual)
/Annots
[ << /FS << /EF << /F 8 0 R >> /F (attachment.txt) /Type /F >>
/Subtype /FileAttachment
/Contents (attachment.txt)
/Rect [ 18 796.88976378 45 823.88976378 ]
>> ]
Search WWH ::




Custom Search