diff options
author | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2023-04-02 15:01:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-02 15:01:26 +0200 |
commit | 230f1ab29039c30c5974d17ddcb0667ceedccf79 (patch) | |
tree | 3b1f1269122f88b316338a5c99046ae0e4077ae6 /libqpdf/qpdfjob-c.cc | |
parent | f8e39253be9d1806ccdb88d8117b7418f2045da1 (diff) | |
parent | 41f79bedbc1ebc2666471ec97b87999410242973 (diff) | |
download | qpdf-230f1ab29039c30c5974d17ddcb0667ceedccf79.tar.zst |
Merge pull request #933 from m-holger/c_job
C-API : expose QPDFJob::createQPDF and writeQPDF
Diffstat (limited to 'libqpdf/qpdfjob-c.cc')
-rw-r--r-- | libqpdf/qpdfjob-c.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libqpdf/qpdfjob-c.cc b/libqpdf/qpdfjob-c.cc index 889afec6..ddb33349 100644 --- a/libqpdf/qpdfjob-c.cc +++ b/libqpdf/qpdfjob-c.cc @@ -4,6 +4,7 @@ #include <qpdf/QPDFLogger.hh> #include <qpdf/QPDFUsage.hh> #include <qpdf/QUtil.hh> +#include <qpdf/qpdf-c_impl.hh> #include <qpdf/qpdflogger-c_impl.hh> #include <cstdio> @@ -98,6 +99,30 @@ qpdfjob_run(qpdfjob_handle j) }); } +qpdf_data +qpdfjob_create_qpdf(qpdfjob_handle j) +{ + QUtil::setLineBuf(stdout); + try { + auto qpdf = j->j.createQPDF(); + return qpdf ? new _qpdf_data(std::move(qpdf)) : nullptr; + } catch (std::exception& e) { + *j->j.getLogger()->getError() + << j->j.getMessagePrefix() << ": " << e.what() << "\n"; + } + return nullptr; +} + +int +qpdfjob_write_qpdf(qpdfjob_handle j, qpdf_data qpdf) +{ + QUtil::setLineBuf(stdout); + return wrap_qpdfjob(j, [qpdf](qpdfjob_handle jh) { + jh->j.writeQPDF(*(qpdf->qpdf)); + return jh->j.getExitCode(); + }); +} + static int run_with_handle(std::function<int(qpdfjob_handle)> fn) { |