-trim-marks finished
This commit is contained in:
parent
cf66fa3d72
commit
bcef18797b
14
Changes
14
Changes
|
@ -1,6 +1,20 @@
|
||||||
Version 2.3 (October 2019)
|
Version 2.3 (October 2019)
|
||||||
|
|
||||||
o Directly set and remove Trim, Art, and Bleed boxes
|
o Directly set and remove Trim, Art, and Bleed boxes
|
||||||
|
o Dump attachments to file
|
||||||
|
o New -hard-box option to set a box and clip to it
|
||||||
|
o Extended bookmark format, preserving all bookmark information
|
||||||
|
o New -pad-with, -pad-mutiple-before option
|
||||||
|
o Set or create XMP metadata
|
||||||
|
o -remove-clipping
|
||||||
|
o Extended support for reading malformed files
|
||||||
|
o Embed missing fonts by calling out to gs
|
||||||
|
o Set bookmarks open to a given level
|
||||||
|
o Create PDF files from scatch
|
||||||
|
o Remove single images by name
|
||||||
|
o Add trim and registration marks
|
||||||
|
o Merge AcroForms
|
||||||
|
o Search for unicode characters in a font automatically
|
||||||
|
|
||||||
Version 2.2 (patchlevel 1)
|
Version 2.2 (patchlevel 1)
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,7 @@ type op =
|
||||||
| CreatePDF
|
| CreatePDF
|
||||||
| RemoveAllText
|
| RemoveAllText
|
||||||
| ShowBoxes
|
| ShowBoxes
|
||||||
|
| TrimMarks
|
||||||
|
|
||||||
let string_of_op = function
|
let string_of_op = function
|
||||||
| CopyFont _ -> "CopyFont"
|
| CopyFont _ -> "CopyFont"
|
||||||
|
@ -305,6 +306,7 @@ let string_of_op = function
|
||||||
| CreatePDF -> "CreatePDF"
|
| CreatePDF -> "CreatePDF"
|
||||||
| RemoveAllText -> "RemoveAllText"
|
| RemoveAllText -> "RemoveAllText"
|
||||||
| ShowBoxes -> "ShowBoxes"
|
| ShowBoxes -> "ShowBoxes"
|
||||||
|
| TrimMarks -> "TrimMarks"
|
||||||
|
|
||||||
(* Inputs: filename, pagespec. *)
|
(* Inputs: filename, pagespec. *)
|
||||||
type input_kind =
|
type input_kind =
|
||||||
|
@ -656,7 +658,7 @@ let banned banlist = function
|
||||||
| PrintPageLabels | Clean | Compress | Decompress
|
| PrintPageLabels | Clean | Compress | Decompress
|
||||||
| RemoveUnusedResources | ChangeId | CopyId _ | ListSpotColours | Version
|
| RemoveUnusedResources | ChangeId | CopyId _ | ListSpotColours | Version
|
||||||
| DumpAttachedFiles | RemoveMetadata | EmbedMissingFonts | BookmarksOpenToLevel _ | CreatePDF
|
| DumpAttachedFiles | RemoveMetadata | EmbedMissingFonts | BookmarksOpenToLevel _ | CreatePDF
|
||||||
| ShowBoxes -> false (* Always allowed *)
|
| ShowBoxes | TrimMarks -> false (* Always allowed *)
|
||||||
(* Combine pages is not allowed because we would not know where to get the
|
(* Combine pages is not allowed because we would not know where to get the
|
||||||
-recrypt from -- the first or second file? *)
|
-recrypt from -- the first or second file? *)
|
||||||
| ExtractText | ExtractImages | ExtractFontFile
|
| ExtractText | ExtractImages | ExtractFontFile
|
||||||
|
@ -1828,6 +1830,9 @@ and specs =
|
||||||
("-show-boxes",
|
("-show-boxes",
|
||||||
Arg.Unit (setop ShowBoxes),
|
Arg.Unit (setop ShowBoxes),
|
||||||
" Show boxes by adding rectangles to pages");
|
" Show boxes by adding rectangles to pages");
|
||||||
|
("-trim-marks",
|
||||||
|
Arg.Unit (setop TrimMarks),
|
||||||
|
" Add trim marks");
|
||||||
("-remove-crop",
|
("-remove-crop",
|
||||||
Arg.Unit (setop RemoveCrop),
|
Arg.Unit (setop RemoveCrop),
|
||||||
" Remove cropping on specified pages");
|
" Remove cropping on specified pages");
|
||||||
|
@ -3685,6 +3690,36 @@ let show_boxes_page pdf _ page =
|
||||||
let show_boxes range pdf =
|
let show_boxes range pdf =
|
||||||
Cpdf.process_pages (show_boxes_page pdf) pdf range
|
Cpdf.process_pages (show_boxes_page pdf) pdf range
|
||||||
|
|
||||||
|
let allowance = 9.
|
||||||
|
|
||||||
|
let line (x0, y0, x1, y1) =
|
||||||
|
[Pdfops.Op_m (x0, y0);
|
||||||
|
Pdfops.Op_l (x1, y1);
|
||||||
|
Pdfops.Op_s]
|
||||||
|
|
||||||
|
let trim_marks_page pdf n page =
|
||||||
|
match get_rectangle pdf page "/TrimBox", get_rectangle pdf page "/MediaBox" with
|
||||||
|
| Some (tminx, tminy, tmaxx, tmaxy), Some (minx, miny, maxx, maxy) ->
|
||||||
|
let ops =
|
||||||
|
[Pdfops.Op_q;
|
||||||
|
Pdfops.Op_K (1., 1., 1., 1.);
|
||||||
|
Pdfops.Op_w 1.]
|
||||||
|
@ line (minx, tmaxy, tminy -. allowance, tmaxy) (* top left *)
|
||||||
|
@ line (tminx, tmaxy +. allowance, tminx, maxy)
|
||||||
|
@ line (tmaxx +. allowance, tmaxy, maxx, tmaxy) (* top right *)
|
||||||
|
@ line (tmaxx, tmaxy +. allowance, tmaxx, maxy)
|
||||||
|
@ line (tmaxx +. allowance, tminy, maxx, tminy) (* bottom right *)
|
||||||
|
@ line (tmaxx, tminy -. allowance, tmaxx, miny)
|
||||||
|
@ line (tminx -. allowance, tminy, minx, tminy) (* bottom left *)
|
||||||
|
@ line (tminx, tminy -. allowance, tminx, miny)
|
||||||
|
@ [Pdfops.Op_Q]
|
||||||
|
in
|
||||||
|
Pdfpage.postpend_operators pdf ops ~fast:args.fast page
|
||||||
|
| _, _ -> Printf.eprintf "-trim_marks: No /TrimBox found on page %i\n" n; page
|
||||||
|
|
||||||
|
let trim_marks range pdf =
|
||||||
|
Cpdf.process_pages (trim_marks_page pdf) pdf range
|
||||||
|
|
||||||
(* Main function *)
|
(* Main function *)
|
||||||
let go () =
|
let go () =
|
||||||
match args.op with
|
match args.op with
|
||||||
|
@ -4554,6 +4589,10 @@ let go () =
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let range = parse_pagespec pdf (get_pagespec ()) in
|
let range = parse_pagespec pdf (get_pagespec ()) in
|
||||||
write_pdf false (show_boxes range pdf)
|
write_pdf false (show_boxes range pdf)
|
||||||
|
| Some TrimMarks ->
|
||||||
|
let pdf = get_single_pdf args.op false in
|
||||||
|
let range = parse_pagespec pdf (get_pagespec ()) in
|
||||||
|
write_pdf false (trim_marks range pdf)
|
||||||
|
|
||||||
let parse_argv () =
|
let parse_argv () =
|
||||||
if args.debug then
|
if args.debug then
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
%FIXME: Document new bookmark format + use of -utf8 for getting good bookmarks
|
%FIXME: Document new bookmark format + use of -utf8 for getting good bookmarks
|
||||||
%FIXME: Fix docs on -fit-window and friends
|
%FIXME: Fix docs on -fit-window and friends
|
||||||
%FIXME: Document new -pad-with (for -pad-before, -pad-after, -pad-every)
|
%FIXME: Document new -pad-with (for -pad-before, -pad-after, -pad-every)
|
||||||
%FIXME: Activate documentation for -extract-images (when done)
|
|
||||||
%FIXME: Document new -artbox, -trimbox, -bleedbox and -remove-artbox, -remove-trimbox, -remove-bleedbox
|
%FIXME: Document new -artbox, -trimbox, -bleedbox and -remove-artbox, -remove-trimbox, -remove-bleedbox
|
||||||
%FIXME: Document -cropbox and -remove-cropbox as synonyms of -crop and -remove-crop
|
%FIXME: Document -cropbox and -remove-cropbox as synonyms of -crop and -remove-crop
|
||||||
%FIXME: Document new XMP metadata stuff including setmetadata date and its format
|
%FIXME: Document new XMP metadata stuff including setmetadata date and its format
|
||||||
|
@ -27,7 +26,7 @@
|
||||||
%FIXME: Explain fast more / better and list things it works on
|
%FIXME: Explain fast more / better and list things it works on
|
||||||
%FIXME: Document new -draft-remove-only functionality for deleting images
|
%FIXME: Document new -draft-remove-only functionality for deleting images
|
||||||
%FIXME: Document that -decompress may need -no-preserve-objstm
|
%FIXME: Document that -decompress may need -no-preserve-objstm
|
||||||
%FIXME: Document new -show-boxes, -trim-marks, -registation-marks operations.
|
%FIXME: Document new -show-boxes, -trim-marks operations.
|
||||||
|
|
||||||
\documentclass{book}
|
\documentclass{book}
|
||||||
\usepackage{palatino}
|
\usepackage{palatino}
|
||||||
|
|
Loading…
Reference in New Issue