2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Tidy qpdfjob-remove-annotations example

This commit is contained in:
m-holger 2024-07-21 18:52:25 +01:00
parent b3ab5cd216
commit fe46d0fbb4

View File

@ -15,15 +15,15 @@ static char const* whoami = nullptr;
static void static void
usageExit(std::string const& msg) usageExit(std::string const& msg)
{ {
std::cerr << std::endl std::cerr << '\n'
<< whoami << ": " << msg << std::endl << whoami << ": " << msg << '\n'
<< std::endl << '\n'
<< "For help:" << std::endl << "For help:\n"
<< " " << whoami << " --help=usage usage information" << std::endl << " " << whoami << " --help=usage usage information\n"
<< " " << whoami << " --help=topic help on a topic" << std::endl << " " << whoami << " --help=topic help on a topic\n"
<< " " << whoami << " --help=--option help on an option" << std::endl << " " << whoami << " --help=--option help on an option\n"
<< " " << whoami << " --help general help and a topic list" << std::endl << " " << whoami << " --help general help and a topic list\n"
<< std::endl; << '\n';
exit(QPDFJob::EXIT_ERROR); exit(QPDFJob::EXIT_ERROR);
} }
@ -40,13 +40,13 @@ realmain(int argc, char* argv[])
auto qpdf_sp = j.createQPDF(); auto qpdf_sp = j.createQPDF();
auto& pdf = *qpdf_sp; auto& pdf = *qpdf_sp;
for (auto page: pdf.getAllPages()) { for (auto page: pdf.getAllPages()) {
page.replaceKey("/Annots", "null"_qpdf); page.removeKey("/Annots");
} }
j.writeQPDF(pdf); j.writeQPDF(pdf);
} catch (QPDFUsage& e) { } catch (QPDFUsage& e) {
usageExit(e.what()); usageExit(e.what());
} catch (std::exception& e) { } catch (std::exception& e) {
std::cerr << whoami << ": " << e.what() << std::endl; std::cerr << whoami << ": " << e.what() << '\n';
return QPDFJob::EXIT_ERROR; return QPDFJob::EXIT_ERROR;
} }
return j.getExitCode(); return j.getExitCode();