From e6c718f367e54d8ccad08c1555b3cb0e01060a13 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 31 Oct 2023 15:50:23 +0000 Subject: [PATCH] Scaffolding for extended JSON outputs --- Changes | 3 +++ cpdfcommand.ml | 28 ++++++++++++++++++++++++++++ cpdfmanual.tex | 1 + 3 files changed, 32 insertions(+) diff --git a/Changes b/Changes index c204588..230c26b 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,9 @@ New features: o Split files to max size with -split-max o Spray splits a file to multiple outputs by alternating pages +o List document and page info in JSON format +o List page labels in JSON format +o List fonts in JSON format Extended features: diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 3d13e66..87250cb 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1154,6 +1154,22 @@ let setaddbookmarksjson s = setop (AddBookmarks s) (); args.format_json <- true +let setlistfontsjson () = + setop Fonts (); + args.format_json <- true + +let setinfojson () = + setop Info (); + args.format_json <- true + +let setpageinfojson () = + setop PageInfo (); + args.format_json <- true + +let setprintpagelabelsjson () = + setop PrintPageLabels (); + args.format_json <- true + let setlistbookmarksjson () = setop ListBookmarks (); args.format_json <- true @@ -2328,12 +2344,21 @@ and specs = ("-list-fonts", Arg.Unit (setop Fonts), " Output font list"); + ("-list-fonts-json", + Arg.Unit setlistfontsjson, + " Output font list in JSON format"); ("-info", Arg.Unit (setop Info), " Output file information"); + ("-info-json", + Arg.Unit setinfojson, + " Output file information in JSON format"); ("-page-info", Arg.Unit (setop PageInfo), " Output page information"); + ("-page-info-json", + Arg.Unit setpageinfojson, + " Output page information in JSON format"); ("-set-author", Arg.String setauthor, " Set Author"); @@ -2499,6 +2524,9 @@ and specs = ("-print-page-labels", Arg.Unit (setop PrintPageLabels), " Print page labels"); + ("-print-page-labels-json", + Arg.Unit setprintpagelabelsjson, + " Print page labels in JSON format"); ("-remove-page-labels", Arg.Unit (setop RemovePageLabels), " Remove page labels"); diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 8e99109..c9b0357 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -1,5 +1,6 @@ %Document -split-max %Document -spray +%Document -info-json, -page-info-json, -page-labels-json, -list-fonts-json \documentclass{book} % Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf, % dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.