After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 641842 - Should use poppler-glib instead of poppler internal API
Should use poppler-glib instead of poppler internal API
Status: RESOLVED FIXED
Product: gnome-commander
Classification: Other
Component: metadata-tags
unspecified
Other Linux
: Normal normal
: 2.0
Assigned To: GNOME Commander maintainer(s)
epiotr
Depends on:
Blocks:
 
 
Reported: 2011-02-08 16:48 UTC by Carlos Garcia Campos
Modified: 2014-03-19 15:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
First raw patch for switch to poppler-glib (11.49 KB, patch)
2011-03-17 14:28 UTC, Pino Toscano
none Details | Review

Description Carlos Garcia Campos 2011-02-08 16:48:23 UTC
Poppler internal API is public, but it's considered private and with no API/ABI stability 
guarantees.
Comment 1 epiotr 2011-02-08 20:44:32 UTC
I'd gladly move to glib API, but unfortunately poppler_document_get_*() functions are available only since version 0.16 (Dec 2010). Moreover the current API doesn't provide means (or at least I can't do this with glib API ;o) for extracting the following info:


    f->metadata->addf(TAG_PDF_PRINTING, "%u", doc.okToPrint());
    f->metadata->addf(TAG_PDF_HIRESPRINTING, "%u", doc.okToPrintHighRes());
    f->metadata->addf(TAG_PDF_MODIFYING, "%u", doc.okToChange());
    f->metadata->addf(TAG_PDF_COPYING, "%u", doc.okToCopy());
    f->metadata->addf(TAG_PDF_COMMENTING, "%u", doc.okToAddNotes());
    f->metadata->addf(TAG_PDF_FORMFILLING, "%u", doc.okToFillForm());
    f->metadata->addf(TAG_PDF_ACCESSIBILITYSUPPORT, "%u", doc.okToAccessibility());
    f->metadata->addf(TAG_PDF_DOCASSEMBLY, "%u", doc.okToAssemble());
 

So, I'm parking this report this problem for a time.
Comment 2 Carlos Garcia Campos 2011-02-09 08:10:57 UTC
Accessors were added in 0.16 but the properties have been there for a long time, you can use g_object_get(). There's permissions property, see: 

http://library.gnome.org/devel/poppler/unstable/PopplerDocument.html#PopplerDocument--permissions

it doesn't support all flags exported by the core api, though. See:

http://library.gnome.org/devel/poppler/unstable/PopplerDocument.html#PopplerPermissions

Please, when there's a missing feature in poppler glib, file a bug report instead of using core api.
Comment 3 Pino Toscano 2011-03-17 14:28:47 UTC
Created attachment 183631 [details] [review]
First raw patch for switch to poppler-glib

This is a very raw porting patch from poppler (core) to poppler-glib.

Some notes:
- I'm not a glib developer, so I can do errors wrt glib API
- the TAG_PDF_HIRESPRINTING, TAG_PDF_ACCESSIBILITYSUPPORT and TAG_PDF_DOCASSEMBLY information/permissions are not available now, as they are not exposed by poppler-glib (as already pointed out)
- if a document is encrypted its loading fails, and only the TAG_DOC_SECURITY is added (set to "1")
- if there are attachments, reading its number requires reading all of them
- I did not looked at the actual versions of functions of glib and poppler I used (hence whether they match the version requirements in configure.in)
- I tested this patch against gnome-commander 1.2.8.10, but the patch applies cleanly (with just a line offset) on master
Comment 4 Pino Toscano 2011-03-17 14:40:59 UTC
Another note I forgot above:
- the "linearized" property now is a "yes"/"no" (unlocalized) string rather than "1"/"0", not sure how to deal with it
Comment 5 Pino Toscano 2011-08-18 14:58:15 UTC
Ping?
The unstable poppler 0.17.2 shoul contain all the features needed, could you please test it?
You can use the macro POPPLER_CHECK_VERSION to compile some code optionally depending on the poppler-glib version, to avoid depending on unstable poppler version.
It would really be nice to have one application less using the private poppler core, in favour of a more stable poppler-glib. Thanks.
Comment 6 Carlos Garcia Campos 2012-02-12 11:44:38 UTC
Review of attachment 183631 [details] [review]:

::: configure.in
@@ +236,3 @@
 have_pdf=no
 if test x$with_poppler != xno; then
+    PKG_CHECK_MODULES(POPPLER, poppler-glib >= $POPPLER_REQ, have_pdf=yes, have_pdf=no)

I would also bump poppler requirements to 0.18, since it's the lates stable version and the once gnome currently depends on.

@@ +31,2 @@
 #ifdef HAVE_PDF
+#include <poppler/glib/poppler.h>

#include <poppler.h>

@@ +57,1 @@
+    metadata.add(tag, buf);

Maybe you need to check if localtime is present and make sure the string is utf8 encoded. In poppler-glib-demo we have this code:

gchar *
pgd_format_date (time_t utime)
{
 	time_t time = (time_t) utime;
        char s[256];
        const char *fmt_hack = "%c";
        size_t len;
#ifdef HAVE_LOCALTIME_R
        struct tm t;
        if (time == 0 || !localtime_r (&time, &t)) return NULL;
	len = strftime (s, sizeof (s), fmt_hack, &t);
#else
        struct tm *t;
        if (time == 0 || !(t = localtime (&time)) ) return NULL;
        len = strftime (s, sizeof (s), fmt_hack, t);
#endif

        if (len == 0 || s[0] == '\0') return NULL;

        return g_locale_to_utf8 (s, -1, NULL, NULL, NULL);
}

@@ +216,3 @@
+    if (error)
+    {
+        g_free(error);

g_error_free(error); You should free to uri here too.

@@ +228,3 @@
+            f->metadata->addf(TAG_DOC_SECURITY, "%u", 1);
+        }
+        g_free(error);

g_error_free(error);

@@ +234,3 @@
     f->metadata->mark_as_accessed(TAG_DOC);
 
+    gchar *title, *author, *subject, *keywords, *creator, *producer, *linearized;

linearized is boolean in newer poppler

@@ +258,3 @@
+
+    f->metadata->add(TAG_PDF_OPTIMIZED, linearized);
+    g_free(linearized);

Use POPPLER_CHECK_VERSION or bump requirements to 0.18 and use a boolean instead.

@@ +270,3 @@
+    f->metadata->addf(TAG_PDF_HIRESPRINTING, "%u", enum_bit_to_01(permissions, POPPLER_PERMISSIONS_OK_TO_PRINT_HIGH_RES));
+    f->metadata->addf(TAG_PDF_ACCESSIBILITYSUPPORT, "%u", enum_bit_to_01(permissions, POPPLER_PERMISSIONS_OK_TO_ACCESSIBILITY));
+    f->metadata->addf(TAG_PDF_DOCASSEMBLY, "%u", enum_bit_to_01(permissions, POPPLER_PERMISSIONS_OK_TO_ASSEMBLE));

POPPLER_PERMISSIONS_OK_TO_EXTRACT_CONTENTS, POPPLER_PERMISSIONS_OK_TO_ASSEMBLE and POPPLER_PERMISSIONS_OK_TO_PRINT_HIGH_RESOLUTION are now present in poppler 0.18 too.
Comment 7 Pino Toscano 2014-01-24 21:55:13 UTC
Ping?
gnome-commanders people, can you please switch to poppler-glib and finally end the compatibility mess with the private libpoppler?

Thanks
Comment 8 Uwe Scholz 2014-01-26 19:46:50 UTC
Hi Pino,

because of the death of Piotr (see gcmd home page), it is planned to publish a new release soon, with all the features already implemented by Piotr and others. 

Please forgive me that further code development goes slowly. I'm the new maintainer only for a view weeks now. But any help in development is very, very welcome! I noticed the patch provided above but didn't find the time to test and commit it.

Nevertheless, transition to poppler-glib will happen in one of the next releases, I think. At least, it is on my ToDo list...
Comment 9 Uwe Scholz 2014-03-19 10:44:20 UTC
This problem has been fixed in our software repository. The fix will go into
the next release, v1.4.1. Thank you for your bug report and your patience.
Comment 10 Pino Toscano 2014-03-19 15:32:53 UTC
(In reply to comment #9)
> This problem has been fixed in our software repository. The fix will go into
> the next release, v1.4.1. Thank you for your bug report and your patience.

Thanks!!!

Just a small cleanup note: you can remove the two POPPLER_HAS_SET_ERROR_CALLBACK and POPPLER_HAS_GOFFSET checks in configure.ac, since they are no more needed now.