dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.09k stars 866 forks source link

Table of Contents and internal links in PDF fails in certain instances #4407

Closed cedar-ave closed 5 years ago

cedar-ave commented 5 years ago

Operation System: (Windows or Linux or MacOS) Windows

DocFX Version Used: 2.42

Template used: pdf.default + custom template

Steps to Reproduce: Generate multiple PDFs using docfx pdf.

Expected Behavior: Table of Contents links go to specified location within the PDF.

Actual Behavior: In some cases, Table of Contents links go nowhere. In those cases, internal links to other places in the PDF fail as well. Number of pages may be a determinant. As a very general rule based on the 20 PDFs I produced, the TOC appears to work on smaller PDFs (approx. <75 pages) and not work on larger PDFs (approx >100 pages). However there was at least 1 exception to that. File size does not seem to be a determinant.

PatrickLehnerXI commented 5 years ago

I am observing broken links in PDFs as well, with docfx 2.42.1 and wkhtmltopdf 0.12.5 (both installed via chocolatey), whereas the links work fine with docfx 2.41 and wkhtmltopdf 0.12.5

superyyrrzz commented 5 years ago

@cedar-ave @PatrickLehnerXI Can you provide some repos to help reproduce the issue?

/cc @icnocop

icnocop commented 5 years ago

It seems to be a bug in PDFSharp.

I created issue https://github.com/empira/PDFsharp/issues/84 which is related to broken links in PDFs.

It's a result of replacing iTextSharp with PDFSharp as part of https://github.com/dotnet/docfx/issues/4250. 😢

I'm wondering if we should revert the code back to iTextSharp?

Thank you.

superyyrrzz commented 5 years ago

@icnocop I'm afraid yes...

icnocop commented 5 years ago

I created PR #4467 which reverts PDFSharp back to iTextSharp.

cedar-ave commented 5 years ago

With the revert to iTextSharp is there potential for #2446 to recur? If so, I would rather experience this bug than that one.

icnocop commented 5 years ago

I think the issue where "cross-reference links often go to the middle of a section instead of top" is a bug in wkhtmltopdf.

See https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1947.

I haven't got as far as trying to compile wkhtmltopdf yet to verify the proposed fix.