I've received reports of PDF backgrounds failing to load properly with the most recent versions of some distributions (ArchLinux, Gentoo): the background stays gray. Tyler Lawson has diagnosed the problem as an issue with GTK2 settings, which prevents gdk-pixbuf from being able to correctly load PPM files. He suggests recompiling GTK2 with the proper settings. I'd encourage anyone concerned to file a bug-report with their distribution's GTK2 package maintainers.
I'll be working on a fix on the xournal side.
Denis
------------- e-mail from Tyler Lawson -----------
I ran across an issue affecting Xournal's ability to annotate PDF files
recently, and thought I would inform you to perhaps save you some work.
I'm running Arch Linux with gtk2-2.14.7 and this problem may start popping
up in more mainstream distributions shortly.
The issue is that ppm files cannot be loaded. gdk_pixbuf_new_from_file()
ultimately loads the file into memory and passes it to gio to determine
the mime-type; however, the header for a ppm is so rudimentary that gio
can't determine the type without knowing the file extension, and returns
application/octet-stream. This is ironic behavior when you started by
passing the filename to gdk.
You can disable this behaviour by recompiling gtk2 without the line
#define GDK_PIXBUF_USE_GIO_MIME 1
in the "configure" script; this is the quickest fix that I know, since
other fixes would seem to require either changing gdk_pixbuf_new_from_file
to pass the filename or changing gio's logic for detecting pixmaps.
I'll submit a bug about this, but I thought I would let you know in case
someone else asks or you want to implement a workaround (like converting
the ppms to another format).
Tyler Lawson
Proposed patch:
diff ~/prog/xournal-0.4.2.1/src/xo-file.c ./xo-file.c
990c990,1001
< pixbuf = gdk_pixbuf_new_from_file(ppm_name, NULL);
---
> { // workaround for PPM loading issue in recent GTK
> gchar *buf;
> gsize count;
> GdkPixbufLoader *loader = gdk_pixbuf_loader_new_with_type("pnm", NULL);
> if (loader!=NULL && g_file_get_contents(ppm_name, &buf, &count, NULL))
> {
> gdk_pixbuf_loader_write(loader, buf, count, NULL);
> pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
> gdk_pixbuf_loader_close(loader, NULL);
> g_free(buf);
> }
> }
I'd appreciate any reports from people affected by the issue about whether this solved things without having to recompile GTK.
The patch did indeed fix the issue without having to recompile GTK (running Arch Linux). Thanks!
There has been more positive feedback about the patch in the Gentoo bugtracker. auroux, will you roll a new release once this is committed?
Eventually yes there'll be a new release, but not right now. The next few weeks are really hectic for me, and I won't have time to make a clean package. In the short term it's probably better if you work on getting Gentoo (and any other affected distribution) to re-release the package with the patch, without waiting for me to make it official.
Denis
Proposed patch worked for me. Many thanks, now I can comment thesis works with ease again.
Jari
I can confirm, that the proposed patch also worked for me.
Arch Linux, x86_64.
Thank you very much.
Tom
Thanks for the patch. I came across this problem today after a Gentoo update over the weekend. Gentoo users need to xournal-0.4.2.1-r1 which hasn't made it into the stable branch yet (put "app-text/xournal ~x86" in /usr/portage/package.keywords for the time being). This works for me with the current stable gtk+-2.14.7-r2 .
This issue is not fixed for me.
I am running xournal 0.4.2.1 with GTK 2.14.7 and xpdf 3.02 (comes with pdftoppm). When I try to load a PDF to annotate it, the background does not get loaded (but I still see the lined paper background).
When running xournal from the command line, I don't see any debug output, other than a standard GTK warning message:
Gtk-WARNING **: GtkSpinButton: setting an adjustment with non-zero page size is deprecated
> This issue is not fixed for me.
Have you incorporated the patch proposed below to xo-file.c (in the bottom-most comment), or recompiled gtk2 without the #define mentioned above? Which distribution are you using?
Denis
From rudiw's comment I inferred that 0.4.2.1 already had the patch incorporated into it. I just tried the patch to xo-file.c and it does indeed fix the issue. Sorry about the noise auroux.
And if you still care about this, I am using crux. Xournal is not offered as a package in crux; I had to write my own.
Release 0.4.5 should fix this problem (it doesn't rely on pdftoppm anymore).
Denis