more
This commit is contained in:
parent
1fdd55bf8f
commit
f34d72ad10
1
Changes
1
Changes
|
@ -1,5 +1,6 @@
|
|||
Version 2.2 (To come)
|
||||
|
||||
o Perform artihmetic on dimensions when specifying size or position
|
||||
o Add simple rectangles to PDF to blank things out
|
||||
o Stamping operations now preserve annotations
|
||||
o Decryption fully on-demand for speed.
|
||||
|
|
|
@ -1740,7 +1740,7 @@ and specs =
|
|||
" Remove text previously added by cpdf");
|
||||
("-add-rectangle",
|
||||
Arg.String setrectangle,
|
||||
"");
|
||||
" Add a rectangle to the page");
|
||||
("-bates",
|
||||
Arg.Int setbates,
|
||||
" Set the base bates number");
|
||||
|
@ -2041,9 +2041,9 @@ and specs =
|
|||
("-creator",
|
||||
Arg.String setcreator,
|
||||
" Change the /Creator entry in the /Info dictionary");
|
||||
("-list-spot-colours",
|
||||
("-list-spot-colors",
|
||||
Arg.Unit (setop ListSpotColours),
|
||||
" List spot colours");
|
||||
" List spot colors");
|
||||
("-squeeze", Arg.Unit setsqueeze, " Squeeze");
|
||||
("-squeeze-log-to", Arg.String setsqueezelogto, " Squeeze log location");
|
||||
(*These items are undocumented *)
|
||||
|
@ -3082,9 +3082,61 @@ let extract_fontfile pagenumber fontname pdf =
|
|||
end
|
||||
| _ -> failwith "unsupported or unfound font"
|
||||
|
||||
let addrectangle (w, h) color position relative_to_cropbox underneath range pdf =
|
||||
let addrectangle
|
||||
fast (w, h) colour outline linewidth opacity position relative_to_cropbox
|
||||
underneath range pdf
|
||||
=
|
||||
let addrectangle_page _ page =
|
||||
page
|
||||
let resources', unique_extgstatename =
|
||||
if opacity < 1.0 then
|
||||
let dict =
|
||||
match Pdf.lookup_direct pdf "/ExtGState" page.Pdfpage.resources with
|
||||
| Some d -> d
|
||||
| None -> Pdf.Dictionary []
|
||||
in
|
||||
let unique_extgstatename = Pdf.unique_key "gs" dict in
|
||||
let dict' =
|
||||
Pdf.add_dict_entry dict unique_extgstatename
|
||||
(Pdf.Dictionary [("/ca", Pdf.Real opacity); ("/CA", Pdf.Real opacity)])
|
||||
in
|
||||
Pdf.add_dict_entry page.Pdfpage.resources "/ExtGState" dict', Some unique_extgstatename
|
||||
else
|
||||
page.Pdfpage.resources, None
|
||||
in
|
||||
let mediabox =
|
||||
if relative_to_cropbox then
|
||||
match Pdf.lookup_direct pdf "/CropBox" page.Pdfpage.rest with
|
||||
| Some pdfobject -> Pdf.parse_rectangle (Pdf.direct pdf pdfobject)
|
||||
| None -> Pdf.parse_rectangle page.Pdfpage.mediabox
|
||||
else
|
||||
Pdf.parse_rectangle page.Pdfpage.mediabox
|
||||
in
|
||||
let x, y, _ =
|
||||
Cpdf.calculate_position false w mediabox Cpdf.Horizontal position
|
||||
in
|
||||
let ops =
|
||||
[
|
||||
Pdfops.Op_q;
|
||||
Pdfops.Op_BMC "/CPDFSTAMP";
|
||||
(match colour with (r, g, b) -> Pdfops.Op_rg (r, g, b));
|
||||
(match colour with (r, g, b) -> Pdfops.Op_RG (r, g, b))
|
||||
]
|
||||
@
|
||||
(if outline then [Pdfops.Op_w linewidth] else [])
|
||||
@
|
||||
(match unique_extgstatename with None -> [] | Some n -> [Pdfops.Op_gs n])
|
||||
@
|
||||
[
|
||||
Pdfops.Op_re (x, y, w, h);
|
||||
(if outline then Pdfops.Op_s else Pdfops.Op_f);
|
||||
Pdfops.Op_EMC;
|
||||
Pdfops.Op_Q
|
||||
]
|
||||
in
|
||||
let page = {page with Pdfpage.resources = resources'} in
|
||||
if underneath
|
||||
then Pdfpage.prepend_operators pdf ops ~fast:fast page
|
||||
else Pdfpage.postpend_operators pdf ops ~fast:fast page
|
||||
in
|
||||
Cpdf.process_pages addrectangle_page pdf range
|
||||
|
||||
|
@ -3700,8 +3752,9 @@ let go () =
|
|||
let range = parse_pagespec pdf (get_pagespec ()) in
|
||||
write_pdf false
|
||||
(addrectangle
|
||||
(parse_coordinate pdf args.coord)
|
||||
args.color args.position args.relative_to_cropbox args.underneath range pdf)
|
||||
args.fast (parse_coordinate pdf args.coord)
|
||||
args.color args.outline args.linewidth args.opacity args.position
|
||||
args.relative_to_cropbox args.underneath range pdf)
|
||||
| Some (AddBookmarks file) ->
|
||||
write_pdf false
|
||||
(Cpdf.add_bookmarks true (Pdfio.input_of_channel (open_in_bin file))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
%FIXME: Document that -upright also shifts the page to 0,0
|
||||
\documentclass{book}
|
||||
\usepackage{palatino}
|
||||
\usepackage{microtype}
|
||||
|
@ -2124,7 +2125,7 @@ recommended when file size is the sole consideration.
|
|||
\noindent\verb!cpdf -remove-id in.pdf -o out.pdf!
|
||||
|
||||
\vspace{1.5mm}
|
||||
\noindent\verb!cpdf -list-spot-colours in.pdf!
|
||||
\noindent\verb!cpdf -list-spot-colors in.pdf!
|
||||
|
||||
\vspace{1.5mm}
|
||||
\noindent\verb!cpdf -remove-dict-entry in.pdf -o out.pdf!
|
||||
|
@ -2235,13 +2236,13 @@ You cannot use \texttt{-recrypt} with \texttt{-remove-id}.
|
|||
|
||||
\section{List Spot Colours}
|
||||
|
||||
This operation lists the name of any ``separation'' colour space in the given PDF file.
|
||||
This operation lists the name of any ``separation'' color space in the given PDF file.
|
||||
|
||||
\begin{framed}
|
||||
\small\noindent\verb!cpdf -list-spot-colours in.pdf!
|
||||
\small\noindent\verb!cpdf -list-spot-colors in.pdf!
|
||||
|
||||
\vspace{2.5mm}
|
||||
\noindent List the spot colours, one per line in \texttt{in.pdf}, writing to \texttt{stdout}.
|
||||
\noindent List the spot colors, one per line in \texttt{in.pdf}, writing to \texttt{stdout}.
|
||||
\end{framed}
|
||||
|
||||
\section{Removing Dictionary Entries}
|
||||
|
|
Loading…
Reference in New Issue