diff --git a/cpdfdraw.ml b/cpdfdraw.ml index 201d227..094d4cf 100644 --- a/cpdfdraw.ml +++ b/cpdfdraw.ml @@ -429,7 +429,7 @@ let rec ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num [] | TextSection ops -> let m = mcid () in - if not dryrun then structdata := StDataMCID ("/P", m, None)::!structdata; + if not dryrun then structdata := StDataMCID ("P", m, None)::!structdata; (if struct_tree && !do_auto_tag then [Pdfops.Op_BDC ("/P", Pdf.Dictionary ["/MCID", Pdf.Integer m])] else []) @ [Pdfops.Op_BT] @ ops_of_drawops struct_tree dryrun pdf endpage filename bates batespad num page ops @@ -460,7 +460,7 @@ let rec ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num | Tag s -> let m = mcid () in if not dryrun then structdata := StDataMCID (s, m, None)::!structdata; - [Pdfops.Op_BDC (s, Pdf.Dictionary ["/MCID", Pdf.Integer m])] + [Pdfops.Op_BDC ("/" ^ s, Pdf.Dictionary ["/MCID", Pdf.Integer m])] | EndTag -> [Pdfops.Op_EMC] | STag s -> if not dryrun then structdata =| StDataBeginTree s; [] | EndSTag -> if not dryrun then structdata =| StDataEndTree; [] @@ -691,7 +691,7 @@ let write_structure_tree pdf st = (alt @ page @ namespace - @ [("/S", Pdf.Name kind); + @ [("/S", Pdf.Name ("/" ^ kind)); ("/P", Pdf.Indirect struct_tree_parent); ("/K", Pdf.Array (map (mktree this_objnum) children))]) in diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index a2619e2..b887b6a 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 2f38364..9de2a78 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -5210,7 +5210,38 @@ $cpdf -print-struct-tree out.pdf There are two types of tag we can add manually. One kind is used to tag individual pieces of content. We do this with a \texttt{-tag}/\texttt{-end-tag} pair. Note that nesting is not permitted here. For example, let us tag a heading: -(H1 / Para example) +\begin{framed} + \noindent\small\verb!cpdf -create-pdf AND -draw-struct-tree -draw -mtrans "50 700" !\\ + \noindent\small\verb! -font-size 40 -no-auto-tags -tag H1 -bt -text "This is the heading"!\\ + \noindent\small\verb! -et -end-tag -auto-tags -mtrans "0 -100" -font-size 20 -leading 25!\\ + \noindent\small\verb! -bt -paras "L200pt=This is the first paragraph, which spreads over!\\ + \noindent\small\verb!more than one line\nHere is the second, which also has multiple lines..."!\\ + \noindent\small\verb! -et AND -o out.pdf! + \noindent\small\verb!! + \noindent\small\verb!! + \noindent\small\verb!! + +\end{framed} + +\noindent Here is the result, visually: + +\bigskip +\fbox{\includegraphics[width=0.3\textwidth]{manualimages/h1.pdf}} +\bigskip + +\noindent And here is the structure tree: + +\begin{verbatim} +/StructTreeRoot +└── + ├── /H1 (1) + │ └── + ├── /P (1) + │ └── + └── /P (1) + └── +\end{verbatim} + \noindent\verb!-stag! Begin structure tree branch\\ \noindent\verb!-end-stag! End structure tree branch\\ diff --git a/manualimages/h1.pdf b/manualimages/h1.pdf new file mode 100644 index 0000000..64f3c32 Binary files /dev/null and b/manualimages/h1.pdf differ