Don't clear page names on new page
This commit is contained in:
parent
04fad2295b
commit
f7bef42725
21
cpdfdraw.ml
21
cpdfdraw.ml
|
@ -91,7 +91,7 @@ let default_fontpack =
|
||||||
Cpdfembed.fontpack_of_standardfont
|
Cpdfembed.fontpack_of_standardfont
|
||||||
(Pdftext.StandardFont (Pdftext.TimesRoman, Pdftext.WinAnsiEncoding))
|
(Pdftext.StandardFont (Pdftext.TimesRoman, Pdftext.WinAnsiEncoding))
|
||||||
|
|
||||||
let fontpacks = null_hash ()
|
let fontpacks = ref (null_hash ())
|
||||||
|
|
||||||
let empty_res () =
|
let empty_res () =
|
||||||
{images = null_hash ();
|
{images = null_hash ();
|
||||||
|
@ -135,8 +135,8 @@ let fresh_name s =
|
||||||
(* At end of page, we keep things for which we have indirects - but ExtGStates
|
(* At end of page, we keep things for which we have indirects - but ExtGStates
|
||||||
aren't indirect, so they go. *)
|
aren't indirect, so they go. *)
|
||||||
let reset_state () =
|
let reset_state () =
|
||||||
Hashtbl.clear (res ()).extgstates;
|
Hashtbl.clear (res ()).extgstates(*;
|
||||||
(res ()).page_names <- []
|
(res ()).page_names <- []*)
|
||||||
|
|
||||||
let process_specials pdf endpage filename bates batespad num page s =
|
let process_specials pdf endpage filename bates batespad num page s =
|
||||||
let pairs =
|
let pairs =
|
||||||
|
@ -154,7 +154,6 @@ let runs_of_utf8 s =
|
||||||
(fun l ->
|
(fun l ->
|
||||||
if l = [] then [] else
|
if l = [] then [] else
|
||||||
let f, n = match l with (_, n, f)::_ -> f, n | _ -> assert false in
|
let f, n = match l with (_, n, f)::_ -> f, n | _ -> assert false in
|
||||||
(*Printf.printf "runs_of_utf8 - looking for (%s, %i) font\n" identifier n;*)
|
|
||||||
let fontname = fst (Hashtbl.find (res ()).fonts (identifier, n)) in
|
let fontname = fst (Hashtbl.find (res ()).fonts (identifier, n)) in
|
||||||
let charcodes = map (fun (c, _, _) -> char_of_int c) l in
|
let charcodes = map (fun (c, _, _) -> char_of_int c) l in
|
||||||
[Pdfops.Op_Tf (fontname, (res ()).font_size);
|
[Pdfops.Op_Tf (fontname, (res ()).font_size);
|
||||||
|
@ -251,7 +250,7 @@ let rec ops_of_drawop dryrun pdf endpage filename bates batespad num page = func
|
||||||
| FontPack (identifier, cpdffont, codepoints) ->
|
| FontPack (identifier, cpdffont, codepoints) ->
|
||||||
(*Printf.printf "FontPack op: %s\n" identifier;*)
|
(*Printf.printf "FontPack op: %s\n" identifier;*)
|
||||||
let fontpack =
|
let fontpack =
|
||||||
match Hashtbl.find fontpacks identifier with
|
match Hashtbl.find !fontpacks identifier with
|
||||||
| (fontpack, _) ->
|
| (fontpack, _) ->
|
||||||
(*Printf.printf "Cpdfdraw FontPack op: using existing fontpack %s\n" identifier;*)
|
(*Printf.printf "Cpdfdraw FontPack op: using existing fontpack %s\n" identifier;*)
|
||||||
fontpack
|
fontpack
|
||||||
|
@ -270,7 +269,7 @@ let rec ops_of_drawop dryrun pdf endpage filename bates batespad num page = func
|
||||||
| ExistingNamedFont ->
|
| ExistingNamedFont ->
|
||||||
error "-draw does not support using an existing named font"
|
error "-draw does not support using an existing named font"
|
||||||
in
|
in
|
||||||
Hashtbl.replace fontpacks identifier (fontpack, codepoints);
|
Hashtbl.replace !fontpacks identifier (fontpack, codepoints);
|
||||||
fontpack
|
fontpack
|
||||||
in
|
in
|
||||||
let ns =
|
let ns =
|
||||||
|
@ -290,7 +289,7 @@ let rec ops_of_drawop dryrun pdf endpage filename bates batespad num page = func
|
||||||
[]
|
[]
|
||||||
| Font (identifier, size) ->
|
| Font (identifier, size) ->
|
||||||
(*Printf.printf "Cpdfdraw Font op: Changing to stored font %s\n" identifier;*)
|
(*Printf.printf "Cpdfdraw Font op: Changing to stored font %s\n" identifier;*)
|
||||||
let fontpack, codepoints = Hashtbl.find fontpacks identifier in
|
let fontpack, codepoints = Hashtbl.find !fontpacks identifier in
|
||||||
(res ()).current_fontpack <- (identifier, fontpack);
|
(res ()).current_fontpack <- (identifier, fontpack);
|
||||||
if dryrun then (res ()).current_fontpack_codepoints <- codepoints;
|
if dryrun then (res ()).current_fontpack_codepoints <- codepoints;
|
||||||
(res ()).font_size <- size;
|
(res ()).font_size <- size;
|
||||||
|
@ -383,9 +382,10 @@ let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf draw
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
let r = save_whole_stack () in
|
let r = save_whole_stack () in
|
||||||
|
let saved_fontpacks = Hashtbl.copy !fontpacks in
|
||||||
ignore (ops_of_drawops true pdf endpage filename bates batespad 0 (hd pages) drawops);
|
ignore (ops_of_drawops true pdf endpage filename bates batespad 0 (hd pages) drawops);
|
||||||
restore_whole_stack r;
|
restore_whole_stack r;
|
||||||
Hashtbl.clear fontpacks;
|
fontpacks := saved_fontpacks;
|
||||||
(*Printf.printf "--------------------------\n";*)
|
(*Printf.printf "--------------------------\n";*)
|
||||||
Some (ops_of_drawops false pdf endpage filename bates batespad 0 (hd pages) drawops)
|
Some (ops_of_drawops false pdf endpage filename bates batespad 0 (hd pages) drawops)
|
||||||
end
|
end
|
||||||
|
@ -399,9 +399,10 @@ let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf draw
|
||||||
| Some x -> x
|
| Some x -> x
|
||||||
| None ->
|
| None ->
|
||||||
let r = save_whole_stack () in
|
let r = save_whole_stack () in
|
||||||
|
let saved_fontpacks = Hashtbl.copy !fontpacks in
|
||||||
ignore (ops_of_drawops true pdf endpage filename bates batespad n p drawops);
|
ignore (ops_of_drawops true pdf endpage filename bates batespad n p drawops);
|
||||||
restore_whole_stack r;
|
restore_whole_stack r;
|
||||||
Hashtbl.clear fontpacks;
|
fontpacks := saved_fontpacks;
|
||||||
ops_of_drawops false pdf endpage filename bates batespad n p drawops)
|
ops_of_drawops false pdf endpage filename bates batespad n p drawops)
|
||||||
else [])
|
else [])
|
||||||
(ilist 1 endpage)
|
(ilist 1 endpage)
|
||||||
|
@ -422,7 +423,7 @@ let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf draw
|
||||||
let draw ?(fast=false) ?(underneath=false) ~filename ~bates ~batespad fast range pdf drawops =
|
let draw ?(fast=false) ?(underneath=false) ~filename ~bates ~batespad fast range pdf drawops =
|
||||||
(*Printf.printf "%s\n" (string_of_drawops drawops); *)
|
(*Printf.printf "%s\n" (string_of_drawops drawops); *)
|
||||||
resstack := [empty_res ()];
|
resstack := [empty_res ()];
|
||||||
Hashtbl.clear fontpacks;
|
Hashtbl.clear !fontpacks;
|
||||||
(res ()).time <- Cpdfstrftime.current_time ();
|
(res ()).time <- Cpdfstrftime.current_time ();
|
||||||
let pdf = ref pdf in
|
let pdf = ref pdf in
|
||||||
let range = ref range in
|
let range = ref range in
|
||||||
|
|
Loading…
Reference in New Issue