mirror of https://github.com/qpdf/qpdf.git
QPDFJob json: make removeAttachment take an array (fixes #693)
This commit is contained in:
parent
63c5a56f38
commit
d0b7cc8ac6
|
@ -1,5 +1,10 @@
|
|||
2022-04-24 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* Bug fix: "removeAttachment" in the job JSON now takes an array
|
||||
of strings instead of a string. It should have taken an array of
|
||||
strings since the corresponding command-line argument,
|
||||
--remove-attachment, is repeatable. Fixes #693.
|
||||
|
||||
* Deprecate QPDFObjectHandle::replaceOrRemoveKey -- it does and
|
||||
always has done the same thing as replaceKey.
|
||||
|
||||
|
|
8
job.sums
8
job.sums
|
@ -6,12 +6,12 @@ include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a3
|
|||
include/qpdf/auto_job_c_main.hh 4ba9bcb8be945f6a3ffa0df3becdb8488b6eaf45dd914d8b714d948e17b5ad5d
|
||||
include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c18911614fe8e568ec
|
||||
include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1
|
||||
job.yml 06a0b29f63c1622a0c6270d15d848a42084a6424e4b98d5d4942a8ec903b7a70
|
||||
job.yml c2937bb06818fc3bffe54c6c069a4a06db7f3c841958c2da1b2f4a33978fd24a
|
||||
libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df
|
||||
libqpdf/qpdf/auto_job_help.hh a7d7edc3b270f2488778426646bb68dcad036727db4be87d1da9993e2a007634
|
||||
libqpdf/qpdf/auto_job_init.hh 6bd71c2ae4ba80e81fe5ae5517ba72abf53a3146f66864f99eeebc7d224998a5
|
||||
libqpdf/qpdf/auto_job_json_decl.hh 30058d744cfb0d1b5e5bd2830e1c7b24713ee39c97c4ccb723dbbae1f9fab61c
|
||||
libqpdf/qpdf/auto_job_json_init.hh d3885830362c4337822bf9bc3d177b50149ba403a26de0e69d37f7751cb5d538
|
||||
libqpdf/qpdf/auto_job_schema.hh 18a3780671d95224cb9a27dcac627c421cae509d59f33a63e6bda0ab53cce923
|
||||
libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297
|
||||
libqpdf/qpdf/auto_job_json_init.hh 06d51f11c117011256e175386eee9946441f3c22b49dd91fc591bbc1fa3bbeec
|
||||
libqpdf/qpdf/auto_job_schema.hh 43273b9edfc48b1f4cccbff1d2b31916a9057c474ef97d2936b2f1f14170885b
|
||||
manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3
|
||||
manual/cli.rst aa44cbe7b6281ee05dc8b19ee1b12ca770503681ffc8ba90e795fc3c3b55153d
|
||||
|
|
1
job.yml
1
job.yml
|
@ -372,6 +372,7 @@ json:
|
|||
moddate:
|
||||
replace:
|
||||
remove-attachment:
|
||||
- null
|
||||
copy-attachments-from:
|
||||
- _file: "file to copy attachments from"
|
||||
CopyAtt.password:
|
||||
|
|
|
@ -412,6 +412,17 @@ Handlers::setupAddAttachmentFile()
|
|||
addParameter([this](char const* p) { c_att->file(p); });
|
||||
}
|
||||
|
||||
void
|
||||
Handlers::beginRemoveAttachmentArray(JSON)
|
||||
{
|
||||
// nothing needed
|
||||
}
|
||||
|
||||
void
|
||||
Handlers::endRemoveAttachmentArray()
|
||||
{
|
||||
// nothing needed
|
||||
}
|
||||
void
|
||||
Handlers::beginCopyAttachmentsFromArray(JSON)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,8 @@ void endAddAttachmentArray();
|
|||
void beginAddAttachment(JSON);
|
||||
void endAddAttachment();
|
||||
void setupAddAttachmentFile();
|
||||
void beginRemoveAttachmentArray(JSON);
|
||||
void endRemoveAttachmentArray();
|
||||
void beginCopyAttachmentsFromArray(JSON);
|
||||
void endCopyAttachmentsFromArray();
|
||||
void beginCopyAttachmentsFrom(JSON);
|
||||
|
|
|
@ -327,7 +327,9 @@ popHandler(); // key: replace
|
|||
popHandler(); // array: .addAttachment[]
|
||||
popHandler(); // key: addAttachment
|
||||
pushKey("removeAttachment");
|
||||
beginArray(bindJSON(&Handlers::beginRemoveAttachmentArray), bindBare(&Handlers::endRemoveAttachmentArray)); // .removeAttachment[]
|
||||
addParameter([this](std::string const& p) { c_main->removeAttachment(p); });
|
||||
popHandler(); // array: .removeAttachment[]
|
||||
popHandler(); // key: removeAttachment
|
||||
pushKey("copyAttachmentsFrom");
|
||||
beginArray(bindJSON(&Handlers::beginCopyAttachmentsFromArray), bindBare(&Handlers::endCopyAttachmentsFromArray)); // .copyAttachmentsFrom[]
|
||||
|
|
|
@ -111,7 +111,9 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
|
|||
"replace": "replace attachment with same key"
|
||||
}
|
||||
],
|
||||
"removeAttachment": "remove an embedded file",
|
||||
"removeAttachment": [
|
||||
"remove an embedded file"
|
||||
],
|
||||
"copyAttachmentsFrom": [
|
||||
{
|
||||
"file": "file to copy attachments from",
|
||||
|
|
|
@ -723,7 +723,7 @@ $td->runtest("check overlay with no resources output",
|
|||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- File Attachments ---");
|
||||
$n_tests += 33;
|
||||
$n_tests += 37;
|
||||
|
||||
open(F, ">auto-txt") or die;
|
||||
print F "from file";
|
||||
|
@ -907,6 +907,25 @@ $td->runtest("check dates",
|
|||
{$td->REGEXP => ".*CreationDate \\(D:\\d+.*ModDate \\(D:\\d+.*",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("remove multiple attachments",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --verbose --static-id add-attachments-1.pdf a.pdf" .
|
||||
" --remove-attachment=auto-1 --remove-attachment=auto-Two"},
|
||||
{$td->FILE => "remove-multiple-attachments.out",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("check output",
|
||||
{$td->FILE => "a.pdf"},
|
||||
{$td->FILE => "remove-multiple-attachments.pdf"});
|
||||
$td->runtest("remove multiple attachments (json)",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --job-json-file=remove-multiple-attachments.json"},
|
||||
{$td->FILE => "remove-multiple-attachments-json.out",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("check output",
|
||||
{$td->FILE => "b.pdf"},
|
||||
{$td->FILE => "remove-multiple-attachments.pdf"});
|
||||
|
||||
show_ntests();
|
||||
# ----------
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
qpdf: removed attachment auto-1
|
||||
qpdf: removed attachment auto-Two
|
||||
qpdf: wrote file b.pdf
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"verbose": "",
|
||||
"staticId": "",
|
||||
"inputFile": "add-attachments-1.pdf",
|
||||
"outputFile": "b.pdf",
|
||||
"removeAttachment": [
|
||||
"auto-1",
|
||||
"auto-Two"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
qpdf: removed attachment auto-1
|
||||
qpdf: removed attachment auto-Two
|
||||
qpdf: wrote file a.pdf
|
Binary file not shown.
Loading…
Reference in New Issue