Bug 19915 - Saving certain forms results in empty PDFs.
Summary: Saving certain forms results in empty PDFs.
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: glib frontend (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
: 21071 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-02 11:24 UTC by Adam Buchbinder
Modified: 2010-08-09 10:11 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Affected PDF. (205.01 KB, application/pdf)
2009-02-02 11:24 UTC, Adam Buchbinder
Details
[PATCH] Set PDFDoc::errCode when saveAs() fails (1.14 KB, patch)
2009-02-22 08:06 UTC, Carlos Garcia Campos
Details | Splinter Review
[PATCH] Return an error code instead of a GBool when saving (3.34 KB, patch)
2009-02-28 04:25 UTC, Carlos Garcia Campos
Details | Splinter Review

Description Adam Buchbinder 2009-02-02 11:24:25 UTC
Created attachment 22494 [details]
Affected PDF.

Saving certain forms after filling them in results in empty PDFs. To reproduce:

Open the attached file in Evince. Fill in some form data. Save the file.

What I expected: The resultant file has size 0.

What I got: The resultant file should contain at least some data.

I'm using poppler 0ed3fd52bb2d3375ed302285b18f076721b8028e, just updated from the repo today. (I also used Cairo 1.8.4 and Evince SVN r3295, but the folks at the GNOME bugtracker assure me that it's a poppler issue.)

This was originally reported on the GNOME bugtracker:

http://bugzilla.gnome.org/show_bug.cgi?id=564268
Comment 1 Albert Astals Cid 2009-02-02 11:48:25 UTC
So you tell cairo and evince versions when reporting a poppler bug but you don't say the poppler version? ;-) Can i have it please?
Comment 2 Adam Buchbinder 2009-02-02 19:04:02 UTC
The poppler version was pulled from git today; the commit ID is specified in the report.

http://cgit.freedesktop.org/poppler/poppler/commit/?id=0ed3fd52bb2d3375ed302285b18f076721b8028e

You should be able to get the exact revision by running "git checkout 0ed3fd52bb2d3375ed302285b18f076721b8028e", I think. If you'd like me to test with a particular revision, just say so and I can do that.
Comment 3 Albert Astals Cid 2009-02-03 13:15:03 UTC
Then it's either a fault in poppler-glib bindings or evince, poppler-qt4 correctly returns false as we don't know how to modify encrypted files at the moment. So it seems either poppler-glib bindings or evince don't cope correctly with poppler core returning false on save.

Carlos can you have a look?
Comment 4 Carlos Garcia Campos 2009-02-03 23:57:55 UTC
(In reply to comment #3)
> Then it's either a fault in poppler-glib bindings or evince, poppler-qt4
> correctly returns false as we don't know how to modify encrypted files at the
> moment. So it seems either poppler-glib bindings or evince don't cope correctly
> with poppler core returning false on save.

you are right. It has to be fixed in both poppler-glib and evince then. 

> Carlos can you have a look?
> 

Yes.
Comment 5 Carlos Garcia Campos 2009-02-22 07:58:36 UTC
Well, we already check the retval, but we don't properly fill the GError, and that's why evince doesn't notice an error ocurred. The problem is that there's no way to know why saveAs() failed, it might be because the document is encrypted or because the file couldn't be open for writing. We could probably use PDFDoc::errCode, what do you think?
Comment 6 Carlos Garcia Campos 2009-02-22 08:06:51 UTC
Created attachment 23177 [details] [review]
[PATCH] Set PDFDoc::errCode when saveAs() fails

 poppler/PDFDoc.cc |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Comment 7 Albert Astals Cid 2009-02-25 14:52:51 UTC
I'm not sure i like this errCode meaning change, after all PDFDoc.h says 

  // Was PDF document successfully opened?
  GBool isOk() { return ok; }

  // Get the error code (if isOk() returns false).
  int getErrorCode() { return errCode; }

what about changing PDFDoc::saveAs to return an int?
Comment 8 Adam Buchbinder 2009-02-26 06:02:58 UTC
I tested the following setup (all checkouts were the current version as of about yesterday):

cairo eb2a73ba6d290497cabb0f917c0375eea919178e (1.9.1 series)
poppler 26a8217160c1eaeeadb92023b27e68f402e38dd0 + Carlos's patch
evince r3496

Other libraries are whatever's in the current Ubuntu 8.10 (Intrepid) distribution.

Loading, editing a form field in, then saving the affected PDF still results in a zero-byte file, with no errors reported on the command line or via the GUI. 

Oddly enough, this version of evince is supposed to deal with this situation from that end; see GNOME bug 566791, which was about the same problem, and this revision, which was included in the tested version:

http://svn.gnome.org/viewvc/evince?view=revision&revision=3493

Is the above setup working for anyone? I may be testing it wrong, but I don't think so; I'm quite sure that my testing copy of evince is linked to my testing copy of the poppler libs, and so on.

Is there any further debugging or tracing that I could do that might be of some help?
Comment 9 Carlos Garcia Campos 2009-02-26 06:10:07 UTC
(In reply to comment #8)
> I tested the following setup (all checkouts were the current version as of
> about yesterday):
> 
> cairo eb2a73ba6d290497cabb0f917c0375eea919178e (1.9.1 series)
> poppler 26a8217160c1eaeeadb92023b27e68f402e38dd0 + Carlos's patch
> evince r3496
> 
> Other libraries are whatever's in the current Ubuntu 8.10 (Intrepid)
> distribution.
> 
> Loading, editing a form field in, then saving the affected PDF still results in
> a zero-byte file, with no errors reported on the command line or via the GUI. 
>

hmm, did you run make install after updating evince? 
Comment 10 Adam Buchbinder 2009-02-26 09:21:54 UTC
>hmm, did you run make install after updating evince? 

Yes; I made a testing directory and built everything with the prefix pointing to that directory, then installed the packages. (I had to install cairo to build poppler, since poppler needs a newer version of cairo than Intrepid ships, and I had to install poppler to build evince.) I verified that the new copy of evince was using the libs I'd built before it:

$ ldd /tmp/evince-test/inst/bin/evince|egrep '(cairo|poppler)'
	libpoppler-glib.so.4 => /tmp/evince-test/inst/lib/libpoppler-glib.so.4 (0xb7a13000)
	libpoppler.so.4 => /tmp/evince-test/inst/lib/libpoppler.so.4 (0xb7856000)
	libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0xb7614000)
	libcairo.so.2 => /tmp/evince-test/inst/lib/libcairo.so.2 (0xb74e6000)

And I executed it by explicitly invoking it.

$ dpkg -l evince
ii evince 2.24.1-0ubuntu1 Document (postscript, pdf) viewer
$ /tmp/evince-test/inst/bin/evince --version
GNOME Document Viewer 2.25.91

The "Help->About" dialog also reports the newer version. Is this system working on your system? Perhaps there's another library I'd need to build to get it working, though I'm skeptical of that.
Comment 11 Carlos Garcia Campos 2009-02-28 04:25:18 UTC
Created attachment 23389 [details] [review]
[PATCH] Return an error code instead of a GBool when saving

 poppler/PDFDoc.cc |   22 +++++++++++-----------                                                                                                             
 poppler/PDFDoc.h  |    8 ++++----                                                                                                                           
 2 files changed, 15 insertions(+), 15 deletions(-)

Note that it requires changes in the frontends too, since now we are returning errNone (which is 0) when successing .
Comment 12 Albert Astals Cid 2009-03-01 14:07:52 UTC
I like this better, please commit and warn the mailing list about the change so people can update the frontends.
Comment 13 Carlos Garcia Campos 2009-03-02 01:03:33 UTC
Fixed in git master. Thanks. 
Comment 14 Adam Buchbinder 2009-03-02 10:50:22 UTC
Excellent! I pulled the current version of poppler master (de3131ae38fc9442b198d4d7b0c57c6939ad66ce), rebuilt, and now Evince prints pops up an error bar ("The file could not be saved as “file:///tmp/evince-test/FormularioTransferencia-change.pdf”. / Document is encrypted") rather than saving a zero-byte file.
Comment 15 Carlos Garcia Campos 2009-04-10 04:28:57 UTC
*** Bug 21071 has been marked as a duplicate of this bug. ***
Comment 16 freedy 2010-08-08 11:21:35 UTC
I'm having similar zero length files on what would seem to be every save as copy.

This even happens on opening a local file that was previously saved by evince. 

No error in gui or cli when this happens. 

Seems like the error trapping is no rigorous enough.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.