mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-04-09 16:11:34 +02:00
more
This commit is contained in:
parent
ca267b3de4
commit
265b4c71d0
3
Makefile
3
Makefile
@ -1,7 +1,8 @@
|
|||||||
# Build the cpdf command line tools and top level
|
# Build the cpdf command line tools and top level
|
||||||
MODS = cpdfyojson cpdfxmlm \
|
MODS = cpdfyojson cpdfxmlm \
|
||||||
cpdfunicodedata cpdferror cpdfjson cpdfstrftime cpdfcoord cpdfattach \
|
cpdfunicodedata cpdferror cpdfjson cpdfstrftime cpdfcoord cpdfattach \
|
||||||
cpdfpagespec cpdfposition cpdf cpdffont cpdftype cpdftexttopdf cpdftoc cpdfcommand
|
cpdfpagespec cpdfposition cpdf cpdfpresent cpdffont cpdftype \
|
||||||
|
cpdftexttopdf cpdftoc cpdfcommand
|
||||||
|
|
||||||
SOURCES = $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml
|
SOURCES = $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml
|
||||||
|
|
||||||
|
57
cpdf.ml
57
cpdf.ml
@ -489,63 +489,6 @@ let combine_pdf_resources pdf a b =
|
|||||||
(Pdf.Dictionary [])
|
(Pdf.Dictionary [])
|
||||||
(unknown_keys_a @ unknown_keys_b @ combined_known_entries)
|
(unknown_keys_a @ unknown_keys_b @ combined_known_entries)
|
||||||
|
|
||||||
(* \section{Build PDF Presentations} *)
|
|
||||||
let change_page_effect t d horizontal inward direction effect_duration page =
|
|
||||||
let checkname = function
|
|
||||||
| "Split" | "Blinds" | "Box" | "Wipe" | "Dissolve" | "Glitter" -> ()
|
|
||||||
| _ -> error "Unknown presentation type"
|
|
||||||
in
|
|
||||||
let rest = page.Pdfpage.rest in
|
|
||||||
let transdict =
|
|
||||||
match t with
|
|
||||||
| None ->
|
|
||||||
Pdf.Dictionary []
|
|
||||||
| Some name ->
|
|
||||||
checkname name;
|
|
||||||
Pdf.Dictionary [("/S", Pdf.Name ("/" ^ name))]
|
|
||||||
in
|
|
||||||
let transdict = Pdf.add_dict_entry transdict "/D" (Pdf.Real effect_duration) in
|
|
||||||
let transdict =
|
|
||||||
match t with
|
|
||||||
| Some ("Split" | "Blinds") ->
|
|
||||||
Pdf.add_dict_entry
|
|
||||||
transdict "/Dm" (Pdf.Name (if horizontal then "/H" else "/V"))
|
|
||||||
| _ -> transdict
|
|
||||||
in
|
|
||||||
let transdict =
|
|
||||||
match t with
|
|
||||||
| Some ("Split" | "Box") ->
|
|
||||||
Pdf.add_dict_entry
|
|
||||||
transdict "/M" (Pdf.Name (if inward then "/I" else "/O"))
|
|
||||||
| _ -> transdict
|
|
||||||
in
|
|
||||||
let transdict =
|
|
||||||
match t with
|
|
||||||
| Some ("Wipe" | "Glitter") ->
|
|
||||||
Pdf.add_dict_entry transdict "/Di" (Pdf.Integer direction)
|
|
||||||
| _ -> transdict
|
|
||||||
in
|
|
||||||
let rest = Pdf.add_dict_entry rest "/Trans" transdict in
|
|
||||||
let rest =
|
|
||||||
match d with
|
|
||||||
| None -> Pdf.remove_dict_entry rest "/Dur"
|
|
||||||
| Some delay -> Pdf.add_dict_entry rest "/Dur" (Pdf.Real delay)
|
|
||||||
in
|
|
||||||
{page with Pdfpage.rest = rest}
|
|
||||||
|
|
||||||
let presentation range t d h i dir effect_dur pdf =
|
|
||||||
let pages = Pdfpage.pages_of_pagetree pdf in
|
|
||||||
let pages' =
|
|
||||||
map2
|
|
||||||
(fun page num ->
|
|
||||||
if mem num range
|
|
||||||
then change_page_effect t d h i dir effect_dur page
|
|
||||||
else page)
|
|
||||||
pages
|
|
||||||
(indx pages)
|
|
||||||
in
|
|
||||||
Pdfpage.change_pages true pdf pages'
|
|
||||||
|
|
||||||
(* \section{Copy an /ID from one file to another} *)
|
(* \section{Copy an /ID from one file to another} *)
|
||||||
let copy_id keepversion copyfrom copyto =
|
let copy_id keepversion copyfrom copyto =
|
||||||
match Pdf.lookup_direct copyfrom "/ID" copyfrom.Pdf.trailerdict with
|
match Pdf.lookup_direct copyfrom "/ID" copyfrom.Pdf.trailerdict with
|
||||||
|
8
cpdf.mli
8
cpdf.mli
@ -85,14 +85,6 @@ val output_info : encoding -> Pdf.t -> unit
|
|||||||
(** Output to standard output information from any XMP metadata stream in a PDF. *)
|
(** Output to standard output information from any XMP metadata stream in a PDF. *)
|
||||||
val output_xmp_info : encoding -> Pdf.t -> unit
|
val output_xmp_info : encoding -> Pdf.t -> unit
|
||||||
|
|
||||||
(** {2 Presentations} *)
|
|
||||||
|
|
||||||
(** [presentation range t d horizontal inward direction effect_duration pdf]
|
|
||||||
adds a presentation on the pages in [range]. See cpdfmanual.pdf for details.
|
|
||||||
*)
|
|
||||||
val presentation : int list -> string option ->
|
|
||||||
float option -> bool -> bool -> int -> float -> Pdf.t -> Pdf.t
|
|
||||||
|
|
||||||
(** {2 Bookmarks} *)
|
(** {2 Bookmarks} *)
|
||||||
|
|
||||||
(** [parse_bookmark_file verify pdf input] parses the bookmark file in [input].
|
(** [parse_bookmark_file verify pdf input] parses the bookmark file in [input].
|
||||||
|
@ -3441,7 +3441,7 @@ 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
|
||||||
let pdf' =
|
let pdf' =
|
||||||
Cpdf.presentation
|
Cpdfpresent.presentation
|
||||||
range
|
range
|
||||||
args.transition args.duration args.horizontal
|
args.transition args.duration args.horizontal
|
||||||
args.inward args.direction args.effect_duration pdf
|
args.inward args.direction args.effect_duration pdf
|
||||||
|
59
cpdfpresent.ml
Normal file
59
cpdfpresent.ml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
(* Build PDF Presentations *)
|
||||||
|
open Pdfutil
|
||||||
|
|
||||||
|
let change_page_effect t d horizontal inward direction effect_duration page =
|
||||||
|
let checkname = function
|
||||||
|
| "Split" | "Blinds" | "Box" | "Wipe" | "Dissolve" | "Glitter" -> ()
|
||||||
|
| _ -> Cpdferror.error "Unknown presentation type"
|
||||||
|
in
|
||||||
|
let rest = page.Pdfpage.rest in
|
||||||
|
let transdict =
|
||||||
|
match t with
|
||||||
|
| None ->
|
||||||
|
Pdf.Dictionary []
|
||||||
|
| Some name ->
|
||||||
|
checkname name;
|
||||||
|
Pdf.Dictionary [("/S", Pdf.Name ("/" ^ name))]
|
||||||
|
in
|
||||||
|
let transdict = Pdf.add_dict_entry transdict "/D" (Pdf.Real effect_duration) in
|
||||||
|
let transdict =
|
||||||
|
match t with
|
||||||
|
| Some ("Split" | "Blinds") ->
|
||||||
|
Pdf.add_dict_entry
|
||||||
|
transdict "/Dm" (Pdf.Name (if horizontal then "/H" else "/V"))
|
||||||
|
| _ -> transdict
|
||||||
|
in
|
||||||
|
let transdict =
|
||||||
|
match t with
|
||||||
|
| Some ("Split" | "Box") ->
|
||||||
|
Pdf.add_dict_entry
|
||||||
|
transdict "/M" (Pdf.Name (if inward then "/I" else "/O"))
|
||||||
|
| _ -> transdict
|
||||||
|
in
|
||||||
|
let transdict =
|
||||||
|
match t with
|
||||||
|
| Some ("Wipe" | "Glitter") ->
|
||||||
|
Pdf.add_dict_entry transdict "/Di" (Pdf.Integer direction)
|
||||||
|
| _ -> transdict
|
||||||
|
in
|
||||||
|
let rest = Pdf.add_dict_entry rest "/Trans" transdict in
|
||||||
|
let rest =
|
||||||
|
match d with
|
||||||
|
| None -> Pdf.remove_dict_entry rest "/Dur"
|
||||||
|
| Some delay -> Pdf.add_dict_entry rest "/Dur" (Pdf.Real delay)
|
||||||
|
in
|
||||||
|
{page with Pdfpage.rest = rest}
|
||||||
|
|
||||||
|
let presentation range t d h i dir effect_dur pdf =
|
||||||
|
let pages = Pdfpage.pages_of_pagetree pdf in
|
||||||
|
let pages' =
|
||||||
|
map2
|
||||||
|
(fun page num ->
|
||||||
|
if mem num range
|
||||||
|
then change_page_effect t d h i dir effect_dur page
|
||||||
|
else page)
|
||||||
|
pages
|
||||||
|
(indx pages)
|
||||||
|
in
|
||||||
|
Pdfpage.change_pages true pdf pages'
|
||||||
|
|
8
cpdfpresent.mli
Normal file
8
cpdfpresent.mli
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
(** {2 Presentations} *)
|
||||||
|
|
||||||
|
(** [presentation range t d horizontal inward direction effect_duration pdf]
|
||||||
|
adds a presentation on the pages in [range]. See cpdfmanual.pdf for details.
|
||||||
|
*)
|
||||||
|
val presentation : int list -> string option ->
|
||||||
|
float option -> bool -> bool -> int -> float -> Pdf.t -> Pdf.t
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user