Bug 143806 - Writer opens DOCX with slightly higher text spacing
Summary: Writer opens DOCX with slightly higher text spacing
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: All All
: medium minor
Assignee: Not Assigned
URL: https://preview.redd.it/c48pt7e9kig71...
Whiteboard:
Keywords: bibisected, filter:docx
Depends on: 105876
Blocks: DOCX-Floatingtable
  Show dependency treegraph
 
Reported: 2021-08-10 11:32 UTC by Meitar Bruner
Modified: 2023-08-18 13:30 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
docx file to export to PDF (42.97 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-08-10 15:18 UTC, Meitar Bruner
Details
PDF from DOCX with Word online (269.30 KB, application/pdf)
2021-08-11 20:42 UTC, Telesto
Details
The example file in Word 2013 and Writer master (168.82 KB, image/png)
2023-05-24 09:11 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Meitar Bruner 2021-08-10 11:32:37 UTC
Description:
Hi!

Im using libre office to convert docx files to PDF.

1.When I export the 'docx' file from Microsoft Word everything works perfect.

2.When I export it via LibreOffice (7.06 and also 7.15 versions) sometimes titles are "jump" to the previous page.

You can see it in the image I've attached (Ive blured the data but you can see the problem).

Am I doing something wrong? This is a huge bug for my customers.

Will be more than happy for a solution!

Steps to Reproduce:
1.Create Word docx file with multiple pages when in page 2 above there is a title in the top of the page. 
2.Send to Libre PDF export

Actual Results:
Title "jump" to bottom of previous page

Expected Results:
The PDF layout should be the same as the docx file layout 


Reproducible: Always


User Profile Reset: No



Additional Info:
Export the PDF properly
Comment 2 Roman Kuznetsov 2021-08-10 14:54:04 UTC
Can you create an example as you wrote "1.Create Word docx file with multiple pages when in page 2 above there is a title in the top of the page." and attach it here?
Comment 3 Meitar Bruner 2021-08-10 15:18:53 UTC
Created attachment 174188 [details]
docx file to export to PDF

Hi, nice to speak with you,

1.I’ve attached a docx file.
2.The file has 3 pages.
3.When you export the file to PDF via LibreOffice, the title on the 3rd page marked with yellow (‘Appendix B – Ipsum lorem Ipsum Lorem Ipsum lorem’), is “jumping” to the bottom of 2nd page.

P.S: When you export it via Microsoft Word everything is fine.

I will be more than happy to solve this somehow.

Thanks,
Meitar Bruner
Fullstack Developer
Comment 4 QA Administrators 2021-08-11 03:59:50 UTC Comment hidden (obsolete)
Comment 5 Roman Kuznetsov 2021-08-11 10:10:21 UTC
The problem isn't in the exporting to PDF. LO opens your example wrong at once and it looks differently from MS Word

Confirm in

Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: ac80ec817eb07c77a51bc0729985a473c734182e
CPU threads: 8; OS: Windows 10.0 Build 19043; UI render: Skia/Vulkan; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: threaded
Comment 6 Telesto 2021-08-11 20:41:14 UTC
Also in
4.4.7.2

and in

Versie: 4.1.0.4 
Build ID: 89ea49ddacd9aa532507cbf852f2bb22b1ace28

and in
Versie 4.0.0.3 (Bouw-id: 7545bee9c2a0782548772a21bc84a9dcc583b89)

looking ok with
LibreOffice 3.5.7.2 
Build ID: 3215f89-f603614-ab984f2-7348103-1225a5b
Comment 7 Telesto 2021-08-11 20:42:39 UTC
Created attachment 174217 [details]
PDF from DOCX with Word online
Comment 8 Meitar Bruner 2021-08-12 07:17:56 UTC
Sorry you are right. When I open the docx in LibreOffice GUI the title already jumping.

Do you know why this is happening? Can I prevent it somehow?
Unfortunately, can’t tell my customers to put page break.

A solution for this could really help!

Thanks, 
Meitar Bruner
Fullstack Developer
Comment 9 Meitar Bruner 2021-08-12 07:22:43 UTC Comment hidden (no-value)
Comment 10 Timur 2021-08-16 09:39:51 UTC
(In reply to Meitar Bruner from comment #0)
> This is a huge bug for my customers. Will be more than happy for a solution!

You may fix it yourself, pay it to be fixed (to your own or LO-certified devs) or just wait as long as it takes for a volunteer to pop in, days or decades. 
Everyone is welcome to submit a bug. But to those who urge it with "my customers need it" I think it's appropriate to advise a payment. 

After original wrong title, another wrong title is "Writer opens docx wrongly" because it should to pinpoint to the cause. Here it's a minor issue of height.

43all, commit 9eb3d13fd2ebe213dfdbd22cae8fe6c7f2998959
https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=bd6310886dc4351a8ac3ed3ee9a4f65d2a0e005c..53f661b3140fe728fe3b8f421841dcb8e6f716ab
Comment 11 Justin L 2021-08-27 05:49:08 UTC
(In reply to Meitar Bruner from comment #8)
> Do you know why this is happening?
> A solution for this could really help!

1.) Do you have the Calibri font installed on your LibreOffice system? Obviously if all the fonts used aren't installed, then spacing can be different. (I too don't own Calibri, so I don't know if that would actually help, but this seems the most likely reason.)

2.) Normally the Heading styles have turned on the "keep with next paragraph" property, so that the document knows they should not be orphaned on a previous page. (That is much better than depending on "hitting enter to get the layout you want".)

3.) And of course the advice you didn't want is the best one. You NEVER start a new page by hitting Enter 20 times. (Why would you expect good results from bad document design?)
Comment 12 Justin L 2021-08-27 07:27:25 UTC
(In reply to Timur from comment #10)
> 43all, bibisect commit 9eb3d13fd2ebe213dfdbd22cae8fe6c7f2998959

I don't think this (or any bibisect) will be useful. There are too many factors that could be at play here.

I did a side-by-side comparison of PDFs to see where the space was different. The most glaring place is between "3. SubTitle" and the (unnecessarily) floating table (already in LO 3.5). Because nearly-full-width floating tables cause so much trouble, they are in-lined in LO. However, the .43cm horizontal distance from the paragraph seems to be thrown away. (I didn't find a duplicate bug report surprisingly.)

So in this case, it seems like we need to add .43cm (plus .21 from the previous paragraph itself so that they don't merge together) onto the top margin of the table. [But that would cause HUGE problems in case text had wrapped into that space.] 

Ultimately, this is depends on bug 105876.

However, even that said, the layout is still a few twips out - and the reported problem still remains.
Comment 13 Gabor Kelemen (allotropia) 2023-05-24 09:11:20 UTC
Created attachment 187472 [details]
The example file in Word 2013 and Writer master

Now there is support for floating tables, there seems to be some problems here:
- the empty paragraph is wrapped before the table instead of after it.
- the 4. from the "4.	SUBTITLE" paragraph is wrapped to the left of the table, but the numbering should not be separated from the numbered paragraph text.

Typing a single letter into the empty paragraph however magically fixes this wrong layout: it moves below the table, the numbering is not separated and the yellow background Appendix B title appears at the top of the third page, as it should.

I remember seeing some similar bugs with images/shapes laid out on top of each other where their layout could be also improved by typing into an empty paragraph which became correctly wrapped by that - e.g. bug 137825.
Comment 14 Justin L 2023-08-18 13:30:23 UTC
Fixed via backports to LO 7.6

(In reply to Gabor Kelemen (allotropia) from comment #13)
> - the empty paragraph is wrapped before the table instead of after it.
> - the 4. from the "4.	SUBTITLE" paragraph is wrapped to the left of the
> table, but the numbering should not be separated from the numbered paragraph
> text.
Both fixed by 24.2 commit a4af5432753408c4eea8a8d56c2f48202160c5fe
Author: Miklos Vajna on Mon Jul 17 09:00:33 2023 +0200
 tdf#120262 sw floattable, legacy: fix text wrap around fly when no content fits