diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2017-11-16 20:16:14 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2017-11-16 20:16:14 +1030 |
commit | 0c8070f5bc74c124e6393b433a61807a8e4bee5d (patch) | |
tree | 0c249cabea983e1e9b6d2b6ec7e2c76f8d0be2ff /src/cairo-pdf-interchange.c | |
parent | 164be896603ceb419c5bc47c7348781f791f70e4 (diff) | |
download | cairo-0c8070f5bc74c124e6393b433a61807a8e4bee5d.tar.gz |
pdf: fix document structure for non tagged structures
Diffstat (limited to 'src/cairo-pdf-interchange.c')
-rw-r--r-- | src/cairo-pdf-interchange.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/cairo-pdf-interchange.c b/src/cairo-pdf-interchange.c index 78a8db673..461986fb3 100644 --- a/src/cairo-pdf-interchange.c +++ b/src/cairo-pdf-interchange.c @@ -543,13 +543,27 @@ cairo_pdf_interchange_write_struct_tree (cairo_pdf_surface_t *surface) _cairo_output_stream_printf (surface->output, "%d 0 obj\n" "<< /Type /StructTreeRoot\n" - " /ParentTree %d 0 R\n" - " /K [ %d 0 R ]\n" - ">>\n" - "endobj\n", + " /ParentTree %d 0 R\n", surface->struct_tree_root.id, - ic->parent_tree_res.id, - child->res.id); + ic->parent_tree_res.id); + + if (cairo_list_is_singular (&ic->struct_root->children)) { + child = cairo_list_first_entry (&ic->struct_root->children, cairo_pdf_struct_tree_node_t, link); + _cairo_output_stream_printf (surface->output, " /K [ %d 0 R ]\n", child->res.id); + } else { + _cairo_output_stream_printf (surface->output, " /K [ "); + + cairo_list_foreach_entry (child, cairo_pdf_struct_tree_node_t, + &ic->struct_root->children, link) + { + _cairo_output_stream_printf (surface->output, "%d 0 R ", child->res.id); + } + _cairo_output_stream_printf (surface->output, "]\n"); + } + + _cairo_output_stream_printf (surface->output, + ">>\n" + "endobj\n"); return CAIRO_STATUS_SUCCESS; } |