more
This commit is contained in:
parent
67a66a8226
commit
01ff49808c
|
@ -20,4 +20,4 @@ val remove_annotations : int list -> Pdf.t -> Pdf.t
|
||||||
val get_annotations_json : Pdf.t -> Pdfio.bytes
|
val get_annotations_json : Pdf.t -> Pdfio.bytes
|
||||||
|
|
||||||
(** Set annotations from JSON. Existing annotations will be removed. *)
|
(** Set annotations from JSON. Existing annotations will be removed. *)
|
||||||
val set_annotations_json : Pdf.t -> Pdfio.bytes -> unit
|
val set_annotations_json : Pdf.t -> Pdfio.input -> unit
|
||||||
|
|
|
@ -125,6 +125,7 @@ type op =
|
||||||
| RemoveAnnotations
|
| RemoveAnnotations
|
||||||
| ListAnnotations
|
| ListAnnotations
|
||||||
| CopyAnnotations of string
|
| CopyAnnotations of string
|
||||||
|
| SetAnnotations of string
|
||||||
| Merge
|
| Merge
|
||||||
| Split
|
| Split
|
||||||
| SplitOnBookmarks of int
|
| SplitOnBookmarks of int
|
||||||
|
@ -258,6 +259,7 @@ let string_of_op = function
|
||||||
| RemoveAnnotations -> "RemoveAnnotations"
|
| RemoveAnnotations -> "RemoveAnnotations"
|
||||||
| ListAnnotations -> "ListAnnotations"
|
| ListAnnotations -> "ListAnnotations"
|
||||||
| CopyAnnotations _ -> "CopyAnnotations"
|
| CopyAnnotations _ -> "CopyAnnotations"
|
||||||
|
| SetAnnotations _ -> "SetAnnotations"
|
||||||
| Merge -> "Merge"
|
| Merge -> "Merge"
|
||||||
| Split -> "Split"
|
| Split -> "Split"
|
||||||
| SplitOnBookmarks _ -> "SplitOnBookmarks"
|
| SplitOnBookmarks _ -> "SplitOnBookmarks"
|
||||||
|
@ -841,7 +843,7 @@ let banned banlist = function
|
||||||
| TwoUp|TwoUpStack|RemoveBookmarks|AddRectangle|RemoveText|
|
| TwoUp|TwoUpStack|RemoveBookmarks|AddRectangle|RemoveText|
|
||||||
Draft|Shift|Scale|ScaleToFit|RemoveAttachedFiles|
|
Draft|Shift|Scale|ScaleToFit|RemoveAttachedFiles|
|
||||||
RemoveAnnotations|RemoveFonts|Crop|RemoveCrop|Trim|RemoveTrim|Bleed|RemoveBleed|Art|RemoveArt|
|
RemoveAnnotations|RemoveFonts|Crop|RemoveCrop|Trim|RemoveTrim|Bleed|RemoveBleed|Art|RemoveArt|
|
||||||
CopyCropBoxToMediaBox|CopyBox|MediaBox|HardBox _|SetTrapped|SetUntrapped|Presentation|
|
CopyCropBoxToMediaBox|CopyBox|MediaBox|HardBox _|SetTrapped|SetAnnotations _|SetUntrapped|Presentation|
|
||||||
BlackText|BlackLines|BlackFills|CopyFont _|StampOn _|StampUnder _|StampAsXObject _|
|
BlackText|BlackLines|BlackFills|CopyFont _|StampOn _|StampUnder _|StampAsXObject _|
|
||||||
AddText _|ScaleContents _|AttachFile _|CopyAnnotations _| ThinLines _ | RemoveClipping | RemoveAllText
|
AddText _|ScaleContents _|AttachFile _|CopyAnnotations _| ThinLines _ | RemoveClipping | RemoveAllText
|
||||||
| Prepend _ | Postpend _ | Draw ->
|
| Prepend _ | Postpend _ | Draw ->
|
||||||
|
@ -1085,6 +1087,8 @@ let setthinlines s = setop (ThinLines (Cpdfcoord.parse_single_number empty s)) (
|
||||||
|
|
||||||
let setcopyannotations s = setop (CopyAnnotations s) ()
|
let setcopyannotations s = setop (CopyAnnotations s) ()
|
||||||
|
|
||||||
|
let setsetannotations s = setop (SetAnnotations s) ()
|
||||||
|
|
||||||
let setshift s =
|
let setshift s =
|
||||||
setop Shift ();
|
setop Shift ();
|
||||||
args.coord <- s
|
args.coord <- s
|
||||||
|
@ -2479,6 +2483,9 @@ and specs =
|
||||||
("-remove-annotations",
|
("-remove-annotations",
|
||||||
Arg.Unit (setop RemoveAnnotations),
|
Arg.Unit (setop RemoveAnnotations),
|
||||||
" Remove annotations");
|
" Remove annotations");
|
||||||
|
("-set-annotations",
|
||||||
|
Arg.String setsetannotations,
|
||||||
|
" Set annotations from JSON file");
|
||||||
("-list-fonts",
|
("-list-fonts",
|
||||||
Arg.Unit (setop Fonts),
|
Arg.Unit (setop Fonts),
|
||||||
" Output font list");
|
" Output font list");
|
||||||
|
@ -3965,6 +3972,11 @@ let go () =
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
| _ -> error "copy-annotations: No input file specified"
|
| _ -> error "copy-annotations: No input file specified"
|
||||||
end
|
end
|
||||||
|
| Some (SetAnnotations json) ->
|
||||||
|
let data = Pdfio.input_of_channel (open_in_bin json) in
|
||||||
|
let pdf = get_single_pdf args.op false in
|
||||||
|
Cpdfannot.set_annotations_json pdf data;
|
||||||
|
write_pdf false pdf
|
||||||
| Some ListAnnotations ->
|
| Some ListAnnotations ->
|
||||||
let pdf = get_single_pdf args.op true in
|
let pdf = get_single_pdf args.op true in
|
||||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||||
|
|
Loading…
Reference in New Issue