[cairo-commit] src/cairo-pdf-interchange.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Thu Nov 16 09:48:43 UTC 2017


 src/cairo-pdf-interchange.c |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

New commits:
commit 0c8070f5bc74c124e6393b433a61807a8e4bee5d
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Thu Nov 16 20:16:14 2017 +1030

    pdf: fix document structure for non tagged structures

diff --git a/src/cairo-pdf-interchange.c b/src/cairo-pdf-interchange.c
index 78a8db67..461986fb 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;
 }


More information about the cairo-commit mailing list