Update and modernize page characteristics
This commit is contained in:
parent
f6502da990
commit
e913b80bb2
1
Changes
1
Changes
|
@ -7,6 +7,7 @@ o Add @b<n>@ for trimming bookmark text to given length
|
||||||
o Add Piece Info to -composition[-json]
|
o Add Piece Info to -composition[-json]
|
||||||
o -merge-add-bookmarks now has proper titles for images
|
o -merge-add-bookmarks now has proper titles for images
|
||||||
o New -jpeg-to-jpeg-scale and -jpeg-to-jpeg-dpi
|
o New -jpeg-to-jpeg-scale and -jpeg-to-jpeg-dpi
|
||||||
|
o Expand page characteristics to cover Art, Trim, Bleed
|
||||||
|
|
||||||
2.7.2 (October 2024)
|
2.7.2 (October 2024)
|
||||||
|
|
||||||
|
|
77
cpdfcoord.ml
77
cpdfcoord.ml
|
@ -18,8 +18,8 @@ let points_of_papersize p =
|
||||||
let h = Pdfunits.points (Pdfpaper.height p) u in
|
let h = Pdfunits.points (Pdfpaper.height p) u in
|
||||||
w, h
|
w, h
|
||||||
|
|
||||||
let cropbox pdf page =
|
let box name pdf page =
|
||||||
match Pdf.lookup_direct pdf "/CropBox" page.Pdfpage.rest with
|
match Pdf.lookup_direct pdf name page.Pdfpage.rest with
|
||||||
| Some pdfobject -> Pdf.direct pdf pdfobject
|
| Some pdfobject -> Pdf.direct pdf pdfobject
|
||||||
| None -> page.Pdfpage.mediabox
|
| None -> page.Pdfpage.mediabox
|
||||||
|
|
||||||
|
@ -30,34 +30,48 @@ let miny pdf box = let minx, miny, maxx, maxy = Pdf.parse_rectangle pdf box in m
|
||||||
let maxx pdf box = let minx, miny, maxx, maxy = Pdf.parse_rectangle pdf box in maxx
|
let maxx pdf box = let minx, miny, maxx, maxy = Pdf.parse_rectangle pdf box in maxx
|
||||||
let maxy pdf box = let minx, miny, maxx, maxy = Pdf.parse_rectangle pdf box in maxy
|
let maxy pdf box = let minx, miny, maxx, maxy = Pdf.parse_rectangle pdf box in maxy
|
||||||
|
|
||||||
let find_page_width pdf page = width pdf page.Pdfpage.mediabox
|
|
||||||
let find_page_height pdf page = height pdf page.Pdfpage.mediabox
|
|
||||||
let find_page_crop_width pdf page = width pdf (cropbox pdf page)
|
|
||||||
let find_page_crop_height pdf page = height pdf (cropbox pdf page)
|
|
||||||
let find_page_minx pdf page = minx pdf page.Pdfpage.mediabox
|
|
||||||
let find_page_miny pdf page = miny pdf page.Pdfpage.mediabox
|
|
||||||
let find_page_maxx pdf page = maxx pdf page.Pdfpage.mediabox
|
|
||||||
let find_page_maxy pdf page = maxy pdf page.Pdfpage.mediabox
|
|
||||||
let find_page_crop_minx pdf page = minx pdf (cropbox pdf page)
|
|
||||||
let find_page_crop_miny pdf page = miny pdf (cropbox pdf page)
|
|
||||||
let find_page_crop_maxx pdf page = maxx pdf (cropbox pdf page)
|
|
||||||
let find_page_crop_maxy pdf page = maxy pdf (cropbox pdf page)
|
|
||||||
|
|
||||||
let find_page_characteristic pdf page = function
|
let find_page_characteristic pdf page = function
|
||||||
| "PW" -> find_page_width pdf page
|
| "PW" -> width pdf page.Pdfpage.mediabox
|
||||||
| "PH" -> find_page_height pdf page
|
| "PH" -> height pdf page.Pdfpage.mediabox
|
||||||
| "CW" -> find_page_crop_width pdf page
|
| "CW" -> width pdf (box "/CropBox" pdf page)
|
||||||
| "CH" -> find_page_crop_height pdf page
|
| "CH" -> height pdf (box "/CropBox" pdf page)
|
||||||
| "PMINX" -> find_page_minx pdf page
|
| "AW" -> width pdf (box "/ArtBox" pdf page)
|
||||||
| "PMINY" -> find_page_miny pdf page
|
| "AH" -> height pdf (box "/ArtBox" pdf page)
|
||||||
| "PMAXX" -> find_page_maxx pdf page
|
| "TW" -> width pdf (box "/TrimBox" pdf page)
|
||||||
| "PMAXY" -> find_page_maxy pdf page
|
| "TH" -> height pdf (box "/TrimBox" pdf page)
|
||||||
| "CMINX" -> find_page_crop_minx pdf page
|
| "BW" -> width pdf (box "/BleedBox" pdf page)
|
||||||
| "CMINY" -> find_page_crop_miny pdf page
|
| "BH" -> height pdf (box "/BleedBox" pdf page)
|
||||||
| "CMAXX" -> find_page_crop_maxx pdf page
|
| "PMINX" -> minx pdf page.Pdfpage.mediabox
|
||||||
| "CMAXY" -> find_page_crop_maxy pdf page
|
| "PMINY" -> miny pdf page.Pdfpage.mediabox
|
||||||
|
| "PMAXX" -> maxx pdf page.Pdfpage.mediabox
|
||||||
|
| "PMAXY" -> maxy pdf page.Pdfpage.mediabox
|
||||||
|
| "CMINX" -> minx pdf (box "/CropBox" pdf page)
|
||||||
|
| "CMINY" -> miny pdf (box "/CropBox" pdf page)
|
||||||
|
| "CMAXX" -> maxx pdf (box "/CropBox" pdf page)
|
||||||
|
| "CMAXY" -> maxy pdf (box "/CropBox" pdf page)
|
||||||
|
| "AMINX" -> minx pdf (box "/ArtBox" pdf page)
|
||||||
|
| "AMINY" -> miny pdf (box "/ArtBox" pdf page)
|
||||||
|
| "AMAXX" -> maxx pdf (box "/ArtBox" pdf page)
|
||||||
|
| "AMAXY" -> maxy pdf (box "/ArtBox" pdf page)
|
||||||
|
| "TMINX" -> minx pdf (box "/TrimBox" pdf page)
|
||||||
|
| "TMINY" -> miny pdf (box "/TrimBox" pdf page)
|
||||||
|
| "TMAXX" -> maxx pdf (box "/TrimBox" pdf page)
|
||||||
|
| "TMAXY" -> maxy pdf (box "/TrimBox" pdf page)
|
||||||
|
| "BMINX" -> minx pdf (box "/BleedBox" pdf page)
|
||||||
|
| "BMINY" -> miny pdf (box "/BleedBox" pdf page)
|
||||||
|
| "BMAXX" -> maxx pdf (box "/BleedBox" pdf page)
|
||||||
|
| "BMAXY" -> maxy pdf (box "/BleedBox" pdf page)
|
||||||
| _ -> failwith "find_page_characteristic"
|
| _ -> failwith "find_page_characteristic"
|
||||||
|
|
||||||
|
let is_page_characteristic = function
|
||||||
|
| "PW" | "PH" | "CW" | "CH" | "AW" | "AH" | "TW" | "TH" | "BW" | "BH"
|
||||||
|
| "PMINX" | "PMINY" | "PMAXX" | "PMAXY"
|
||||||
|
| "CMINX" | "CMINY" | "CMAXX" | "CMAXY"
|
||||||
|
| "AMINX" | "AMINY" | "AMAXX" | "AMAXY"
|
||||||
|
| "TMINX" | "TMINY" | "TMAXX" | "TMAXY"
|
||||||
|
| "BMINX" | "BMINY" | "BMAXX" | "BMAXY" -> true
|
||||||
|
| _ -> false
|
||||||
|
|
||||||
let make_num pdf page unt num =
|
let make_num pdf page unt num =
|
||||||
let f =
|
let f =
|
||||||
match num with
|
match num with
|
||||||
|
@ -66,11 +80,7 @@ let make_num pdf page unt num =
|
||||||
| Pdfgenlex.LexName
|
| Pdfgenlex.LexName
|
||||||
(( "PW" | "PH" | "CW" | "CH" | "PMINX" | "PMINY" | "PMAXX" | "PMAXY"
|
(( "PW" | "PH" | "CW" | "CH" | "PMINX" | "PMINY" | "PMAXX" | "PMAXY"
|
||||||
| "CMINX" | "CMINY" | "CMAXX" | "CMAXY") as page_characteristic) ->
|
| "CMINX" | "CMINY" | "CMAXX" | "CMAXY") as page_characteristic) ->
|
||||||
(*let r =*)
|
|
||||||
find_page_characteristic pdf page page_characteristic
|
find_page_characteristic pdf page page_characteristic
|
||||||
(*in
|
|
||||||
Printf.printf "characteristic %s is %f\n" page_characteristic r;
|
|
||||||
r*)
|
|
||||||
| _ -> failwith "make_num"
|
| _ -> failwith "make_num"
|
||||||
in
|
in
|
||||||
match unt with
|
match unt with
|
||||||
|
@ -172,10 +182,7 @@ and parse_units pdf page numbers = function
|
||||||
| Pdfgenlex.LexName
|
| Pdfgenlex.LexName
|
||||||
(( "PW" | "PH" | "CW" | "CH" | "PMINX" | "PMINY" | "PMAXX" | "PMAXY"
|
(( "PW" | "PH" | "CW" | "CH" | "PMINX" | "PMINY" | "PMAXX" | "PMAXY"
|
||||||
| "CMINX" | "CMINY" | "CMAXX" | "CMAXY") as page_characteristic)::more ->
|
| "CMINX" | "CMINY" | "CMAXX" | "CMAXY") as page_characteristic)::more ->
|
||||||
let r =
|
let r = find_page_characteristic pdf page page_characteristic in
|
||||||
find_page_characteristic pdf page page_characteristic
|
|
||||||
in
|
|
||||||
(* Printf.printf "characteristic %s is %f\n" page_characteristic r;*)
|
|
||||||
parse_units pdf page (r::numbers) more
|
parse_units pdf page (r::numbers) more
|
||||||
| Pdfgenlex.LexName ("add" | "sub" | "mul" | "div") as op::
|
| Pdfgenlex.LexName ("add" | "sub" | "mul" | "div") as op::
|
||||||
((Pdfgenlex.LexInt _ | Pdfgenlex.LexReal _ | Pdfgenlex.LexName
|
((Pdfgenlex.LexInt _ | Pdfgenlex.LexReal _ | Pdfgenlex.LexName
|
||||||
|
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -910,7 +910,7 @@ supported:
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\end{center}
|
\end{center}
|
||||||
|
|
||||||
\noindent For example, one may write \texttt{14mm} or \texttt{21.6in}. In addition, the following letters stand, in some operations (\texttt{-scale-page}, \texttt{-scale-to-fit}, \texttt{-scale-contents}, \texttt{-shift}, \texttt{-mediabox},\\ \texttt{-cropbox}) for various page dimensions:
|
\noindent For example, one may write \texttt{14mm} or \texttt{21.6in}. In addition, the following letters stand for various page dimensions:
|
||||||
|
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\begin{tabular}{rl}
|
\begin{tabular}{rl}
|
||||||
|
@ -925,7 +925,25 @@ supported:
|
||||||
\texttt{CMINX} & Crop box minimum x coordinate\\
|
\texttt{CMINX} & Crop box minimum x coordinate\\
|
||||||
\texttt{CMINY} & Crop box minimum y coordinate\\
|
\texttt{CMINY} & Crop box minimum y coordinate\\
|
||||||
\texttt{CMAXX} & Crop box maximum x coordinate\\
|
\texttt{CMAXX} & Crop box maximum x coordinate\\
|
||||||
\texttt{CMAXY} & Crop box maximum y coordinate
|
\texttt{CMAXY} & Crop box maximum y coordinate\\
|
||||||
|
\texttt{AW} & Art box width\\
|
||||||
|
\texttt{AH} & Art box height\\
|
||||||
|
\texttt{AMINX} & Art box minimum x coordinate\\
|
||||||
|
\texttt{AMINY} & Art box minimum y coordinate\\
|
||||||
|
\texttt{AMAXX} & Art box maximum x coordinate\\
|
||||||
|
\texttt{AMAXY} & Art box maximum y coordinate\\
|
||||||
|
\texttt{TW} & Trim box width\\
|
||||||
|
\texttt{TH} & Trim box height\\
|
||||||
|
\texttt{TMINX} & Trim box minimum x coordinate\\
|
||||||
|
\texttt{TMINY} & Trim box minimum y coordinate\\
|
||||||
|
\texttt{TMAXX} & Trim box maximum x coordinate\\
|
||||||
|
\texttt{TMAXY} & Trim box maximum y coordinate\\
|
||||||
|
\texttt{BW} & Bleed box width\\
|
||||||
|
\texttt{BH} & Bleed box height\\
|
||||||
|
\texttt{BMINX} & Bleed box minimum x coordinate\\
|
||||||
|
\texttt{BMINY} & Bleed box minimum y coordinate\\
|
||||||
|
\texttt{BMAXX} & Bleed box maximum x coordinate\\
|
||||||
|
\texttt{BMAXY} & Bleed box maximum y coordinate\\
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\end{center}
|
\end{center}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue