https://bugs.documentfoundation.org/show_bug.cgi?id=171547

            Bug ID: 171547
           Summary: PDF export loses leading whitespace (indentation) when
                    copied as plain text
           Product: LibreOffice
           Version: 26.2.1.2 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Printing and PDF export
          Assignee: [email protected]
          Reporter: [email protected]

Created attachment 206454
  --> https://bugs.documentfoundation.org/attachment.cgi?id=206454&action=edit
Sample document showing indentation loss in PDF copy-paste

What did you do? (steps to reproduce):
Create a document in LibreOffice Writer containing indented code or text with
leading spaces.
Export the document to PDF using the standard PDF export.
Open the exported PDF in a Chromium-based browser (e.g., Chromium or Opera).
Copy the indented text from the PDF.
Paste it into a plain text editor.
Compare the pasted text with the original document.

What happened? (actual results):
The PDF displays correctly and indentation is visible.
However, when copying text from the PDF and pasting it into a plain text
editor, leading whitespace (indentation) is lost.

What should have happened? (expected results):
The copied text should preserve leading whitespace exactly, so that indentation
is maintained when pasted into a plain text editor.


Additional information:

Indentation is only preserved if both of the following conditions are met
before exporting to PDF:

The text is placed inside a text box (graphical object) in LibreOffice Writer
Non-breaking spaces (Ctrl+Shift+Space) are used instead of regular spaces

If either condition is not met, indentation is lost when copying from the PDF.

The workaround above works when viewing the PDF in Chromium-based browsers
(e.g., Chromium, Opera), but not in other viewers such as Firefox or Evince.

The PDF renders visually correctly in all cases. The issue only appears during
text extraction (copy-paste), suggesting that regular spaces in standard
paragraph text are not encoded in a way that preserves leading whitespace.

Possibly related to Bug 130008, but this report provides a more specific
reproduction case involving leading whitespace, text containers, and whitespace
type.

At minimum, non-breaking spaces should be preserved correctly during copy-paste
from the exported PDF, as they represent explicit, non-collapsible whitespace.
This already works when the text is placed inside a text box (graphical
object), but not when using standard paragraph text.

Attachment description

Sample document demonstrating loss of indentation when copying text from PDF
export.

The document contains three cases:

Indented code using normal spaces (paragraph text)
Indented code using non-breaking spaces (paragraph text)
Indented code inside a text box using non-breaking spaces

After exporting to PDF, only case (3) preserves indentation correctly when
copying and pasting into a plain text editor (tested in Chromium-based
viewers).

Environment:
Version: 26.2.1.2 (X86_64)
Build ID: 8399f6259d8c87f40e7255cdb3c9b958f5e08948
CPU threads: 12; OS: Linux 6.11; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: es-ES
Calc: threaded

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to