subformats
This commit is contained in:
parent
f331d670df
commit
94d119196d
4
Makefile
4
Makefile
|
@ -7,8 +7,8 @@ DOC = cpdfunicodedata cpdferror cpdfdebug cpdfjson cpdfstrftime cpdfcoord \
|
||||||
cpdfembed cpdffont cpdftype cpdfaddtext cpdfpad cpdfocg \
|
cpdfembed cpdffont cpdftype cpdfaddtext cpdfpad cpdfocg \
|
||||||
cpdfsqueeze cpdfdraft cpdfspot cpdfpagelabels cpdfcreate cpdfannot \
|
cpdfsqueeze cpdfdraft cpdfspot cpdfpagelabels cpdfcreate cpdfannot \
|
||||||
cpdfxobject cpdfimpose cpdfchop cpdftweak cpdftexttopdf cpdftoc \
|
cpdfxobject cpdfimpose cpdfchop cpdftweak cpdftexttopdf cpdftoc \
|
||||||
cpdfjpeg cpdfjpeg2000 cpdfpng cpdfimage cpdfdraw cpdfcomposition \
|
cpdfjpeg cpdfjpeg2000 cpdfpng cpdfprinttree cpdfua cpdfimage cpdfdraw \
|
||||||
cpdfshape cpdfcolours cpdfdrawcontrol cpdfprinttree cpdfua \
|
cpdfcomposition cpdfshape cpdfcolours cpdfdrawcontrol \
|
||||||
cpdfcommand
|
cpdfcommand
|
||||||
|
|
||||||
MODS = $(NONDOC) $(DOC)
|
MODS = $(NONDOC) $(DOC)
|
||||||
|
|
|
@ -1025,7 +1025,7 @@ let fixdashes s =
|
||||||
let set_input_image f s =
|
let set_input_image f s =
|
||||||
try
|
try
|
||||||
let fh = open_in_bin s in
|
let fh = open_in_bin s in
|
||||||
let pdf = Cpdfimage.image_of_input ~subformat:args.subformat ~title:args.title f (Pdfio.input_of_channel fh) in
|
let pdf = Cpdfimage.image_of_input ?subformat:args.subformat ?title:args.title f (Pdfio.input_of_channel fh) in
|
||||||
begin try close_in fh with _ -> () end;
|
begin try close_in fh with _ -> () end;
|
||||||
args.original_filename <- s;
|
args.original_filename <- s;
|
||||||
args.create_objstm <- true;
|
args.create_objstm <- true;
|
||||||
|
@ -4476,11 +4476,11 @@ let go () =
|
||||||
begin match args.subformat with
|
begin match args.subformat with
|
||||||
| Some Cpdfua.PDFUA1 ->
|
| Some Cpdfua.PDFUA1 ->
|
||||||
begin match args.title with None -> error "Provide -title" | _ -> () end;
|
begin match args.title with None -> error "Provide -title" | _ -> () end;
|
||||||
let pdf = Cpdfua.create_cpdfua1 (unopt args.title) args.createpdf_pagesize args.createpdf_pages in
|
let pdf = Cpdfua.create_pdfua1 (unopt args.title) args.createpdf_pagesize args.createpdf_pages in
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
| Some Cpdfua.PDFUA2 ->
|
| Some Cpdfua.PDFUA2 ->
|
||||||
begin match args.title with None -> error "Provide -title" | _ -> () end;
|
begin match args.title with None -> error "Provide -title" | _ -> () end;
|
||||||
let pdf = Cpdfua.create_cpdfua2 (unopt args.title) args.createpdf_pagesize args.createpdf_pages in
|
let pdf = Cpdfua.create_pdfua2 (unopt args.title) args.createpdf_pagesize args.createpdf_pages in
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
| None ->
|
| None ->
|
||||||
let pdf = Cpdfcreate.blank_document_paper args.createpdf_pagesize args.createpdf_pages in
|
let pdf = Cpdfcreate.blank_document_paper args.createpdf_pagesize args.createpdf_pages in
|
||||||
|
|
15
cpdfimage.ml
15
cpdfimage.ml
|
@ -494,7 +494,20 @@ let obj_of_jbig2_data ?global data =
|
||||||
Pdf.Stream {contents = (Pdf.Dictionary d, Pdf.Got data)}, extra
|
Pdf.Stream {contents = (Pdf.Dictionary d, Pdf.Got data)}, extra
|
||||||
|
|
||||||
let image_of_input ?subformat ?title fobj i =
|
let image_of_input ?subformat ?title fobj i =
|
||||||
let pdf = Pdf.empty () in
|
let pdf =
|
||||||
|
match subformat with
|
||||||
|
| None -> Pdf.empty ()
|
||||||
|
| Some Cpdfua.PDFUA1 ->
|
||||||
|
begin match title with
|
||||||
|
| None -> error "no -title given"
|
||||||
|
| Some title -> Cpdfua.create_pdfua1 title Pdfpaper.a4 1
|
||||||
|
end
|
||||||
|
| Some Cpdfua.PDFUA2 ->
|
||||||
|
begin match title with
|
||||||
|
| None -> error "no -title given"
|
||||||
|
| Some title -> Cpdfua.create_pdfua2 title Pdfpaper.a4 1
|
||||||
|
end
|
||||||
|
in
|
||||||
let data = Pdfio.bytes_of_input i 0 i.Pdfio.in_channel_length in
|
let data = Pdfio.bytes_of_input i 0 i.Pdfio.in_channel_length in
|
||||||
let obj, extras = fobj () data in
|
let obj, extras = fobj () data in
|
||||||
iter (Pdf.addobj_given_num pdf) extras;
|
iter (Pdf.addobj_given_num pdf) extras;
|
||||||
|
|
|
@ -25,7 +25,7 @@ val process :
|
||||||
path_to_jbig2enc:string -> path_to_convert:string -> int list -> Pdf.t -> unit
|
path_to_jbig2enc:string -> path_to_convert:string -> int list -> Pdf.t -> unit
|
||||||
|
|
||||||
(**/**)
|
(**/**)
|
||||||
val image_of_input : ?subformat:Cpdfua.subformat option -> ?title:string option -> (unit -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list) -> Pdfio.input -> Pdf.t
|
val image_of_input : ?subformat:Cpdfua.subformat -> ?title:string -> (unit -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list) -> Pdfio.input -> Pdf.t
|
||||||
val obj_of_jpeg_data : Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list
|
val obj_of_jpeg_data : Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list
|
||||||
val obj_of_png_data : Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list
|
val obj_of_png_data : Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list
|
||||||
val obj_of_jbig2_data : ?global:Pdfio.bytes -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list
|
val obj_of_jbig2_data : ?global:Pdfio.bytes -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list
|
||||||
|
|
|
@ -1604,7 +1604,7 @@ let print_struct_tree pdf =
|
||||||
~get_children:(fun (E2 (_, _, cs)) -> cs)
|
~get_children:(fun (E2 (_, _, cs)) -> cs)
|
||||||
(remove_empty (remove_slashes st)))
|
(remove_empty (remove_slashes st)))
|
||||||
|
|
||||||
let create_cpdfua1 title pagesize pages =
|
let create_pdfua1 title pagesize pages =
|
||||||
let pdf = Cpdfcreate.blank_document_paper pagesize pages in
|
let pdf = Cpdfcreate.blank_document_paper pagesize pages in
|
||||||
let pdf = Cpdfmetadata.set_pdf_info ~xmp_also:false ~xmp_just_set:false ("/Title", Pdf.String title, 0) pdf in
|
let pdf = Cpdfmetadata.set_pdf_info ~xmp_also:false ~xmp_just_set:false ("/Title", Pdf.String title, 0) pdf in
|
||||||
let pdf = Cpdfmetadata.create_metadata pdf in
|
let pdf = Cpdfmetadata.create_metadata pdf in
|
||||||
|
@ -1616,7 +1616,7 @@ let create_cpdfua1 title pagesize pages =
|
||||||
mark pdf;
|
mark pdf;
|
||||||
pdf
|
pdf
|
||||||
|
|
||||||
let create_cpdfua2 title pagesize pages =
|
let create_pdfua2 title pagesize pages =
|
||||||
let pdf = Cpdfcreate.blank_document_paper pagesize pages in
|
let pdf = Cpdfcreate.blank_document_paper pagesize pages in
|
||||||
let pdf = Cpdfmetadata.set_pdf_info ~xmp_also:false ~xmp_just_set:false ("/Title", Pdf.String title, 0) pdf in
|
let pdf = Cpdfmetadata.set_pdf_info ~xmp_also:false ~xmp_just_set:false ("/Title", Pdf.String title, 0) pdf in
|
||||||
let pdf = Cpdfmetadata.create_metadata pdf in
|
let pdf = Cpdfmetadata.create_metadata pdf in
|
||||||
|
|
|
@ -30,6 +30,6 @@ val extract_struct_tree : Pdf.t -> Cpdfyojson.Safe.t
|
||||||
(** Reapply an edited JSON structure tree to its PDF. *)
|
(** Reapply an edited JSON structure tree to its PDF. *)
|
||||||
val replace_struct_tree : Pdf.t -> Cpdfyojson.Safe.t -> unit
|
val replace_struct_tree : Pdf.t -> Cpdfyojson.Safe.t -> unit
|
||||||
|
|
||||||
val create_cpdfua1 : string -> Pdfpaper.t -> int -> Pdf.t
|
val create_pdfua1 : string -> Pdfpaper.t -> int -> Pdf.t
|
||||||
|
|
||||||
val create_cpdfua2 : string -> Pdfpaper.t -> int -> Pdf.t
|
val create_pdfua2 : string -> Pdfpaper.t -> int -> Pdf.t
|
||||||
|
|
Loading…
Reference in New Issue