Unable to load pdf documents using recent versions of pdftop
Brought to you by:
andreasb123,
auroux
I reported the following bug in ubuntu:
https://bugs.launchpad.net/ubuntu/+source/xournal/+bug/137944
As underlined by a comment there, recent versions of pdftoppm no longer use 6 digits for the page number in the file name, but rather the number varies depending on the number of pages, resulting in xournal unable to load the pdf. Moreover, when a pdf can't be opened, an error should be reported instead of failing silently, however this is less urgent IMHO.
Logged In: YES
user_id=1482965
Originator: NO
The diff below should fix things for 0.4.0.1. I'll also upload it to the CVS.
Let me know if it works properly - both with new and with old pdftoppm.
Denis.
--- ../../xournal-0.4.0.1/src/xo-file.c 2007-08-14 22:39:30.000000000 -0400
+++ xo-file.c 2007-09-10 20:17:13.000000000 -0400
@@ -944,20 +944,21 @@
struct BgPdfPage *bgpg;
gchar *ppm_name;
GdkPixbuf *pixbuf;
+ int npad, ret;
if (bgpdf.requests == NULL) return;
req = (struct BgPdfRequest *)bgpdf.requests->data;
- ppm_name = g_strdup_printf("%s/p-%06d.ppm", bgpdf.tmpdir, req->pageno);
-// printf("Child %d finished, should look for %s... \n", pid, ppm_name);
-
- if (bgpdf.status == STATUS_ABORTED || bgpdf.status == STATUS_SHUTDOWN)
- pixbuf = NULL;
- else
- pixbuf = gdk_pixbuf_new_from_file(ppm_name, NULL);
-
- unlink(ppm_name);
- g_free(ppm_name);
+ pixbuf = NULL;
+ // pdftoppm used to generate p-nnnnnn.ppm (6 digits); new versions produce variable width
+ for (npad = 6; npad>0; npad--) {
+ ppm_name = g_strdup_printf("%s/p-%0*d.ppm", bgpdf.tmpdir, npad, req->pageno);
+ if (bgpdf.status != STATUS_ABORTED && bgpdf.status != STATUS_SHUTDOWN)
+ pixbuf = gdk_pixbuf_new_from_file(ppm_name, NULL);
+ ret = unlink(ppm_name);
+ g_free(ppm_name);
+ if (pixbuf != NULL || ret == 0) break;
+ }
if (pixbuf != NULL) { // success
// printf("success\n");
Logged In: YES
user_id=1482965
Originator: NO
Hmph, formatting not preserved... I'm attaching the diff file.
Denis.
File Added: newer-pdftoppm-bugfix.patch
patch against xo-file.c (v0.4.0.1) to fix bug with newer pdftoppm
Logged In: YES
user_id=556738
Originator: YES
Thanks for prompt reply, the patch works. Maybe it's time for a new release to fix this?
Logged In: YES
user_id=1482965
Originator: NO
I'll make a new release very soon. I also want to add the .desktop and MIME info files submitted in the "Patches" section, so I need to work a bit on the installer.
Denis.
Logged In: YES
user_id=1482965
Originator: NO
This bug should be fixed in release 0.4.1.
Denis.