mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2024-12-12 08:46:39 +01:00
Scaffolding for -output-[jpeg|png]
This commit is contained in:
parent
273aeb8ea7
commit
68fe5bd5f7
2
Changes
2
Changes
@ -5,7 +5,7 @@ New features:
|
|||||||
o New -center-to-fit centres pages on a given paper size
|
o New -center-to-fit centres pages on a given paper size
|
||||||
o New -jpeg-to-jpeg-scale and -jpeg-to-jpeg-dpi
|
o New -jpeg-to-jpeg-scale and -jpeg-to-jpeg-dpi
|
||||||
o Rasterize PDFs by calling out to GhostScript
|
o Rasterize PDFs by calling out to GhostScript
|
||||||
o Convert to PNG/JPEG by calling out to GhostScript
|
o Extract pages as PNG/JPEG by calling out to GhostScript
|
||||||
|
|
||||||
Extended features:
|
Extended features:
|
||||||
|
|
||||||
|
@ -231,6 +231,7 @@ type op =
|
|||||||
| SetLanguage of string
|
| SetLanguage of string
|
||||||
| Redact
|
| Redact
|
||||||
| Rasterize
|
| Rasterize
|
||||||
|
| OutputImage of string
|
||||||
|
|
||||||
let string_of_op = function
|
let string_of_op = function
|
||||||
| PrintFontEncoding _ -> "PrintFontEncoding"
|
| PrintFontEncoding _ -> "PrintFontEncoding"
|
||||||
@ -385,6 +386,7 @@ let string_of_op = function
|
|||||||
| SetLanguage _ -> "SetLanguage"
|
| SetLanguage _ -> "SetLanguage"
|
||||||
| Redact -> "Redact"
|
| Redact -> "Redact"
|
||||||
| Rasterize -> "Rasterize"
|
| Rasterize -> "Rasterize"
|
||||||
|
| OutputImage _ -> "OutputImage"
|
||||||
|
|
||||||
(* Inputs: filename, pagespec. *)
|
(* Inputs: filename, pagespec. *)
|
||||||
type input_kind =
|
type input_kind =
|
||||||
@ -940,7 +942,7 @@ let banned banlist = function
|
|||||||
| OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _
|
| OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _
|
||||||
| TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | PrintObj _ | ReplaceObj _
|
| TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | PrintObj _ | ReplaceObj _
|
||||||
| Verify _ | MarkAs _ | RemoveMark _ | ExtractStructTree | ReplaceStructTree _ | SetLanguage _
|
| Verify _ | MarkAs _ | RemoveMark _ | ExtractStructTree | ReplaceStructTree _ | SetLanguage _
|
||||||
| PrintStructTree | Rasterize
|
| PrintStructTree | Rasterize | OutputImage _
|
||||||
-> 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? *)
|
||||||
@ -3010,6 +3012,8 @@ let specs =
|
|||||||
("-rasterize-res", Arg.Float (fun f -> args.rast_res <- f), " Rastierization resolution");
|
("-rasterize-res", Arg.Float (fun f -> args.rast_res <- f), " Rastierization resolution");
|
||||||
("-rasterize-annots", Arg.Unit (fun () -> args.rast_annots <- true), " Rasterize annotations");
|
("-rasterize-annots", Arg.Unit (fun () -> args.rast_annots <- true), " Rasterize annotations");
|
||||||
("-rasterize-no-antialias", Arg.Unit (fun () -> args.rast_antialias <- false), " Don't antialias when rasterizing");
|
("-rasterize-no-antialias", Arg.Unit (fun () -> args.rast_antialias <- false), " Don't antialias when rasterizing");
|
||||||
|
("-output-jpeg", Arg.String (fun s -> args.op <- Some (OutputImage s)), " Output pages as JPEGs");
|
||||||
|
("-output-png", Arg.String (fun s -> args.op <- Some (OutputImage s)), " Output pages as PNGs");
|
||||||
(* These items are undocumented *)
|
(* These items are undocumented *)
|
||||||
("-debug", Arg.Unit setdebug, "");
|
("-debug", Arg.Unit setdebug, "");
|
||||||
("-debug-crypt", Arg.Unit (fun () -> args.debugcrypt <- true), "");
|
("-debug-crypt", Arg.Unit (fun () -> args.debugcrypt <- true), "");
|
||||||
@ -3729,6 +3733,9 @@ let rasterize antialias device res annots pdf range =
|
|||||||
Sys.remove tmppdf;
|
Sys.remove tmppdf;
|
||||||
pdf
|
pdf
|
||||||
|
|
||||||
|
let write_images spec pdf range =
|
||||||
|
()
|
||||||
|
|
||||||
(* Main function *)
|
(* Main function *)
|
||||||
let go () =
|
let go () =
|
||||||
check_bookmarks_mistake ();
|
check_bookmarks_mistake ();
|
||||||
@ -4836,6 +4843,10 @@ let go () =
|
|||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||||
write_pdf false (rasterize args.rast_antialias args.rast_device args.rast_res args.rast_annots pdf range)
|
write_pdf false (rasterize args.rast_antialias args.rast_device args.rast_res args.rast_annots pdf range)
|
||||||
|
| Some (OutputImage spec) ->
|
||||||
|
let pdf = get_single_pdf args.op false in
|
||||||
|
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||||
|
write_images spec pdf range
|
||||||
|
|
||||||
(* 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. *)
|
||||||
|
Loading…
Reference in New Issue
Block a user