mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-06-05 22:09:39 +02:00
Regularize exit codes for PDF exploration commands
This commit is contained in:
@ -3647,11 +3647,11 @@ let extract_stream pdf decomp objnum =
|
|||||||
let data =
|
let data =
|
||||||
match obj with
|
match obj with
|
||||||
| Pdf.Stream {contents = (_, Pdf.Got x)} -> x
|
| Pdf.Stream {contents = (_, Pdf.Got x)} -> x
|
||||||
| _ -> mkbytes 0
|
| _ -> raise (Pdf.PDFError "Stream not found")
|
||||||
in
|
in
|
||||||
match args.out with
|
match args.out with
|
||||||
| NoOutputSpecified ->
|
| NoOutputSpecified ->
|
||||||
()
|
raise (Pdf.PDFError "No output specified")
|
||||||
| File outname ->
|
| File outname ->
|
||||||
let fh = open_out_bin outname in
|
let fh = open_out_bin outname in
|
||||||
output_string fh (Pdfio.string_of_bytes data);
|
output_string fh (Pdfio.string_of_bytes data);
|
||||||
@ -3688,7 +3688,8 @@ let print_obj json pdf objspec =
|
|||||||
let obj = if objnum = 0 then pdf.Pdf.trailerdict else Pdf.lookup_obj pdf objnum in
|
let obj = if objnum = 0 then pdf.Pdf.trailerdict else Pdf.lookup_obj pdf objnum in
|
||||||
match Pdf.lookup_chain pdf obj chain with
|
match Pdf.lookup_chain pdf obj chain with
|
||||||
| Some x -> write x
|
| Some x -> write x
|
||||||
| None -> ()
|
| None ->
|
||||||
|
Pdfe.log "Chain not found"; exit 2
|
||||||
in
|
in
|
||||||
match explode objspec with
|
match explode objspec with
|
||||||
| 'P'::more ->
|
| 'P'::more ->
|
||||||
@ -3709,7 +3710,10 @@ let print_version () =
|
|||||||
let replace_obj pdf objspec obj =
|
let replace_obj pdf objspec obj =
|
||||||
let split_chain str = map (fun x -> "/" ^ x) (tl (String.split_on_char '/' str)) in
|
let split_chain str = map (fun x -> "/" ^ x) (tl (String.split_on_char '/' str)) in
|
||||||
let chain = split_chain objspec in
|
let chain = split_chain objspec in
|
||||||
Pdf.replace_chain pdf chain obj
|
try
|
||||||
|
Pdf.replace_chain pdf chain obj
|
||||||
|
with
|
||||||
|
e -> Pdfe.log "Chain not found"; exit 2
|
||||||
|
|
||||||
(* Call out to GhostScript to rasterize. Read back in and replace the page contents with the resultant PNG. *)
|
(* Call out to GhostScript to rasterize. Read back in and replace the page contents with the resultant PNG. *)
|
||||||
let rasterize antialias downsample device res annots quality pdf range =
|
let rasterize antialias downsample device res annots quality pdf range =
|
||||||
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
@ -6582,7 +6582,7 @@ $ ./cpdf -obj /Root/Pages/Count cpdfmanual.pdf
|
|||||||
"/MCBERL+URWPalladioL-Roma"
|
"/MCBERL+URWPalladioL-Roma"
|
||||||
\end{verbatim}}
|
\end{verbatim}}
|
||||||
|
|
||||||
\noindent To output data in JSON format instead of PDF format, use \texttt{-obj-json} in place of \texttt{-obj}.
|
\noindent If the object does not exist, Cpdf will exit with code 2. To output data in JSON format instead of PDF format, use \texttt{-obj-json} in place of \texttt{-obj}.
|
||||||
|
|
||||||
A stream may be extracted with \texttt{-extract-stream} or \texttt{-extract-stream-decompress}, which decompresses it first where possible:
|
A stream may be extracted with \texttt{-extract-stream} or \texttt{-extract-stream-decompress}, which decompresses it first where possible:
|
||||||
|
|
||||||
|
@ -263,7 +263,6 @@ let replace_dict_entry pdf key value search =
|
|||||||
Pdf.objselfmap (dict_entry_single_object f pdf) pdf;
|
Pdf.objselfmap (dict_entry_single_object f pdf) pdf;
|
||||||
pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict
|
pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict
|
||||||
|
|
||||||
(* FIXME no need to self map here, since nothing changes *)
|
|
||||||
let print_dict_entry ~utf8 pdf key =
|
let print_dict_entry ~utf8 pdf key =
|
||||||
let f d =
|
let f d =
|
||||||
match Pdf.lookup_direct pdf key d with
|
match Pdf.lookup_direct pdf key d with
|
||||||
|
Reference in New Issue
Block a user