dotnet/docfx

Generated PDF's outline/bookmarks don't link to the correct page when setting property `outline` to `DefaultOutline`

Closed this issue · 2 comments

Operation System: Windows

DocFX Version Used: 2.48.1

WkHtmlToPdf Versionj Used: 0.12.5

Template used: default

Steps to Reproduce:

  1. Download+extract attached Zip file
  2. Run build.cmd (make sure paths to wkhtmlpdf.exe + docfx.exe are in %PATH%

Expected Behavior:

Clicking on a link in the outline routes the correct page in the generated PDF

Actual Behavior:

Clicking on a link in the outline routes a wrong page in the generated PDF

Description

The attached file is based on the file from issue #4274 which has been closed, since a workaround exists (setting the outline property to WkDefaultOutline)

The proposed workaround however does introduce other problems: The outline looks a lot different from the outline generated with 'DefaultOutline' and contains a lot of items that should not be included in the outline. Also the hierarchy of the outline is broken.

This is because according to WkHtmlToPdfs docs it translates all <h?>-tags into outline items. This means, also headings and sub-headings as well as notes, tipps, warnings (which are rendered with the <h5> tag) are translated into outline items. This not only clutters the outline with a lot of entries you definitely do not want to see in an outline (the Note, Tip, Warning entries) it also kind of breaks the outline hierarchy, since there is a conflict between sub headings inside of a document and documents that are "child-documents" to a document. To demonstrate that I attached two screenshots. The first one is of the outline generated by setting the DefaultOutline-property:

DefaultOutline

The second screenshot is of the outline generated by the WkDefaultOutline:

WkDefaultOutline

As you can see the WkDefaultOutline outline puts documents Page 12 and Page 12.X onto the same level, in favor of the contents of Page 12 which are put as child elements.

Also you can see the redundant notes, warnings etc.

I also noticed, that this breaks the PDFs that you can dowload on docs.microsoft.com which are presumably also generated using DocFx (at least they look very familiar). See for example the ASP.NET docs where the outline links will send you to the wrong page.

I have the same problem. The only solution is to hide the outline using "outline": "NoOutline" which is not actually a solution.

Addressed in v2.73.0 with a new PDF engine.