File: Zend_Pdf-Properties.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (239 lines) | stat: -rw-r--r-- 9,736 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.pdf.info">
    <!-- @todo review and revise upon completion of refactoring -->
    <title>Document Info and Metadata</title>

    <para>
        A <acronym>PDF</acronym> document may include general information such as the document's
        title, author, and creation and modification dates.
    </para>

    <para>
        Historically this information is stored using special Info structure. This structure
        is available for read and writing as an associative array using
        <property>properties</property> public property of <classname>Zend_Pdf</classname> objects:
    </para>

    <programlisting language="php"><![CDATA[
$pdf = Zend_Pdf::load($pdfPath);

echo $pdf->properties['Title'] . "\n";
echo $pdf->properties['Author'] . "\n";

$pdf->properties['Title'] = 'New Title.';
$pdf->save($pdfPath);
]]></programlisting>

    <para>
        The following keys are defined by <acronym>PDF</acronym> v1.4 (Acrobat 5) standard:

        <itemizedlist>
            <listitem>
                <para>
                    <emphasis>Title</emphasis> - string, optional, the document's title.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>Author</emphasis> - string, optional, the name of the person who
                    created the document.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>Subject</emphasis> - string, optional, the subject of the document.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>Keywords</emphasis> - string, optional, keywords associated with the
                    document.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>Creator</emphasis> - string, optional, if the document was converted
                    to <acronym>PDF</acronym> from another format, the name of the application (for
                    example, Adobe FrameMaker®) that created the original document from which it was
                    converted.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>Producer</emphasis> - string, optional, if the document was converted
                    to <acronym>PDF</acronym> from another format, the name of the application (for
                    example, Acrobat Distiller) that converted it to <acronym>PDF</acronym>..
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>CreationDate</emphasis> - string, optional, the date and time the
                    document was created, in the following form: "D:YYYYMMDDHHmmSSOHH'mm'", where:

                    <itemizedlist>
                        <listitem>
                            <para>
                                <emphasis>YYYY</emphasis> is the year.
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>MM</emphasis> is the month.
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>DD</emphasis> is the day (01–31).
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>HH</emphasis> is the hour (00–23).
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>mm</emphasis>is the minute (00–59).
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>SS</emphasis> is the second (00–59).
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>O</emphasis> is the relationship of local time to
                                Universal Time (UT), denoted by one of the characters +, −, or Z
                                (see below).
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>HH</emphasis> followed by ' is the absolute value of the
                                offset from UT in hours (00–23).
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>mm</emphasis> followed by ' is the absolute value of the
                                offset from UT in minutes (00–59).
                            </para>
                        </listitem>
                    </itemizedlist>

                    The apostrophe character (') after HH and mm is part of the syntax. All fields
                    after the year are optional. (The prefix D:, although also optional, is strongly
                    recommended.) The default values for MM and DD are both 01; all other numerical
                    fields default to zero values. A plus sign (+) as the value of the O field
                    signifies that local time is later than UT, a minus sign (−) that local time is
                    earlier than UT, and the letter Z that local time is equal to UT. If no UT
                    information is specified, the relationship of the specified time to UT is
                    considered to be unknown. Whether or not the time zone is known, the rest of the
                    date should be specified in local time.
                </para>

                <para>
                    For example, December 23, 1998, at 7:52 PM, U.S. Pacific Standard Time, is
                    represented by the string "D:199812231952−08'00'".
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>ModDate</emphasis> - string, optional, the date and time the document
                    was most recently modified, in the same form as
                    <emphasis>CreationDate</emphasis>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>Trapped</emphasis> - boolean, optional, indicates whether the document
                    has been modified to include trapping information.

                    <itemizedlist>
                        <listitem>
                            <para>
                                <emphasis><constant>TRUE</constant></emphasis> - The document has
                                been fully trapped; no further trapping is needed.
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis><constant>FALSE</constant></emphasis> - The document has
                                not yet been trapped; any desired trapping must still be done.
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis><constant>NULL</constant></emphasis> - Either it is
                                unknown whether the document has been trapped or it has been partly
                                but not yet fully trapped; some additional trapping may still be
                                needed.
                            </para>
                        </listitem>
                    </itemizedlist>
                </para>
            </listitem>
        </itemizedlist>
    </para>

    <para>
        Since <acronym>PDF</acronym> v 1.6 metadata can be stored in the special
        <acronym>XML</acronym> document attached to the <acronym>PDF</acronym> (XMP - <ulink
            url="http://www.adobe.com/products/xmp/">Extensible Metadata Platform</ulink>).
    </para>

    <para>
        This <acronym>XML</acronym> document can be retrieved and attached to the PDF with
        <methodname>Zend_Pdf::getMetadata()</methodname> and
        <methodname>Zend_Pdf::setMetadata($metadata)</methodname> methods:
    </para>

    <programlisting language="php"><![CDATA[
$pdf = Zend_Pdf::load($pdfPath);
$metadata = $pdf->getMetadata();
$metadataDOM = new DOMDocument();
$metadataDOM->loadXML($metadata);

$xpath = new DOMXPath($metadataDOM);
$pdfPreffixNamespaceURI = $xpath->query('/rdf:RDF/rdf:Description')
                                ->item(0)
                                ->lookupNamespaceURI('pdf');
$xpath->registerNamespace('pdf', $pdfPreffixNamespaceURI);

$titleNode = $xpath->query('/rdf:RDF/rdf:Description/pdf:Title')->item(0);
$title = $titleNode->nodeValue;
...

$titleNode->nodeValue = 'New title';
$pdf->setMetadata($metadataDOM->saveXML());
$pdf->save($pdfPath);
]]></programlisting>

    <para>
        Common document properties are duplicated in the Info structure and Metadata document (if
        presented). It's user application responsibility now to keep them synchronized.
    </para>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->