From 962e27dd14fb61b49b2d08f0f6d1a1926b9bc696 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Fri, 31 Dec 2021 19:33:34 +0000 Subject: [PATCH] tidying --- cpdfaddtext.ml | 2 +- cpdfattach.ml | 3 +-- cpdfdraft.ml | 2 +- cpdfmetadata.ml | 21 ++++++++------------- cpdfpad.ml | 2 +- cpdfpage.ml | 12 ++++++------ cpdftweak.ml | 10 ++++------ 7 files changed, 22 insertions(+), 30 deletions(-) diff --git a/cpdfaddtext.ml b/cpdfaddtext.ml index e614d6c..0601b60 100644 --- a/cpdfaddtext.ml +++ b/cpdfaddtext.ml @@ -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). *) diff --git a/cpdfattach.ml b/cpdfattach.ml index ce83799..ec7fbb2 100644 --- a/cpdfattach.ml +++ b/cpdfattach.ml @@ -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)) - diff --git a/cpdfdraft.ml b/cpdfdraft.ml index bf8b7fc..3fe8ffd 100644 --- a/cpdfdraft.ml +++ b/cpdfdraft.ml @@ -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) = diff --git a/cpdfmetadata.ml b/cpdfmetadata.ml index 7d9c4c8..857dcb8 100644 --- a/cpdfmetadata.ml +++ b/cpdfmetadata.ml @@ -56,7 +56,7 @@ let xmp_template = |} -(* \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" diff --git a/cpdfpad.ml b/cpdfpad.ml index 43799b8..cb2f6aa 100644 --- a/cpdfpad.ml +++ b/cpdfpad.ml @@ -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 diff --git a/cpdfpage.ml b/cpdfpage.ml index 4efa53e..37379c2 100644 --- a/cpdfpage.ml +++ b/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 diff --git a/cpdftweak.ml b/cpdftweak.ml index 89f64be..4e2ba3d 100644 --- a/cpdftweak.ml +++ b/cpdftweak.ml @@ -2,10 +2,9 @@ open Pdfutil open Pdfio open Cpdferror -(* \section{Blacken text} *) +(* Blacken text *) (* - \begin{verbatim} Algorithm: Change BT @@ -18,7 +17,6 @@ open Cpdferror ET - \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 =