more
This commit is contained in:
parent
51472da1fa
commit
9f50046c52
|
@ -3376,6 +3376,32 @@ let warn_prerotate range pdf =
|
||||||
let prerotate range pdf =
|
let prerotate range pdf =
|
||||||
Cpdfpage.upright ~fast:args.fast range pdf
|
Cpdfpage.upright ~fast:args.fast range pdf
|
||||||
|
|
||||||
|
let find_composition_fonts pdf i obj marked =
|
||||||
|
match Pdf.lookup_direct pdf "/Subtype" obj with
|
||||||
|
| Some (Pdf.Name "/Image") ->
|
||||||
|
Hashtbl.add marked i ();
|
||||||
|
String.length (Pdfwrite.string_of_pdf_including_data obj);
|
||||||
|
| _ -> 0
|
||||||
|
|
||||||
|
let find_composition_content_streams pdf i obj marked =
|
||||||
|
match Pdf.lookup_direct pdf "/Type" obj with
|
||||||
|
| Some (Pdf.Name "/Page") ->
|
||||||
|
let cs =
|
||||||
|
begin match Pdf.lookup_direct pdf "/Contents" obj with
|
||||||
|
| Some (Pdf.Indirect i) -> [i]
|
||||||
|
| Some (Pdf.Array is) -> option_map (function Pdf.Indirect i -> Some i | _ -> None) is
|
||||||
|
| _ -> []
|
||||||
|
end
|
||||||
|
in
|
||||||
|
let l = ref 0 in
|
||||||
|
iter
|
||||||
|
(fun i ->
|
||||||
|
Hashtbl.add marked i ();
|
||||||
|
l += String.length (Pdfwrite.string_of_pdf_including_data (Pdf.lookup_obj pdf i)))
|
||||||
|
cs;
|
||||||
|
!l
|
||||||
|
| _ -> 0
|
||||||
|
|
||||||
let find_composition pdf =
|
let find_composition pdf =
|
||||||
let marked = null_hash () in
|
let marked = null_hash () in
|
||||||
let images = ref 0 in
|
let images = ref 0 in
|
||||||
|
@ -3383,11 +3409,8 @@ let find_composition pdf =
|
||||||
Pdf.objiter
|
Pdf.objiter
|
||||||
(fun i obj ->
|
(fun i obj ->
|
||||||
match Hashtbl.find marked i with _ -> () | exception Not_found ->
|
match Hashtbl.find marked i with _ -> () | exception Not_found ->
|
||||||
match Pdf.lookup_direct pdf "/Subtype" obj with
|
images += find_composition_fonts pdf i obj marked;
|
||||||
| Some (Pdf.Name "/Image") ->
|
content_streams += find_composition_content_streams pdf i obj marked)
|
||||||
images += String.length (Pdfwrite.string_of_pdf_including_data obj);
|
|
||||||
Hashtbl.add marked i ()
|
|
||||||
| _ -> ())
|
|
||||||
pdf;
|
pdf;
|
||||||
(!images, !content_streams)
|
(!images, !content_streams)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue