Bug 153974

Summary: Wrong choice of page margins when importing a PDF with a shape
Product: LibreOffice Reporter: Eyal Rozenberg <eyalroz1>
Component: DrawAssignee: Not Assigned <libreoffice-bugs>
Status: UNCONFIRMED ---    
Severity: minor CC: ilmari.lauhakangas, kira.tubo
Priority: medium    
Version: 3.5.0 release   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 99746    
Attachments: Writer-exported PDF with wrong margins
The original Writer document
PDF export with LTR
original writer file with rectangle shape
rectangle exported pdf

Description Eyal Rozenberg 2023-03-04 20:21:22 UTC
Created attachment 185756 [details]
Writer-exported PDF with wrong margins

Consider the attached PDF, exported from Writer. It has A4 paper size, one RTL paragraph (with LTR text), and a horizontal line between the text boundaries. Its margins are 2 cm on each side.

However, when we open the document in Draw, we get margins of:

From left:   1.90 cm
From right:  1.00 cm
From top:    2.00 cm
From bottom: 4.00 cm

which is both wrong and nonsensical. The content is placed reasonably, however - it's just at an offset from the right margin.

Seen with:

Version: 7.5.0.3 (X86_64) / LibreOffice Community
Build ID: c21113d003cd3efa8c53188764377a8272d9d6de
CPU threads: 4; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: en-IL (en_IL); UI: en-US
Comment 1 Eyal Rozenberg 2023-03-04 20:22:47 UTC
Note: Not seeing that behavior using the Writer PDF import filter.
Comment 2 Eyal Rozenberg 2023-03-04 20:23:04 UTC
Created attachment 185757 [details]
The original Writer document
Comment 3 Kira Tubo 2023-11-16 03:47:04 UTC
Created attachment 190851 [details]
PDF export with LTR

Hmmm, I don't think RTL is the issue. If I export the same file, aligning the text to LTR, the margins are the same as the RTL file. 

It might have to do with the horizontal bar in the document. I get the similar (if not worse) results with a simple rectangle shape created from Writer. I will attach sample files shortly.
Comment 4 Kira Tubo 2023-11-16 03:53:22 UTC
Created attachment 190852 [details]
original writer file with rectangle shape

Steps: 

1. Open Writer
2. Insert rectangle shape
3. Export as PDF
4. Open file created in step 3 in Draw

Result: margins in Draw do not match the margins from Writer.
Comment 5 Kira Tubo 2023-11-16 03:54:02 UTC
Created attachment 190853 [details]
rectangle exported pdf
Comment 6 Buovjaga 2023-11-28 12:53:36 UTC
It's the same result in the oldest of Linux 43all bibisect repo. I should ask about this in the dev chat.