xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/document_properties.in (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1{{header}}
2{{object 1 0}} <<
3  /Type /Catalog
4  /Pages 2 0 R
5  /OpenAction 10 0 R
6>>
7endobj
8{{object 2 0}} <<
9  /Type /Pages
10  /Count 4
11  /Kids [
12    3 0 R
13    4 0 R
14    5 0 R
15    6 0 R
16  ]
17>>
18endobj
19% Page number 0.
20{{object 3 0}} <<
21  /Type /Page
22  /Parent 2 0 R
23  /Resources <<
24    /Font <</F1 15 0 R>>
25  >>
26  /MediaBox [0 0 612 792]
27>>
28endobj
29% Page number 1.
30{{object 4 0}} <<
31  /Type /Page
32  /Parent 2 0 R
33  /Resources <<
34    /Font <</F1 15 0 R>>
35  >>
36  /MediaBox [0 0 612 792]
37>>
38endobj
39% Page number 2.
40{{object 5 0}} <<
41  /Type /Page
42  /Parent 2 0 R
43  /Resources <<
44    /Font <</F1 15 0 R>>
45  >>
46  /MediaBox [0 0 612 792]
47>>
48endobj
49% Page number 3.
50{{object 6 0}} <<
51  /Type /Page
52  /Parent 2 0 R
53  /Resources <<
54    /Font <</F1 15 0 R>>
55  >>
56  /MediaBox [0 0 612 792]
57>>
58endobj
59
60% Info
61{{object 9 0}} <<
62  /Author (Joe Random Author)
63  /Creator (Joe Random Creator)
64>>
65endobj
66% OpenAction action
67{{object 10 0}} <<
68  /Type /Action
69  /S /JavaScript
70  /JS 11 0 R
71>>
72endobj
73% JS program to execute
74{{object 11 0}} <<
75  {{streamlen}}
76>>
77stream
78var document_props = [
79  'ADBE',
80  'author',
81  'baseURL',
82  'bookmarkRoot',
83  'calculate',
84  'Collab',
85  'creationDate',
86  'creator',
87  'delay',
88  'dirty',
89  'documentFileName',
90  'external',
91  'filesize',
92  'icons',
93  'info',
94  'keywords',
95  'layout',
96  'media',
97  'modDate',
98  'mouseX',
99  'mouseY',
100  'numFields',
101  'numPages',
102  'pageNum',
103  'pageWindowRect',
104  'path',
105  'producer',
106  'subject',
107  'title',
108  'URL',
109  'zoom',
110  'zoomType',
111];
112
113function testGetProps(props) {
114  app.alert('*** Getting properties ***');
115  for (var i = 0; i < props.length; ++i) {
116    try {
117      var expr1 = "this." + props[i];
118      var expr2 = "typeof " + expr1;
119      app.alert(expr1 + " is " + eval(expr2) + ' ' + eval(expr1));
120    } catch (e) {
121      app.alert("ERROR: " + e.toString());
122    }
123  }
124}
125
126function testSetProps(props, value) {
127  app.alert('*** Setting properties to ' + value + ' ***');
128  for (var i = 0; i < props.length; ++i) {
129    try {
130      var expr1 = "this." + props[i] + ' = ' + value + ';'
131      app.alert(expr1 + " yields " + eval(expr1));
132    } catch (e) {
133      app.alert("ERROR: " + e.toString());
134    }
135  }
136}
137
138testGetProps(document_props);
139testSetProps(document_props, 'true');
140testSetProps(document_props, 'false');
141testSetProps(document_props, '["red", 0, "blue", 42]');
142testSetProps(document_props, '{"red": 0, "blue": 42}');
143testSetProps(document_props, '"red"');
144testSetProps(document_props, '3');
145testGetProps(document_props);
146endstream
147endobj
148{{xref}}
149trailer <<
150  /Root 1 0 R
151  /Info 9 0 R
152>>
153{{startxref}}
154%%EOF
155