Bug 695596 - document content vanishes when annotating
Summary: document content vanishes when annotating
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: iPhone All
: P4 major
Assignee: MuPDF bugs
URL:
Keywords:
: 695595 695710 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-10-13 06:02 UTC by Joseph Heenan
Modified: 2015-03-26 04:14 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments
original pdf file (71.83 KB, application/pdf)
2014-10-13 06:02 UTC, Joseph Heenan
Details
result on iPhone6 (72.39 KB, image/png)
2014-10-13 06:03 UTC, Joseph Heenan
Details
broken, annotated pdf file (156.11 KB, application/pdf)
2014-10-13 06:05 UTC, Joseph Heenan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Heenan 2014-10-13 06:02:21 UTC
Created attachment 11238 [details]
original pdf file

Seen on 1.6 iOS App Store release of mupdf, on both iphone6 and iphone6+, both running iOS 8.0.2.

Steps to reproduce:

1. Email attached document to email account accessible from iOS
2. open attachment from email
3. share->open in->mupdf
4. zoom in a little
5. draw a red line on the page
6. save document
7. reopen document

Expected result:

All PDF content shown, with annotation on top.

Actual result:

Annotation is shown okay, but some of the pdf content has vanished. (see attached screenshot)


Notes:

The original PDF file was produced by viewing http://www.artifex.com/files/ImagingScience.pdf in Safari on my mac and using it's "share->email web page" option. Don't believe that's relevant, the md5 sum seems to match the original.
Comment 1 Joseph Heenan 2014-10-13 06:03:30 UTC
Created attachment 11239 [details]
result on iPhone6
Comment 2 Joseph Heenan 2014-10-13 06:04:32 UTC
*** Bug 695595 has been marked as a duplicate of this bug. ***
Comment 3 Joseph Heenan 2014-10-13 06:05:43 UTC
Created attachment 11240 [details]
broken, annotated pdf file
Comment 4 Joseph Heenan 2014-10-13 06:19:52 UTC
Comments from Ken on IRC:

[2:11pm] kens: GS says it has an incorrect stream length and (possibly) a spurious ET operator
[2:11pm] kens: The stream seems to be borked
[2:12pm] kens: The content stream ends:
[2:12pm] kens: 117.02 702.51 l
[2:12pm] kens: 117.126 702.49 l
[2:12pm] kens: 117.231 702.464 l
[2:12pm] kens: 117.337 70endstream
[2:12pm] kens: endobj
[2:13pm] kens: Which looks wrong to me 
[2:15pm] kens: I think it may be caused by the fact that the page has several content streams
[2:16pm] kens: And they don't break in a logical place, it is busy constructing a path when it suddently stops the content stream and starts a new one, which then continues to appaend to the path.
[2:16pm] jogux: Producer: Acrobat Distiller 6.0 (Windows) ….
[2:17pm] kens: The rewritten PDF file only has one content stream for the first page, looks like it just didn't cater for the additional streams at all
Comment 5 Ken Sharp 2014-11-29 08:51:38 UTC
*** Bug 695710 has been marked as a duplicate of this bug. ***
Comment 6 zeniko 2014-12-18 12:56:13 UTC
The issue with that file is that the claimed stream length doesn't match the actual stream length. PDF readers respecting the stream length (such as Adobe Reader and MuPDF) thus omit part of the page while those who do not (such as Foxit or Firefox' pdf.js) show the full page.

It thus seems that MuPDF somehow miscalculates the stream length when recreating a stream which was broken into multiple pieces originally.
Comment 7 Robin Watts 2015-03-26 04:14:46 UTC
Fixed now, possibly by:

commit cef4820268f18f03c4407d3897abfde012e92204
Author: Tor Andersson <tor@ccxvii.net>
Date:   Sun Mar 8 18:31:22 2015 +0100

    Automatically update /Length and /Filter in pdf_update_stream.