I don't have access to Poppler sources, so I'll just remind folks that as of 
PDF 1.4 the version can come from /Version key in the Catalog as well.  Be sure 
to check that.

Leonard

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Pino Toscano
Sent: Sunday, August 16, 2009 7:05 PM
To: [email protected]
Subject: [poppler] 3 commits - qt4/src qt4/tests qt/poppler-document.cc 
qt/poppler-qt.h

 qt/poppler-document.cc       |    8 ++++++++
 qt/poppler-qt.h              |   12 ++++++++++++
 qt4/src/poppler-document.cc  |    8 ++++++++
 qt4/src/poppler-qt4.h        |   18 +++++++++++++++++-
 qt4/tests/check_metadata.cpp |    4 ++++
 5 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit 1b5612841b0c663f6d391d4581f65f68a2975db0
Author: Pino Toscano <[email protected]>
Date:   Mon Aug 17 01:04:04 2009 +0200

    [Qt] add Document::getPdfVersion(int *major, int *minor) for the document 
PDF version numbers
    
    This new function reads the version of the PDF specification of the 
document, putting major and minor numbers in own variables.

diff --git a/qt/poppler-document.cc b/qt/poppler-document.cc
index fe74676..bade1d1 100644
--- a/qt/poppler-document.cc
+++ b/qt/poppler-document.cc
@@ -273,6 +273,14 @@ double Document::getPDFVersion() const
   return data->doc.getPDFMajorVersion () + data->doc.getPDFMinorVersion() / 
10.0;
 }
 
+void Document::getPdfVersion(int *major, int *minor) const
+{
+  if (major)
+    *major = data->doc.getPDFMajorVersion();
+  if (minor)
+    *minor = data->doc.getPDFMinorVersion();
+}
+
 QDomDocument *Document::toc() const
 {
   Outline * outline = data->doc.getOutline();
diff --git a/qt/poppler-qt.h b/qt/poppler-qt.h
index e649d79..a6b1e6e 100644
--- a/qt/poppler-qt.h
+++ b/qt/poppler-qt.h
@@ -238,6 +238,18 @@ public:
   bool okToCopy() const;
   bool okToAddNotes() const;
   double getPDFVersion() const;
+  /**
+    The version of the PDF specification that the document
+    conforms to
+
+    \param major an optional pointer to a variable where store the
+    "major" number of the version
+    \param minor an optional pointer to a variable where store the
+    "minor" number of the version
+
+    \since 0.12
+  */
+  void getPdfVersion(int *major, int *minor) const;
 
   bool print(const QString &fileName, QValueList<int> pageList, double hDPI, 
double vDPI, int rotate);
 
commit aef8ecda1e80b921228f415a53c9c5a52df87d94
Author: Pino Toscano <[email protected]>
Date:   Mon Aug 17 00:57:08 2009 +0200

    [Qt4] deprecate Document::pdfVersion()
    
    ... in favour of getPdfVersion()

diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index eaf35ec..f8a9a07 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -935,8 +935,11 @@ QString subject = m_doc->info("Subject");
        /**
           The version of the PDF specification that the document
           conforms to
+
+          \deprecated use getPdfVersion and avoid float point
+          comparisons/handling
        */
-       double pdfVersion() const;
+       Q_DECL_DEPRECATED double pdfVersion() const;
 
        /**
           The version of the PDF specification that the document
commit 830140f70e48e8033ad4411b6bd405d5ad7358a3
Author: Pino Toscano <[email protected]>
Date:   Mon Aug 17 00:51:13 2009 +0200

    [Qt4] add Document::getPdfVersion(int *major, int *minor) for the document 
PDF version numbers
    
    This new function reads the version of the PDF specification of the 
document, putting major and minor numbers in own variables.
    Add them to the relative unit test.

diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index 3e4b086..1e4715e 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -382,6 +382,14 @@ namespace Poppler {
        return m_doc->doc->getPDFMajorVersion () + 
m_doc->doc->getPDFMinorVersion() / 10.0;
     }
 
+    void Document::getPdfVersion(int *major, int *minor) const
+    {
+       if (major)
+           *major = m_doc->doc->getPDFMajorVersion();
+       if (minor)
+           *minor = m_doc->doc->getPDFMinorVersion();
+    }
+
     Page *Document::page(const QString &label) const
     {
        GooString label_g(label.toAscii().data());
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index 776ef63..eaf35ec 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -937,6 +937,19 @@ QString subject = m_doc->info("Subject");
           conforms to
        */
        double pdfVersion() const;
+
+       /**
+          The version of the PDF specification that the document
+          conforms to
+
+          \param major an optional pointer to a variable where store the
+          "major" number of the version
+          \param minor an optional pointer to a variable where store the
+          "minor" number of the version
+
+          \since 0.12
+       */
+       void getPdfVersion(int *major, int *minor) const;
   
        /**
           The fonts within the PDF document.
diff --git a/qt4/tests/check_metadata.cpp b/qt4/tests/check_metadata.cpp
index a1e7ea6..48f05a6 100644
--- a/qt4/tests/check_metadata.cpp
+++ b/qt4/tests/check_metadata.cpp
@@ -213,6 +213,10 @@ void TestMetaData::checkVersion()
     QVERIFY( doc );
 
     QCOMPARE( doc->pdfVersion(), 1.6 );
+    int major = 0, minor = 0;
+    doc->getPdfVersion( &major, &minor );
+    QCOMPARE( major, 1 );
+    QCOMPARE( minor, 6 );
 
     delete doc;
 }
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to