diff --git a/Changes b/Changes index 780cd8d..613af02 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,7 @@ o Build PDF files from JPEG2000 (.jp2, .jpf/.jpx) files o Mark a file as PDF/UA compliant, or remove such marking o Verify compliance to PDF/UA via the Matterhorn protocol o Extract, edit and reapply document structure tree +o Print structure tree summary o Split structure tree when splitting PDF to save size o Combine structure trees when stamping PDFs o Set the natural language of a file diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 343d90e..bed7921 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -3444,6 +3444,7 @@ let extract_stream pdf decomp objnum = commas. Begins with P and it's a page number then a (possibly empty) chain. Otherwise it's an object number (0 = trailerdict). *) let print_obj pdf objspec = + let split str = map (fun x -> "/" ^ x) (tl (String.split_on_char '/' str)) in let simple_obj obj = let obj = if obj = 0 then pdf.Pdf.trailerdict else Pdf.lookup_obj pdf obj in Printf.printf "%S\n" (Pdfwrite.string_of_pdf obj) @@ -3459,10 +3460,10 @@ let print_obj pdf objspec = let number, chain = let digits, rest = cleavewhile isdigit more in List.nth (Pdf.page_reference_numbers pdf) (int_of_string (implode digits) - 1), - begin match String.split_on_char ',' (implode rest) with [""] -> [] | x -> x end + begin match split (implode rest) with [""] -> [] | x -> x end in chain_obj number chain - | '/'::more -> chain_obj 0 (String.split_on_char ',' (implode ('/'::more))) + | '/'::more -> chain_obj 0 (split (implode ('/'::more))) | [] -> simple_obj 0 | _ -> simple_obj (int_of_string objspec) diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index aa712c6..223bbc9 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfmanual.tex b/cpdfmanual.tex index a64c711..74e55fa 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -5266,7 +5266,7 @@ We can print an abbreviated form of the structure tree to standard output with \ This JSON file can be edited, for example to change text strings, and reapplied with \texttt{cpdf -replace-struct-tree out.json in.pdf -o out.pdf}. If extra objects are required, they should be introduced with negative object numbers: cpdf will renumber them on import so as not to clash with any existing numbers. -To remove a structure tree from a PDF, we can use \texttt{-remove-dict-entry} from Chapter \ref{chap:misc} i.e \texttt{cpdf -remove-struct-entry /StructTreeRoot in.pdf -o out.pdf}. +To remove a structure tree from a PDF, we can use \texttt{-remove-dict-entry} from Chapter \ref{chap:misc} i.e \texttt{cpdf -remove-dict-entry /StructTreeRoot in.pdf -o out.pdf}. \section{Verifying conformance to PDF/UA} @@ -5400,7 +5400,7 @@ Once we are sure a file complies to PDF/UA, in terms of both machine and human c \noindent\verb!cpdf -remove-clipping [] in.pdf -o out.pdf! \vspace{1.5mm} - \noindent\verb!cpdf -obj in.pdf! + \noindent\verb!cpdf -obj in.pdf! \vspace{1.5mm} \noindent\verb!cpdf -extract-stream[-decompress] in.pdf [-o out.dat | -stdout]! @@ -5618,14 +5618,14 @@ $ cpdf -obj 1238 out.pdf \noindent Alternatively, we may follow a chain of dictionary entries from the trailer dictionary: {\small\begin{verbatim} -$ ./cpdf -obj /Root,/Pages,/Count cpdfmanual.pdf +$ ./cpdf -obj /Root/Pages/Count cpdfmanual.pdf "133" \end{verbatim}} \noindent We may also begin at a numbered page instead of at the trailer dictionary: {\small\begin{verbatim} -./cpdf -obj P20/Resources,/Font,/F58,/BaseFont cpdfmanual.pdf +./cpdf -obj P20/Resources/Font/F58/BaseFont cpdfmanual.pdf "/MCBERL+URWPalladioL-Roma" \end{verbatim}}