Bug 691706

Summary: incorrect document outline dictionary after conversion
Product: Ghostscript Reporter: artifex
Component: PDF WriterAssignee: Alex Cherepanov <alex>
Status: NOTIFIED FIXED    
Severity: normal CC: christinedelight.top85
Priority: P2    
Version: 0.00   
Hardware: PC   
OS: Windows XP   
Customer: 870 Word Size: ---
Attachments: 123.pdf
gs_123.pdf
Patch for the issue

Description artifex 2010-10-22 11:47:02 UTC
Created attachment 6817 [details]
123.pdf

After the conversion of 123.pdf to gs_123.pdf, the document-level navigation does not work. All /Dest-entries are pointing to the first page.

GS-call:   gs -sDEVICE=pdfwrite -o gs_123.pdf
Comment 1 artifex 2010-10-22 11:48:11 UTC
Created attachment 6818 [details]
gs_123.pdf
Comment 2 Ken Sharp 2010-10-25 16:38:27 UTC
The problem seems to actually be in the PDF *interpreter* which is not passing the /Dest argument to the constructed pdfmark, which is what pdfwrite uses. Since pdfwrite isn't getting a destination, it uses the current page. Because outlines are written right at the start, the current page is always the first one.

I'll see if I can figure out what the PDF interpreter ought to be doing, so that I can pass it to Alex for approval.
Comment 3 Ken Sharp 2010-10-26 14:04:23 UTC
Created attachment 6835 [details]
Patch for the issue

The attached patch works for me. If we have a View and a Page, but no matrix (not required if we have a /View [/Fit]) then do not discard the page number but use it as a /Page argument (adding one because pdfmark starts from page 1, not 0).

I'm not absolutely sure what this PostScript is doing, or why it previously chose to discard the page number, so I've coded this in a way where it only uses the page number if its an integer (just in case there's some weird path I haven't traced). 

This resolves the reported problem for me, but this is not my code and I'm pretty hazy on what exactly its doing, so this patch needs to be reviewed by Alex before being committed, hence I'm reassigning the bug to him for review.
Comment 4 Ken Sharp 2010-10-26 14:04:58 UTC
Re-assigning to Alex as the problem is in the PDF interpreter, not the PDF writer.
Comment 5 Alex Cherepanov 2011-06-12 01:03:41 UTC
I don't have much to add to Ken's comments. The patch looks fine to me.
It's committed as a rev. 49ae789184ebb094c29b14a6778e8fa823f6637a