mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-06-05 22:09:39 +02:00
Fix -add-rectangle when PMAXX ect.
This commit is contained in:
1
Changes
1
Changes
@ -13,6 +13,7 @@ o New -decompress-just-content for easier content stream debugging
|
||||
Fixes:
|
||||
|
||||
* Sanitizes inputs to prevent command injection attacks
|
||||
o Fix PMAXX et al. w.r.t -add-rectangle
|
||||
|
||||
* = Supported by a grant from NLnet
|
||||
|
||||
|
@ -579,7 +579,7 @@ let
|
||||
!pdf
|
||||
|
||||
let addrectangle
|
||||
fast (w, h) colour outline linewidth opacity position relative_to_cropbox
|
||||
fast coord colour outline linewidth opacity position relative_to_cropbox
|
||||
underneath range pdf
|
||||
=
|
||||
let addrectangle_page _ page =
|
||||
@ -607,6 +607,11 @@ let addrectangle
|
||||
else
|
||||
Pdf.parse_rectangle pdf page.Pdfpage.mediabox
|
||||
in
|
||||
let w, h =
|
||||
match Cpdfcoord.parse_units_string pdf page coord with
|
||||
| [w; h] -> w, h
|
||||
| _ -> error "bad coordinate specification"
|
||||
in
|
||||
let x, y, _ =
|
||||
Cpdfposition.calculate_position false w mediabox position
|
||||
in
|
||||
|
@ -48,10 +48,10 @@ val addtexts :
|
||||
Pdf.t ->(*pdf*)
|
||||
Pdf.t
|
||||
|
||||
(** Add a rectangle to the given pages. [addrectangle fast (w, h) colour outline linewidth opacity position relative_to_cropbox underneath range pdf]. *)
|
||||
(** Add a rectangle to the given pages. [addrectangle fast coordinate colour outline linewidth opacity position relative_to_cropbox underneath range pdf]. *)
|
||||
val addrectangle :
|
||||
bool ->
|
||||
float * float ->
|
||||
string ->
|
||||
colour ->
|
||||
bool ->
|
||||
float ->
|
||||
|
@ -4590,7 +4590,7 @@ let go () =
|
||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
write_pdf false
|
||||
(Cpdfaddtext.addrectangle
|
||||
args.fast (Cpdfcoord.parse_coordinate pdf args.coord)
|
||||
args.fast args.coord
|
||||
args.color args.outline args.linewidth args.opacity args.position
|
||||
args.relative_to_cropbox args.underneath range pdf)
|
||||
| Some (AddBookmarks file) ->
|
||||
|
@ -14,5 +14,7 @@ val parse_coordinate : Pdf.t -> string -> float * float
|
||||
(** Read a list of coordinates from a string *)
|
||||
val parse_coordinates : Pdf.t -> string -> (float * float) list
|
||||
|
||||
val parse_units_string : Pdf.t -> Pdfpage.t -> string -> float list
|
||||
|
||||
(** Read a single number from a string *)
|
||||
val parse_single_number : Pdf.t -> string -> float
|
||||
|
@ -188,7 +188,7 @@ let add_border linewidth ~fast pdf =
|
||||
let firstpage = hd (Pdfpage.pages_of_pagetree pdf) in
|
||||
let _, _, w, h = Pdf.parse_rectangle pdf firstpage.Pdfpage.mediabox in
|
||||
Cpdfaddtext.addrectangle
|
||||
fast (w -. linewidth, h -. linewidth) (RGB (0., 0., 0.)) true linewidth 1. (Cpdfposition.BottomLeft (linewidth /. 2., linewidth /. 2.))
|
||||
fast (string_of_float (w -. linewidth) ^ " " ^ string_of_float (h -. linewidth)) (RGB (0., 0., 0.)) true linewidth 1. (Cpdfposition.BottomLeft (linewidth /. 2., linewidth /. 2.))
|
||||
false false (ilist 1 (Pdfpage.endpage pdf)) pdf
|
||||
|
||||
let impose ~process_struct_tree ~x ~y ~fit ~columns ~rtl ~btt ~center ~margin ~spacing ~linewidth ~fast pdf =
|
||||
|
Reference in New Issue
Block a user