From b3320180811226f04aa486b537a6bc5ba16b3c04 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Fri, 22 Mar 2024 15:33:08 +0000 Subject: [PATCH] Make sure JPEG2000 images are listed --- cpdfcommand.ml | 6 ++++-- cpdfimage.ml | 6 +++--- cpdfmanual.tex | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index fbe2665..05caaaf 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -4244,9 +4244,11 @@ let go () = begin match json with | `List l -> iter - (function (`Assoc [(_, `Int i); (_, `List pages); (_, `String name); (_, `Int w); (_, `Int h); (_, `Int size); (_, `Int bpc); (_, `String cs); (_, `String filter)]) -> + (function (`Assoc [(_, `Int i); (_, `List pages); (_, `String name); (_, `Int w); (_, `Int h); (_, `Int size); (_, bpc); (_, cs); (_, `String filter)]) -> let pages = combine_with_spaces (map (function `Int i -> string_of_int i | _ -> "") pages) in - flprint (Printf.sprintf "%i, %s, %s, %i, %i, %i, %i, %s, %s\n" i pages name w h size bpc cs filter) + let bpc = match bpc with `Int bpc -> string_of_int bpc | _ -> "none" in + let cs = match cs with `String cs -> cs | _ -> "none" in + flprint (Printf.sprintf "%i, %s, %s, %i, %i, %i, %s, %s, %s\n" i pages name w h size bpc cs filter) | _ -> ()) l | _ -> () diff --git a/cpdfimage.ml b/cpdfimage.ml index 427d7c1..d605d0b 100644 --- a/cpdfimage.ml +++ b/cpdfimage.ml @@ -365,8 +365,8 @@ let images pdf range = | _ -> 0 and bpc = match Pdf.lookup_direct pdf "/BitsPerComponent" xobject with - | Some (Pdf.Integer x) -> x - | _ -> 0 + | Some (Pdf.Integer x) -> Some x + | _ -> None and colourspace = match Pdf.lookup_direct pdf "/ColorSpace" xobject with | Some x -> Some (Pdfspace.string_of_colourspace (Pdfspace.read_colourspace pdf resources x)) @@ -420,7 +420,7 @@ let images pdf range = ("Width", `Int w); ("Height", `Int h); ("Bytes", `Int size); - ("BitsPerComponent", `Int bpc); + ("BitsPerComponent", match bpc with None -> `Null | Some bpc -> `Int bpc); ("Colourspace", match cs with None -> `Null | Some s -> `String s); ("Filter", match filter with None -> `Null | Some s -> `String s)]) images) diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 593a4f7..b8d68bc 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -1,3 +1,4 @@ +%Document JPEG2000 embedding \documentclass{book} % Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf, % dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.