Index
- Installation
- Getting Started
- Memory Usage
- Readers and Writers
- The Document Class
- Metadata
- Pages
- Canvas
- Page Layout and Mode
- Viewer Preferences
- Document Outline
- Page Labels
- Actions
- Destinations
- Annotations
- Embedded File Streams
- Colors and Color Spaces
- Page Formats and Boundaries
- Standard and Public Key Encryption
- Fonts and Encodings
- Corrupted Documents
- Reader Enabled Documents
- Refactor Old SetaPDF Code
- API Reference
Embedded File Streams
Table of Contents
Introduction
Embedded file streams allow you to embed an external file directly within the body of a PDF file. This embedded file streams are referenced by a file specification then, which can be attached to the global embedded files name tree or a file attachment annotation.
The EmbeddedFileStream Class
An embedded file stream is represented by the SetaPDF_Core_EmbeddedFileStream
class which offers following getter and setter methods:
create()
Create an embedded file stream.
getMimeType()
Get the subtype of the embedded file.
getParams()
Get the entries and data of the embedded file parameter dictionary.
setMimeType()
Set the mime type (or subtype) of the embedded file stream.
setParams()
Set the entries in the embedded file parameter dictionary.
The FileSpecification Class
An embedded file stream is referenced by a file specification through its EF (embedded file stream) entry. A file specification offers several other methods:
createEmbedded()
Create a file specification with an embedded file stream.
getCollectionItem()
Get the collection item data.
getDescription()
Get the descriptive text associated with the file specification.
getDictionary()
Get the dictionary.
getEmbeddedFileStream()
Get the embedded file stream object.
getFileSpecification()
Get the file specification value.
getFileSystem()
Get name of the file system.
getUnicodeFileSpecification()
Get the unicode text file specification value.
getVolatile()
Get the volatile flag.
setCollectionItem()
Set the collection item data.
setDescription()
Set the descriptive text associated with the file specification.
setEmbeddedFileStream()
Set the embedded file stream object.
setFileSpecification()
Set the file specification value.
setFileSystem()
Set the file system name.
setUnicodeFileSpecification()
Set the unicode text file specification value.
setVolatile()
Set the volatile flag.
To create a file specification with an embedded file stream you should use the static helper method createEmbedded()
.
The EmbeddedFiles Name Tree
The EmbeddedFiles name tree maps name strings to file specifications for embedded file streams. It is represented by the SetaPDF_Core_Document_Catalog_Names_EmbeddedFiles
which can be resolved by following code:
$document = new \SetaPDF_Core_Document(); //... $embeddedFiles = $document->getCatalog()->getNames()->getEmbeddedFiles();
add()
Adds an embedded file by its file specification.
get()
Get an embedded file by its name.
getAll()
Get all embedded files.
remove()
Remove an embedded file.
The registered names should be PDF strings (PDFDoc encoding or UTF-16BE including BOM).
Keep in mind that name parameter are encoding specific.