Bug 144989 - Exported PDF of master document with hidden sections in chapters loses pagination
Summary: Exported PDF of master document with hidden sections in chapters loses pagina...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
7.2.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: target:7.3.0 target:7.2.3
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Writer-Master-Doc
  Show dependency treegraph
 
Reported: 2021-10-08 01:34 UTC by Olivier Hallot
Modified: 2021-11-25 14:55 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Situation of correct page number of PDF toc (162.09 KB, image/png)
2021-10-08 01:34 UTC, Olivier Hallot
Details
Situation showing the issue: offset of page numbers (156.38 KB, image/png)
2021-10-08 01:34 UTC, Olivier Hallot
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Hallot 2021-10-08 01:34:03 UTC
Created attachment 175588 [details]
Situation of correct page number of PDF toc

This bug is a follow-up of bug#84913, and add sample data for testing and verification.

The zip file contains all files needed. 

https://nextcloud.documentfoundation.org/s/t4s5e3GtZe29GPN

The archive contains

GS70-GettingStarted.odm 
------------------------
* A master doc  linking all chapters.
* On page 3 of the master doc there is a string "book [0|1]. 0 or 1 is a variable field controlling hidden sections in the chapters. 
* When 'book eq 1', the chapter sections containing the heading "Copyright..." are hidden and the hidden section are not visible nor printed.
* When 'book eq 0', the chapter sections containing the heading "Copyright..." are not  hidden and are visible and printed.
* Open the master document and update the links as usual.

GS70NN-(..).odt
----------------
* Chapter files.
* All chapter files have a section with condition "book eq 1" wrapping the Copyright heading and the chapter TOC. When 'book eq 1' the section is hidden.

0.pdf
-----
A pdf file where 'book eq 0', meaning that all sections are visible.

1.pdf
-----
A pdf file where 'book eq 1', meaning all chapter's copyright + TOC are hidden.

Actual results
--------------
The screen shots shows the issue

Screenshot_0.pdf.png shows a PDF reader with PDF "Contents" on the right, accessing heading "Changing formula color". The PDF page is correctly displays showing the heading. The PDF ToC shows page 342 and the PDF page is actually 342. That is OK.

Likewise, Screenshot_1.pdf.png access heading "Changing formula color" on page 313 but the heading target is lost. The page number does not correspond to the heading "Changing formula color". Actually the "Changing formula color" heading is located in page 337 of the PDF file.

Expected results
----------------
with hidden sections actually hidden, the page numbers of the exported PDF contents right pane should point to the right page in the file. In the case above, instead of "Changing formula color" on page 313, it should be "Changing formula color" on page 337.

Note
----
The issue (page number offset) is even more visible when TOC points to the end of the PDF file, higher chapters. The issue is not visible in the beginning of the file (lower chapters)

It seems that the offset depend on the number and size of the hidden sections.
Comment 1 Olivier Hallot 2021-10-08 01:34:49 UTC
Created attachment 175589 [details]
Situation showing the issue: offset of page numbers
Comment 2 Buovjaga 2021-10-09 10:58:49 UTC
Repro (the actual page for me is 331 rather than 337).

Arch Linux 64-bit
Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: 2d9eddbb23625aad7a9accedbf69209a04169f00
CPU threads: 8; OS: Linux 5.14; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 5 October 2021
Comment 3 Buovjaga 2021-10-10 08:04:42 UTC
Bibisected the change in behaviour with linux-64-7.2 to https://git.libreoffice.org/core/commit/4184569b963877c2a488ff05766654b9db194798
sw: speed up DoIdleJobs(WORD_COUNT)

Btw. it was broken in oldest of 7.1, so it was fixed once during 7.1.
Comment 4 Commit Notification 2021-11-04 20:07:54 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/20ddabc88b6b45ea3efcc44ede5244ea526b09c4

tdf#144989 sw: disable idle jobs during printing or PDF export

It will be available in 7.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2021-11-05 08:39:22 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/73d3639304100d50422435745f8ecc7ff1583de1

tdf#144989 sw: disable idle jobs during printing or PDF export

It will be available in 7.2.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Michael Stahl (allotropia) 2021-11-05 10:04:23 UTC
thanks to buovjaga for the hint, the problem reproduces 100% of the time with kde5 vclplug, but i didn't see it with gtk3 or gen.

fixed on master.
Comment 7 Commit Notification 2021-11-06 16:02:32 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-7-2-3":

https://git.libreoffice.org/core/commit/1482b0166dda75c978752ea93b0cd9b76315d384

tdf#144989 sw: disable idle jobs during printing or PDF export

It will be available in 7.2.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Buovjaga 2021-11-25 14:55:03 UTC
Verified, thanks

Arch Linux 64-bit
Version: 7.3.0.0.alpha1+ / LibreOffice Community
Build ID: 8c66455df8f6a26c314290f252bedbc19db6b327
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 25 November 2021