From 1f7c10e2b5c3db825e99d09c59cbdb1fd9a0e6d8 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 18 Nov 2014 10:51:14 +0000 Subject: [PATCH] Faster attachments, fixes for manual bugs --- cpdf.ml | 15 +++++++-------- cpdfcommand.ml | 30 ++++++------------------------ 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/cpdf.ml b/cpdf.ml index 1e538f2..1044b7d 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -642,17 +642,16 @@ let presentation range t d h i dir effect_dur pdf = in Pdfpage.change_pages true pdf pages' -(* \section{Attaching files} *) +(* Attaching files *) let make_filestream file = let data = let ch = open_in_bin file in - let len = in_channel_length ch in - let stream = mkbytes len in - for x = 0 to bytes_size stream - 1 do - bset stream x (input_byte ch) - done; - close_in ch; - stream + let len = in_channel_length ch in + let stream = mkbytes len in + let i = input_of_channel ch in + setinit i stream 0 len; + close_in ch; + stream in Pdf.Stream (ref (Pdf.Dictionary diff --git a/cpdfcommand.ml b/cpdfcommand.ml index c235da8..dbd7613 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1198,7 +1198,10 @@ let setcopyfontname s = args.copyfontname <- Some s let setpadevery i = - args.op <- Some (PadEvery i) + if i > 0 then + args.op <- Some (PadEvery i) + else + error "PadEvery: must be > 0" let setpadmultiple i = args.op <- Some (PadMultiple i) @@ -1496,9 +1499,7 @@ and specs = ("-remove-duplicate-streams", Arg.Unit setremoveduplicatestreams, ""); - ("-squeeze", - Arg.Unit setsqueeze, - ""); + ("-list-bookmarks", Arg.Unit (setop ListBookmarks), " List Bookmarks"); @@ -1826,29 +1827,9 @@ and specs = ("-label-startval", Arg.Int setlabelstartval, " Set label start value (default 1)"); - (* These items are for cpdftk *) - (*("-update-info", Arg.String setupdateinfo, ""); - ("-printf-format", Arg.Unit setprintfformat, ""); - - ("-dump-data", Arg.Unit (setop DumpData), ""); - ("-keep-this-id", Arg.Unit setkeepthisid, ""); - ("-do-ask", Arg.Unit setdoask, ""); - ("-verbose", Arg.Unit setverbose, ""); - ("-prompt-inputs", Arg.Unit promptinputs, ""); - ("-prompt-input-passwords", Arg.Unit promptinputpasswords, ""); - ("-prompt-output", Arg.Unit promptoutput, ""); - ("-dont-overwrite-existing-files", Arg.Unit setdontoverwriteexistingfiles, ""); - ("-dont-overwrite-inputs", Arg.Unit setdontoverwriteinputs, ""); - ("-make-new-id", Arg.Unit setmakenewid, ""); - ("-upright-stamp", Arg.Unit setuprightstamp, ""); - ("-remove-unused-resources", Arg.Unit (setop RemoveUnusedResources), ""); - ("-stamp-under-multi", Arg.String setstampundermulti, ""); - ("-stamp-on-multi", Arg.String setstamponmulti, ""); - ("-list-annotations-more", Arg.Unit (setop ListAnnotationsMore), "");*) (*These items are undocumented *) ("-extract-fontfile", Arg.Unit (setop ExtractFontFile), ""); ("-extract-images", Arg.Unit setextractimages, ""); - (*("-output-graph", Arg.Unit (setoutputgraph), "");*) ("-csp1", Arg.Unit (setop CSP1), ""); ("-csp2", Arg.Float setcsp2, ""); ("-csp3", Arg.Unit (setop CSP3), ""); @@ -1859,6 +1840,7 @@ and specs = ("-debug", Arg.Unit setdebug, ""); ("-debug-crypt", Arg.Unit setdebugcrypt, ""); ("-fix-prince", Arg.Unit (setop RemoveUnusedResources), ""); + ("-squeeze", Arg.Unit setsqueeze, ""); ("-extract-text", Arg.Unit (setop ExtractText), "")] and usage_msg =