aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-02-08 17:07:37 +0100
committerJay Berkenbilt <ejb@ql.org>2022-02-08 18:34:14 +0100
commitcfd5147d922ee4e29e10f116dfca79325398a6db (patch)
treedc2742d54e9fdec9bc170ba677be0e8861f63766 /libqpdf/QPDF.cc
parent8082af09bea1132cecc2d148eeb23bc05e66f6b2 (diff)
downloadqpdf-cfd5147d922ee4e29e10f116dfca79325398a6db.tar.zst
Add QPDF::getVersionAsPDFVersion
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc19
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
{