mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2024-12-22 15:05:46 +01:00
@b
This commit is contained in:
parent
8119e6eb3f
commit
64e415084a
2
Changes
2
Changes
@ -2,6 +2,8 @@
|
||||
|
||||
o New -center-to-fit centres pages on a given paper size
|
||||
o Allow bold, italic, colours for bookmarks
|
||||
o Clean up @B implementation for -split-on-bookmarks
|
||||
o Add @b for trimmed bookmarks
|
||||
|
||||
2.7.2 (October 2024)
|
||||
|
||||
|
@ -143,7 +143,6 @@ let parse_bookmark_file verify pdf input =
|
||||
!currline
|
||||
(Printexc.to_string e))
|
||||
|
||||
|
||||
let add_bookmarks ~json verify input pdf =
|
||||
let parsed =
|
||||
(if json then parse_bookmark_file_json else parse_bookmark_file) verify pdf input in
|
||||
@ -273,10 +272,10 @@ let get_bookmark_name encoding pdf marks splitlevel n _ =
|
||||
(* @S means start page of this section *)
|
||||
(* @E means end page of this section *)
|
||||
(* @B means bookmark name at start page *)
|
||||
(* @b52| means bookmark name at start page truncated to 52 characters using crude UTF8 truncation. *)
|
||||
(* @b52@ means bookmark name at start page truncated to 52 characters using crude UTF8 truncation. *)
|
||||
let process_others encoding marks pdf splitlevel filename sequence startpage endpage s =
|
||||
let trim_utf8 len l =
|
||||
Printf.printf "trim_uff input $%S$\n" (implode l);
|
||||
let l = try take l len with _ -> l in
|
||||
(* This truncator is far from perfect, but it does yield a valid UTF8 string, when given one. *)
|
||||
match rev l with
|
||||
| b2::b1::b0::t ->
|
||||
@ -327,8 +326,9 @@ let process_others encoding marks pdf splitlevel filename sequence startpage end
|
||||
procss (rev (explode (get_bookmark_name encoding pdf marks splitlevel startpage pdf)) @ prev) t
|
||||
| '@'::'b'::t ->
|
||||
let number, rest = cleavewhile (function '0'..'9' -> true | _ -> false) t in
|
||||
begin try ignore (int_of_string (implode number)) with _ -> error "Bad @b spec" end;
|
||||
let text = trim_utf8 (int_of_string (implode number)) (explode (get_bookmark_name encoding pdf marks splitlevel startpage pdf)) in
|
||||
procss ((rev text) @ prev) (tl rest)
|
||||
procss (rev text @ prev) (if rest = [] then [] else tl rest)
|
||||
| h::t -> procss (h::prev) t
|
||||
in
|
||||
implode (procss [] (explode s))
|
||||
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
@ -1304,6 +1304,7 @@ the result is unspecified. The following format operators may be used:
|
||||
\texttt{@S} & Start page of this chunk \\
|
||||
\texttt{@E} & End page of this chunk \\
|
||||
\texttt{@B} & Bookmark name at this page, if any. \\
|
||||
\texttt{@b<w>@} & Bookmark name at this page, if any, truncated to \texttt{<n>} characters.\\
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
|
||||
@ -1346,6 +1347,16 @@ one of the output files.
|
||||
\verb! / ? < > \ : * | " ^ + =!
|
||||
\end{framed}
|
||||
|
||||
\noindent The bookmark may be truncated by using the \texttt{@b} variant:
|
||||
|
||||
\begin{framed}\small
|
||||
\noindent\verb!cpdf -split-bookmarks 0 a.pdf -o @b10@.pdf!
|
||||
|
||||
\vspace{2.5mm}
|
||||
\noindent Split \texttt{a.pdf} on bookmark boundaries, using the first 10 characters of bookmark text as the filename.
|
||||
|
||||
\end{framed}
|
||||
|
||||
\section{Splitting to Maximum Size}
|
||||
|
||||
The \texttt{-split-max} operation splits a file into chunks of no more than the given size, starting at the beginning. The suffixes kB, KiB, MB, MiB, GB, and GiB may be used to give the size. For example:
|
||||
|
Loading…
Reference in New Issue
Block a user