First working -jbig2

This commit is contained in:
John Whitington 2023-12-04 13:39:56 +00:00
parent 9ad38424f7
commit 0d97d39c02
3 changed files with 21 additions and 1 deletions

View File

@ -1789,6 +1789,7 @@ let set_input_image f s =
let set_input_png = set_input_image Cpdfimage.obj_of_png_data
let set_input_jpeg = set_input_image Cpdfimage.obj_of_jpeg_data
let set_input_jbig2 = set_input_image (Cpdfimage.obj_of_jbig2_data ~global:1)
let embed_font_inner font =
match font with
@ -1915,6 +1916,9 @@ and specs =
("-jpeg",
Arg.String set_input_jpeg,
" Load from a JPEG file, converting to PDF");
("-jbig2",
Arg.String set_input_jbig2,
" Load from a JBIG2 fragment, converting to PDF");
("-idir",
Arg.String set_input_dir,
" Add a directory of files");

View File

@ -405,7 +405,22 @@ let obj_of_png_data data =
"/Width", Pdf.Integer png.width;
"/Height", Pdf.Integer png.height]
in
Pdf.Stream {contents = (Pdf.Dictionary d , Pdf.Got png.idat)}
Pdf.Stream {contents = (Pdf.Dictionary d, Pdf.Got png.idat)}
let obj_of_jbig2_data ?global:int data =
let d =
let w = 800 in
let h = 1200 in
[("/Length", Pdf.Integer (Pdfio.bytes_size data));
("/Filter", Pdf.Name "/JBIG2Decode");
("/Subtype", Pdf.Name "/Image");
("/BitsPerComponent", Pdf.Integer 1);
("/ColorSpace", Pdf.Name "/DeviceGray");
(* FIXME decodeparms for global *)
("/Width", Pdf.Integer w);
("/Height", Pdf.Integer h)]
in
Pdf.Stream {contents = (Pdf.Dictionary d, Pdf.Got data)}
let image_of_input fobj i =
let pdf = Pdf.empty () in

View File

@ -15,3 +15,4 @@ val images : Pdf.t -> int list -> Cpdfyojson.Safe.t
val image_of_input : (Pdfio.bytes -> Pdf.pdfobject) -> Pdfio.input -> Pdf.t
val obj_of_jpeg_data : Pdfio.bytes -> Pdf.pdfobject
val obj_of_png_data : Pdfio.bytes -> Pdf.pdfobject
val obj_of_jbig2_data : ?global:int -> Pdfio.bytes -> Pdf.pdfobject