mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-02-12 01:40:38 +01:00
Set document language with -set-language
This commit is contained in:
parent
9d3c4384e4
commit
9e3c8f4666
@ -223,6 +223,7 @@ type op =
|
|||||||
| MarkAs of string
|
| MarkAs of string
|
||||||
| ExtractStructTree
|
| ExtractStructTree
|
||||||
| ReplaceStructTree of string
|
| ReplaceStructTree of string
|
||||||
|
| SetLanguage of string
|
||||||
|
|
||||||
let string_of_op = function
|
let string_of_op = function
|
||||||
| PrintFontEncoding _ -> "PrintFontEncoding"
|
| PrintFontEncoding _ -> "PrintFontEncoding"
|
||||||
@ -369,6 +370,7 @@ let string_of_op = function
|
|||||||
| MarkAs _ -> "MarkAs"
|
| MarkAs _ -> "MarkAs"
|
||||||
| ExtractStructTree -> "ExtractStructTree"
|
| ExtractStructTree -> "ExtractStructTree"
|
||||||
| ReplaceStructTree _ -> "ReplaceStructTree"
|
| ReplaceStructTree _ -> "ReplaceStructTree"
|
||||||
|
| SetLanguage _ -> "SetLanguage"
|
||||||
|
|
||||||
(* Inputs: filename, pagespec. *)
|
(* Inputs: filename, pagespec. *)
|
||||||
type input_kind =
|
type input_kind =
|
||||||
@ -889,7 +891,7 @@ let banned banlist = function
|
|||||||
| AddPageLabels | RemovePageLabels | OutputJSON | OCGCoalesce
|
| AddPageLabels | RemovePageLabels | OutputJSON | OCGCoalesce
|
||||||
| OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _
|
| OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _
|
||||||
| TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | PrintObj _
|
| TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | PrintObj _
|
||||||
| Verify _ | MarkAs _ | ExtractStructTree | ReplaceStructTree _
|
| Verify _ | MarkAs _ | ExtractStructTree | ReplaceStructTree _ | SetLanguage _
|
||||||
-> false (* Always allowed *)
|
-> false (* Always allowed *)
|
||||||
(* Combine pages is not allowed because we would not know where to get the
|
(* Combine pages is not allowed because we would not know where to get the
|
||||||
-recrypt from -- the first or second file? *)
|
-recrypt from -- the first or second file? *)
|
||||||
@ -2453,6 +2455,9 @@ and specs =
|
|||||||
("-display-doc-title",
|
("-display-doc-title",
|
||||||
Arg.String displaydoctitle,
|
Arg.String displaydoctitle,
|
||||||
" Display document's title in the title bar");
|
" Display document's title in the title bar");
|
||||||
|
("-set-language",
|
||||||
|
Arg.String (fun s -> setop (SetLanguage s) ()),
|
||||||
|
" Set the document's language");
|
||||||
("-pages",
|
("-pages",
|
||||||
Arg.Unit (setop CountPages),
|
Arg.Unit (setop CountPages),
|
||||||
" Count pages");
|
" Count pages");
|
||||||
@ -4478,6 +4483,10 @@ let go () =
|
|||||||
let json = Cpdfyojson.Safe.from_file s in
|
let json = Cpdfyojson.Safe.from_file s in
|
||||||
Cpdfua.replace_struct_tree pdf json;
|
Cpdfua.replace_struct_tree pdf json;
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
|
| Some (SetLanguage s) ->
|
||||||
|
let pdf = get_single_pdf args.op false in
|
||||||
|
Cpdfmetadata.set_language pdf s;
|
||||||
|
write_pdf false pdf
|
||||||
|
|
||||||
(* Advise the user if a combination of command line flags makes little sense,
|
(* Advise the user if a combination of command line flags makes little sense,
|
||||||
or error out if it make no sense at all. *)
|
or error out if it make no sense at all. *)
|
||||||
|
@ -447,6 +447,9 @@ let language pdf =
|
|||||||
| Some (Pdf.String x) -> Some x
|
| Some (Pdf.String x) -> Some x
|
||||||
| _ -> None
|
| _ -> None
|
||||||
|
|
||||||
|
let set_language pdf s =
|
||||||
|
Pdf.replace_chain pdf [] "/Lang" (Pdf.String s)
|
||||||
|
|
||||||
let output_xmp_info ?(json=ref [("none", `Null)]) encoding pdf =
|
let output_xmp_info ?(json=ref [("none", `Null)]) encoding pdf =
|
||||||
let notjson = !json = [("none", `Null)] in
|
let notjson = !json = [("none", `Null)] in
|
||||||
let print_out tree title namespace name =
|
let print_out tree title namespace name =
|
||||||
|
@ -89,6 +89,8 @@ val determine_subformats : Pdf.t -> string list
|
|||||||
|
|
||||||
val language : Pdf.t -> string option
|
val language : Pdf.t -> string option
|
||||||
|
|
||||||
|
val set_language : Pdf.t -> string -> unit
|
||||||
|
|
||||||
val adobe : string
|
val adobe : string
|
||||||
val xmp : string
|
val xmp : string
|
||||||
val dc : string
|
val dc : string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user