File tree Expand file tree Collapse file tree 4 files changed +73
-43
lines changed Expand file tree Collapse file tree 4 files changed +73
-43
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ pub struct Outline {
33
33
children : Vec < OutlineNode > ,
34
34
}
35
35
36
+ impl Outline {
37
+ pub ( crate ) fn is_empty ( & self ) -> bool {
38
+ self . children . is_empty ( )
39
+ }
40
+ }
41
+
36
42
impl Default for Outline {
37
43
fn default ( ) -> Self {
38
44
Self :: new ( )
Original file line number Diff line number Diff line change @@ -247,7 +247,9 @@ impl SerializeContext {
247
247
}
248
248
249
249
pub ( crate ) fn set_outline ( & mut self , outline : Outline ) {
250
- self . global_objects . outline = MaybeTaken :: new ( Some ( outline) ) ;
250
+ if !outline. is_empty ( ) {
251
+ self . global_objects . outline = MaybeTaken :: new ( Some ( outline) ) ;
252
+ }
251
253
}
252
254
253
255
pub ( crate ) fn set_metadata ( & mut self , metadata : Metadata ) {
Original file line number Diff line number Diff line change @@ -508,10 +508,11 @@ impl Validator {
508
508
mod tests {
509
509
use crate :: action:: LinkAction ;
510
510
use crate :: annotation:: { Annotation , LinkAnnotation , Target } ;
511
+ use crate :: destination:: XyzDestination ;
511
512
use crate :: error:: KrillaError ;
512
513
use crate :: font:: { Font , GlyphId , GlyphUnits , KrillaGlyph } ;
513
514
use crate :: metadata:: Metadata ;
514
- use crate :: outline:: Outline ;
515
+ use crate :: outline:: { Outline , OutlineNode } ;
515
516
use crate :: page:: Page ;
516
517
use crate :: paint:: { LinearGradient , SpreadMethod } ;
517
518
use crate :: path:: { Fill , FillRule } ;
@@ -995,7 +996,11 @@ mod tests {
995
996
. title ( "a nice title" . to_string ( ) ) ;
996
997
document. set_metadata ( metadata) ;
997
998
998
- let outline = Outline :: new ( ) ;
999
+ let mut outline = Outline :: new ( ) ;
1000
+ outline. push_child ( OutlineNode :: new (
1001
+ "Test" . to_string ( ) ,
1002
+ XyzDestination :: new ( 0 , Point :: from_xy ( 0.0 , 0.0 ) ) ,
1003
+ ) ) ;
999
1004
document. set_outline ( outline) ;
1000
1005
}
1001
1006
Original file line number Diff line number Diff line change 5
5
<<
6
6
/Type /Pages
7
7
/Count 1
8
- /Kids [8 0 R]
8
+ /Kids [10 0 R]
9
9
>>
10
10
endobj
11
11
12
12
2 0 obj
13
13
<<
14
14
/Type /Outlines
15
+ /First 3 0 R
16
+ /Last 3 0 R
17
+ /Count 1
15
18
>>
16
19
endobj
17
20
18
21
3 0 obj
22
+ <<
23
+ /Parent 2 0 R
24
+ /Title (Test)
25
+ /Dest 9 0 R
26
+ >>
27
+ endobj
28
+
29
+ 4 0 obj
19
30
<<
20
31
/Type /StructTreeRoot
21
32
/RoleMap <<
22
33
/Datetime /Span
23
34
/Terms /Part
24
35
/Title /H1
25
36
>>
26
- /K [5 0 R]
37
+ /K [6 0 R]
27
38
/ParentTree <<
28
- /Nums [0 4 0 R]
39
+ /Nums [0 5 0 R]
29
40
>>
30
41
/ParentTreeNextKey 1
31
42
>>
32
43
endobj
33
44
34
- 4 0 obj
35
- [7 0 R 6 0 R]
45
+ 5 0 obj
46
+ [8 0 R 7 0 R]
36
47
endobj
37
48
38
- 5 0 obj
49
+ 6 0 obj
39
50
<<
40
51
/Type /StructElem
41
52
/S /Document
42
- /P 3 0 R
43
- /K [7 0 R 6 0 R]
53
+ /P 4 0 R
54
+ /K [8 0 R 7 0 R]
44
55
>>
45
56
endobj
46
57
47
- 6 0 obj
58
+ 7 0 obj
48
59
<<
49
60
/Type /StructElem
50
61
/S /TH
51
- /P 5 0 R
62
+ /P 6 0 R
52
63
/A [<<
53
64
/O /Table
54
65
/Scope /Row
55
66
>>]
56
67
/K [1]
57
- /Pg 8 0 R
68
+ /Pg 10 0 R
58
69
>>
59
70
endobj
60
71
61
- 7 0 obj
72
+ 8 0 obj
62
73
<<
63
74
/Type /StructElem
64
75
/S /L
65
- /P 5 0 R
76
+ /P 6 0 R
66
77
/A [<<
67
78
/O /List
68
79
/ListNumbering /Circle
69
80
>>]
70
81
/K [0]
71
- /Pg 8 0 R
82
+ /Pg 10 0 R
72
83
>>
73
84
endobj
74
85
75
- 8 0 obj
86
+ 9 0 obj
87
+ [10 0 R /XYZ 0 842 0]
88
+ endobj
89
+
90
+ 10 0 obj
76
91
<<
77
92
/Type /Page
78
93
/Resources <<
@@ -81,11 +96,11 @@ endobj
81
96
/MediaBox [0 0 595 842]
82
97
/StructParents 0
83
98
/Parent 1 0 R
84
- /Contents 9 0 R
99
+ /Contents 11 0 R
85
100
>>
86
101
endobj
87
102
88
- 9 0 obj
103
+ 11 0 obj
89
104
<<
90
105
/Length 201
91
106
>>
@@ -122,30 +137,30 @@ EMC
122
137
endstream
123
138
endobj
124
139
125
- 10 0 obj
140
+ 12 0 obj
126
141
<<
127
142
/Title (a nice title)
128
143
>>
129
144
endobj
130
145
131
- 11 0 obj
146
+ 13 0 obj
132
147
<<
133
148
/Length 961
134
149
/Type /Metadata
135
150
/Subtype /XML
136
151
>>
137
152
stream
138
- <?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?><x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="xmp-writer"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:xmpTPg="http://ns.adobe.com/xap/1.0/t/pg/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" xmlns:pdfuaid="http://www.aiim.org/pdfua/ns/id/" ><dc:title><rdf:Alt><rdf:li xml:lang="x-default">a nice title</rdf:li></rdf:Alt></dc:title><dc:language><rdf:Bag><rdf:li>en</rdf:li></rdf:Bag></dc:language><pdfuaid:part>1</pdfuaid:part><xmpTPg:NPages>1</xmpTPg:NPages><dc:format>application/pdf</dc:format><xmpMM:InstanceID>7t1JAG/css3tUUA6/AmdMA ==</xmpMM:InstanceID><xmpMM:DocumentID>7t1JAG/css3tUUA6/AmdMA ==</xmpMM:DocumentID><xmpMM:RenditionClass>proof</xmpMM:RenditionClass><pdf:PDFVersion>1.7</pdf:PDFVersion></rdf:Description></rdf:RDF></x:xmpmeta><?xpacket end="r"?>
153
+ <?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?><x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="xmp-writer"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:xmpTPg="http://ns.adobe.com/xap/1.0/t/pg/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" xmlns:pdfuaid="http://www.aiim.org/pdfua/ns/id/" ><dc:title><rdf:Alt><rdf:li xml:lang="x-default">a nice title</rdf:li></rdf:Alt></dc:title><dc:language><rdf:Bag><rdf:li>en</rdf:li></rdf:Bag></dc:language><pdfuaid:part>1</pdfuaid:part><xmpTPg:NPages>1</xmpTPg:NPages><dc:format>application/pdf</dc:format><xmpMM:InstanceID>fLu8RnbyO5J0/UMUrJ4ToA ==</xmpMM:InstanceID><xmpMM:DocumentID>fLu8RnbyO5J0/UMUrJ4ToA ==</xmpMM:DocumentID><xmpMM:RenditionClass>proof</xmpMM:RenditionClass><pdf:PDFVersion>1.7</pdf:PDFVersion></rdf:Description></rdf:RDF></x:xmpmeta><?xpacket end="r"?>
139
154
endstream
140
155
endobj
141
156
142
- 12 0 obj
157
+ 14 0 obj
143
158
<<
144
159
/Type /Catalog
145
160
/Pages 1 0 R
146
- /Metadata 11 0 R
161
+ /Metadata 13 0 R
147
162
/Lang (en)
148
- /StructTreeRoot 3 0 R
163
+ /StructTreeRoot 4 0 R
149
164
/MarkInfo <<
150
165
/Marked true
151
166
/Suspects false
@@ -158,27 +173,29 @@ endobj
158
173
endobj
159
174
160
175
xref
161
- 0 13
176
+ 0 15
162
177
0000000000 65535 f
163
178
0000000016 00000 n
164
- 0000000080 00000 n
165
- 0000000120 00000 n
166
- 0000000315 00000 n
167
- 0000000345 00000 n
168
- 0000000432 00000 n
169
- 0000000560 00000 n
170
- 0000000697 00000 n
171
- 0000000875 00000 n
172
- 0000001130 00000 n
173
- 0000001177 00000 n
174
- 0000002227 00000 n
179
+ 0000000081 00000 n
180
+ 0000000161 00000 n
181
+ 0000000229 00000 n
182
+ 0000000424 00000 n
183
+ 0000000454 00000 n
184
+ 0000000541 00000 n
185
+ 0000000670 00000 n
186
+ 0000000808 00000 n
187
+ 0000000846 00000 n
188
+ 0000001026 00000 n
189
+ 0000001282 00000 n
190
+ 0000001329 00000 n
191
+ 0000002379 00000 n
175
192
trailer
176
193
<<
177
- /Size 13
178
- /Root 12 0 R
179
- /Info 10 0 R
180
- /ID [(7t1JAG/css3tUUA6/AmdMA ==) (7t1JAG/css3tUUA6/AmdMA ==)]
194
+ /Size 15
195
+ /Root 14 0 R
196
+ /Info 12 0 R
197
+ /ID [(fLu8RnbyO5J0/UMUrJ4ToA ==) (fLu8RnbyO5J0/UMUrJ4ToA ==)]
181
198
>>
182
199
startxref
183
- 2468
200
+ 2620
184
201
%%EOF
You can’t perform that action at this time.
0 commit comments