diff options
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r-- | libqpdf/QPDF.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 02a003a5..2337f43d 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -11,6 +11,7 @@ #include <stdlib.h> #include <string.h> #include <memory.h> +#include <regex> #include <qpdf/QTC.hh> #include <qpdf/QUtil.hh> @@ -2742,6 +2743,24 @@ QPDF::getFilename() const return this->m->file->getName(); } +PDFVersion +QPDF::getVersionAsPDFVersion() +{ + int major = 1; + int minor = 3; + int extension_level = getExtensionLevel(); + + std::regex v("^[[:space:]]*([0-9]+)\\.([0-9]+)"); + std::smatch m; + if (std::regex_search(this->m->pdf_version, m, v)) + { + major = QUtil::string_to_int(m[1].str().c_str()); + minor = QUtil::string_to_int(m[2].str().c_str()); + } + + return PDFVersion(major, minor, extension_level); +} + std::string QPDF::getPDFVersion() const { |