mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Tidy pdf-attach-file example
This commit is contained in:
parent
56b4d5a610
commit
527810e939
@ -11,7 +11,8 @@
|
|||||||
// This example attaches a file to an input file, adds a page to the
|
// This example attaches a file to an input file, adds a page to the
|
||||||
// beginning of the file that includes a file attachment annotation,
|
// beginning of the file that includes a file attachment annotation,
|
||||||
// and writes the result to an output file. It also illustrates a
|
// and writes the result to an output file. It also illustrates a
|
||||||
// number of new API calls that were added in qpdf 10.2.
|
// number of new API calls that were added in qpdf 10.2 as well as
|
||||||
|
// the use of the qpdf literal syntax introduced in qpdf 10.6.
|
||||||
//
|
//
|
||||||
|
|
||||||
static char const* whoami = 0;
|
static char const* whoami = 0;
|
||||||
@ -24,8 +25,8 @@ static void usage(std::string const& msg)
|
|||||||
<< " --infile infile.pdf" << std::endl
|
<< " --infile infile.pdf" << std::endl
|
||||||
<< " --outfile outfile.pdf" << std::endl
|
<< " --outfile outfile.pdf" << std::endl
|
||||||
<< " --attachment attachment" << std::endl
|
<< " --attachment attachment" << std::endl
|
||||||
<< " [ --password infile-password ]" << std::endl
|
<< " [--password infile-password]" << std::endl
|
||||||
<< " [ --mimetype attachment mime type ]" << std::endl;
|
<< " [--mimetype attachment mime type]" << std::endl;
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,9 +91,16 @@ static void process(char const* infilename, char const* password,
|
|||||||
"0 0 20 20 re\n"
|
"0 0 20 20 re\n"
|
||||||
"S\n");
|
"S\n");
|
||||||
auto apdict = ap.getDict();
|
auto apdict = ap.getDict();
|
||||||
apdict.replaceKey("/Resources", QPDFObjectHandle::newDictionary());
|
|
||||||
apdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"));
|
// The following four lines demonstrate the use of the qpdf literal syntax
|
||||||
apdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form"));
|
// introduced in qpdf 10.6. They could have been written as:
|
||||||
|
// apdict.replaceKey("/Resources", QPDFObjectHandle::newDictionary());
|
||||||
|
// apdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"));
|
||||||
|
// apdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form"));
|
||||||
|
// apdict.replaceKey("/BBox", QPDFObjectHandle::parse("[ 0 0 20 20 ]"));
|
||||||
|
apdict.replaceKey("/Resources", "<< >>"_qpdf"");
|
||||||
|
apdict.replaceKey("/Type", "/XObject"_qpdf);
|
||||||
|
apdict.replaceKey("/Subtype", "/Form"_qpdf);
|
||||||
apdict.replaceKey("/BBox", "[ 0 0 20 20 ]"_qpdf);
|
apdict.replaceKey("/BBox", "[ 0 0 20 20 ]"_qpdf);
|
||||||
auto annot = q.makeIndirectObject(
|
auto annot = q.makeIndirectObject(
|
||||||
QPDFObjectHandle::parse(
|
QPDFObjectHandle::parse(
|
||||||
|
Loading…
Reference in New Issue
Block a user