tidying
This commit is contained in:
parent
9c5a905cc7
commit
962e27dd14
|
@ -6,7 +6,7 @@ type color =
|
|||
| RGB of float * float * float
|
||||
| CYMK of float * float * float * float
|
||||
|
||||
(* \section{Superimpose text, page numbers etc.} *)
|
||||
(* Superimpose text, page numbers etc. *)
|
||||
|
||||
(* Process UTF8 text to /WinAnsiEncoding string (for standard 14) or whatever
|
||||
is in the font (for existing fonts). *)
|
||||
|
|
|
@ -206,7 +206,7 @@ let list_attached_files pdf =
|
|||
in
|
||||
toplevel @ pagelevel
|
||||
|
||||
(* \section{Remove Attached files} *)
|
||||
(* Remove Attached files *)
|
||||
let remove_attached_files_on_pages pdf =
|
||||
let remove_from_page page =
|
||||
{page with Pdfpage.rest =
|
||||
|
@ -301,4 +301,3 @@ let dump_attached_files pdf out =
|
|||
iter (dump_attached_page pdf out) (Pdfpage.pages_of_pagetree pdf)
|
||||
with
|
||||
e -> error (Printf.sprintf "Couldn't dump attached files: %s\n" (Printexc.to_string e))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
open Pdfutil
|
||||
open Pdfio
|
||||
|
||||
(* \section{Making draft documents} *)
|
||||
(* Making draft documents *)
|
||||
|
||||
(* Predicate on an xobject: true if an image xobject. *)
|
||||
let isimage pdf (_, xobj) =
|
||||
|
|
|
@ -56,7 +56,7 @@ let xmp_template =
|
|||
|
||||
<?xpacket end='r'?>|}
|
||||
|
||||
(* \section{Set or replace metadata} *)
|
||||
(* Set or replace metadata *)
|
||||
let set_metadata_from_bytes keepversion data pdf =
|
||||
let metadata_stream =
|
||||
Pdf.Stream
|
||||
|
@ -94,9 +94,7 @@ let set_metadata keepversion filename pdf =
|
|||
done;
|
||||
set_metadata_from_bytes keepversion data pdf
|
||||
|
||||
|
||||
|
||||
(* \section{Remove metadata} *)
|
||||
(* Remove metadata *)
|
||||
let remove_metadata pdf =
|
||||
match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
||||
| None -> error "malformed file"
|
||||
|
@ -108,6 +106,7 @@ let remove_metadata pdf =
|
|||
Pdf.add_dict_entry pdf.Pdf.trailerdict "/Root" (Pdf.Indirect rootnum);
|
||||
Pdf.root =
|
||||
rootnum}
|
||||
|
||||
(* Print metadata *)
|
||||
let get_metadata pdf =
|
||||
match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
||||
|
@ -353,8 +352,7 @@ let set_pdf_info_xml_many changes value xmldata pdf =
|
|||
changes;
|
||||
!xmldata
|
||||
|
||||
|
||||
(* \section{Set an entry in the /Info dictionary} *)
|
||||
(* Set an entry in the /Info dictionary *)
|
||||
|
||||
(* We must parse the date to get its components, then use strftime to build the
|
||||
* new string in XMP format *)
|
||||
|
@ -528,7 +526,7 @@ let set_metadata_date pdf date =
|
|||
pdf
|
||||
|
||||
|
||||
(* \section{Copy an /ID from one file to another} *)
|
||||
(* Copy an /ID from one file to another *)
|
||||
let copy_id keepversion copyfrom copyto =
|
||||
match Pdf.lookup_direct copyfrom "/ID" copyfrom.Pdf.trailerdict with
|
||||
| None -> copyto (* error "Source PDF file has no /ID entry to copy from" *)
|
||||
|
@ -559,7 +557,7 @@ let create_metadata pdf =
|
|||
(replacements pdf);
|
||||
set_metadata_from_bytes false (bytes_of_string !xmp) pdf
|
||||
|
||||
(* \section{Set viewer preferences} *)
|
||||
(* Set viewer preferences *)
|
||||
let set_viewer_preference (key, value, version) pdf =
|
||||
match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
||||
| Some catalog ->
|
||||
|
@ -584,9 +582,7 @@ let set_viewer_preference (key, value, version) pdf =
|
|||
Pdf.trailerdict = trailerdict'}
|
||||
| None -> error "bad root"
|
||||
|
||||
|
||||
|
||||
(* \section{Set page layout} *)
|
||||
(* Set page layout *)
|
||||
let set_page_layout pdf s =
|
||||
match s with
|
||||
| "SinglePage" | "OneColumn" | "TwoColumnLeft"
|
||||
|
@ -607,8 +603,7 @@ let set_page_layout pdf s =
|
|||
end
|
||||
| _ -> error "Unknown page layout"
|
||||
|
||||
|
||||
(* \section{Set page mode} *)
|
||||
(* Set page mode *)
|
||||
let set_page_mode pdf s =
|
||||
match s with
|
||||
| "UseNone" | "UseOutlines" | "UseThumbs"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
open Pdfutil
|
||||
|
||||
(* \section{Padding with blank pages.} *)
|
||||
(* Padding with blank pages. *)
|
||||
let insert_after pos page pages =
|
||||
let before, after = cleave pages pos in
|
||||
before @ [page] @ after
|
||||
|
|
12
cpdfpage.ml
12
cpdfpage.ml
|
@ -97,7 +97,7 @@ let shift_page ?(fast=false) dxdylist pdf pnum page =
|
|||
let shift_pdf ?(fast=false) dxdylist pdf range =
|
||||
process_pages (shift_page ~fast dxdylist pdf) pdf range
|
||||
|
||||
(* \section{Shift page data} *)
|
||||
(* Shift page data *)
|
||||
let make_mediabox (xmin, ymin, xmax, ymax) =
|
||||
Pdf.Array
|
||||
[Pdf.Real xmin; Pdf.Real ymin; Pdf.Real xmax; Pdf.Real ymax]
|
||||
|
@ -183,7 +183,7 @@ let scale_page_contents ?(fast=false) scale position pdf pnum page =
|
|||
let scale_contents ?(fast=false) position scale pdf range =
|
||||
process_pages (scale_page_contents ~fast scale position pdf) pdf range
|
||||
|
||||
(* \section{Set media box} *)
|
||||
(* Set media box *)
|
||||
let set_mediabox xywhlist pdf range =
|
||||
let crop_page pnum page =
|
||||
let x, y, w, h = List.nth xywhlist (pnum - 1) in
|
||||
|
@ -287,7 +287,7 @@ let upright ?(fast=false) range pdf =
|
|||
in
|
||||
process_pages (upright_page pdf) pdf range
|
||||
|
||||
(* \section{Rotating pages} *)
|
||||
(* Rotating pages *)
|
||||
let rotate_pdf r pdf range =
|
||||
let rotate_page _ page =
|
||||
{page with Pdfpage.rotate =
|
||||
|
@ -325,7 +325,7 @@ let rotate_page_contents ~fast rotpoint r pdf pnum page =
|
|||
let rotate_contents ?(fast=false) r pdf range =
|
||||
process_pages (rotate_page_contents ~fast None r pdf) pdf range
|
||||
|
||||
(* \section{Scale page data} *)
|
||||
(* Scale page data *)
|
||||
let scale_pdf ?(fast=false) sxsylist pdf range =
|
||||
let scale_page pnum page =
|
||||
let sx, sy = List.nth sxsylist (pnum - 1) in
|
||||
|
@ -413,7 +413,7 @@ let hasbox pdf page boxname =
|
|||
|
||||
|
||||
|
||||
(* \section{Flip pages} *)
|
||||
(* Flip pages *)
|
||||
let flip_page ?(fast=false) transform_op pdf pnum page =
|
||||
let minx, miny, maxx, maxy =
|
||||
Pdf.parse_rectangle page.Pdfpage.mediabox
|
||||
|
@ -658,7 +658,7 @@ let setBox box minx maxx miny maxy pdf range =
|
|||
in
|
||||
process_pages (Cpdfutil.ppstub set_box_page) pdf range
|
||||
|
||||
(* \section{Cropping} *)
|
||||
(* Cropping *)
|
||||
let crop_pdf ?(box="/CropBox") xywhlist pdf range =
|
||||
let crop_page pagenum page =
|
||||
{page with
|
||||
|
|
10
cpdftweak.ml
10
cpdftweak.ml
|
@ -2,10 +2,9 @@ open Pdfutil
|
|||
open Pdfio
|
||||
open Cpdferror
|
||||
|
||||
(* \section{Blacken text} *)
|
||||
(* Blacken text *)
|
||||
|
||||
(*
|
||||
\begin{verbatim}
|
||||
Algorithm: Change
|
||||
BT
|
||||
<ops>
|
||||
|
@ -18,7 +17,6 @@ open Cpdferror
|
|||
<ops minus any color, shading or gs operators>
|
||||
ET
|
||||
<ops minus any text positioning or text rendering ones>
|
||||
\end{verbatim}
|
||||
*)
|
||||
let blacktext_ops colour pdf resources content =
|
||||
let not_text = function
|
||||
|
@ -94,7 +92,7 @@ let blacktext c range pdf =
|
|||
in
|
||||
Cpdfpage.process_pages (Cpdfutil.ppstub blacktext_page) pdf range
|
||||
|
||||
(* \section{Blacken lines} *)
|
||||
(* Blacken lines *)
|
||||
let blacklines_ops c pdf resources content =
|
||||
let rec blacken_strokeops prev = function
|
||||
| [] -> rev prev
|
||||
|
@ -120,7 +118,7 @@ let blacklines c range pdf =
|
|||
in
|
||||
Cpdfpage.process_pages (Cpdfutil.ppstub blacklines_page) pdf range
|
||||
|
||||
(* \section{Blacken Fills} *)
|
||||
(* Blacken Fills *)
|
||||
let blackfills_ops c pdf resources content =
|
||||
let rec blacken_fillops prev = function
|
||||
| [] -> rev prev
|
||||
|
@ -146,7 +144,7 @@ let blackfills c range pdf =
|
|||
in
|
||||
Cpdfpage.process_pages (Cpdfutil.ppstub blackfills_page) pdf range
|
||||
|
||||
(* \section{Set a minimum line width to avoid dropout} *)
|
||||
(* Set a minimum line width to avoid dropout *)
|
||||
let thinlines range width pdf =
|
||||
let thinpage _ page =
|
||||
let operators =
|
||||
|
|
Loading…
Reference in New Issue