Compiled Scrivener links miss targets (or become non-links)

gr's Avatar

gr

Dec 20, 2016 @ 07:07 AM

I have a case where a set of Scrivener links, which correctly target their docs inside Scrivener, produce links on compile that target the wrong pages in the output PDF. The links are missing their targets not just by a little. In a thousand page pdf, the links may miss their targets by, say, a hundred pages.

The Scriv links were made with Copy Documents as TOC. Have also reproduced with Copy Documents as Structured Link List.
The pages containing the links had a custom section format, but have successfully reproduced with As-Is.

The project where this came up is a long, complex preexisting project that I was adapting to Scriv3.0's compile regimen, but I have reproduced the phenomenon in a new project as well.

STEPS: Make new project. I copied some 30 simple docs from another project to make some content in the new project. Set these all to a new Section Style, 'Content'. Select all the docs in the binder, and Copy Special in either way as above. Make a new document and paste. In compile dialog, go in and duplicate the default Scriv template, so you can add a section format: create a new section format called 'PageBreakBefore' which is set to include the text of the document and has page-break-before (i.e. separator before and between sections set to Page Break). Map the Content section type to this new section format. Map the document with the scrivener links in it to as-is. Compile to pdf. In the resulting PDF, go to the place where all the Scriv links are and click some to see the mismatch. I have attached a sample pdf output.

I find that if I go back in and map the content section type to as-is (hence no page break), it sometimes comes out right -- but it is just as likely that the Scriv links do not get rendered as links at all in the pdf.* Pdf attached for this result too.

-g

  • Sometimes I get an odd mix of some of them turning out as links and some not.

MacBook Pro, latest Sierra, using Scriv3b-161216

  1. 1 Posted by keith on Dec 20, 2016 @ 01:28 PM

    keith's Avatar

    Great, many thanks for the sample project. This was in fact a fairly simple bug to fix once I'd worked out what was going on. If you go through the last couple or three pages of your PDF file - the ones that should contain the links - and try clicking around, what you will find is that the links have all be placed one page off from where they should be. So, the big blank area on the last page (63) is actually full of links - links that should be attached to page 62. And all the links at the top of page 61 don't work because the links on that page should be attached to page 60, where the links start over halfway down the page.

    This comes down to how PDF file links work and some changes in Scrivener 3.0. To attach links in PDF files, you say, "attach a link to page X on page Y, and the link should be in this box here" (where the box matches a range of text). The bug is causing all of those link boxes to be placed one page off in your document. And this is because page generation for printing and PDF files in Scrivener 3.0 is much more complex than it was in 2.x. It inserts gaps between pages for recto and verso control where necessary, and hides unintended blank pages from the print behind the scenes. So, what's happening in your case is that page layout has generated an unwanted blank page in the background layout which is suppressed for the print/PDF generation. But the code that sets up the links was using the old, 2.x way of getting the correct page number for the link placement and so not accounting for this suppressed (unwanted) page.

    I've updated the code to use the new, more correct method, which solves the problem for the next beta.

    Thanks and all the best,
    Keith

  2. keith closed this discussion on Dec 20, 2016 @ 01:28 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac