Leading spaces lost copying code from pdf

My recommendation is to tweak the pdf format to actually write blank lines
and consider left-aligned code listing. This would at least allow
https://pdf-xchange.eu/ to be used as a free viewer on windows, and
probably any pdf editor, to support copy/paste pdf code with layout.

BTW, note
https://documentation.libreoffice.org/assets/Uploads/Documentation/en/GS7.3/GS73-GettingStarted.pdf#page=431
code not colorized, and no indented code throughout.

HI Flywire

My recommendation is to tweak the pdf format to actually write blank lines
and consider left-aligned code listing. This would at least allow
https://pdf-xchange.eu/ to be used as a free viewer on windows, and
probably any pdf editor, to support copy/paste pdf code with layout.

Your use case is to copy the basic or python code in a PDF output and paste in a text editor. Yes, code indentation is lost.

Assuming there is no UI setting to prevent this, please open an enhancement bug.

I also would investigate if any style attribute can prevent PDF to loose indentation.

I also don't get why use an external service for PDF edition since LibreOffice can edit PDF files, in 2 ways:
1) as hybrid PDF
2) as a drawing handled by Draw.

BTW, note
https://documentation.libreoffice.org/assets/Uploads/Documentation/en/GS7.3/GS73-GettingStarted.pdf#page=431
code not colorized, and no indented code throughout.

Just use Andrew Pitonyak extension in the python code fragment. I did it in the Base guide and it works.

Cheers

https://bugs.documentfoundation.org/show_bug.cgi?id=148025 is marked as a
duplicate but it needs confirming and changing to related because nearly
all of the assertions in #66181 are wrong, and the bugs have a different
emphasis.

From https://bugs.documentfoundation.org/show_bug.cgi?id=148025#c3

Pasting the selection from https://pdf-xchange.eu/ will contain the

required blank lines *if* it is written in the pdf. LibreOffice does not
write blank lines in the pdf.

Please understand this is a two-part fix:
1) Tweak LibreOffice pdf to write blank lines -
https://github.com/LibreOffice/core/blob/master/vcl/source/gdi/pdfwriter_impl.cxx
??
2) User must view pdf in software that captures pdf layout

Adobe Acrobat only captures text, not layout. Maintainers of pdf viewer
software generally consider this is all that is required but I note the
viewers often offer features not found in Acrobat.

The only reason to use a pdf editor is they must capture layout to be
functional but they generally don't have the best interface for viewing pdf
files. For example, LibreOffice is not the software of choice to view pdf
files. https://pdf-xchange.eu/ has an acceptable interface.

See attached XpdfReader screenshot showing selection. Ideally, a freely
available pdf viewer can be found or tweaked to capture that selection into
the clipboard rather than stripping leading/trailing spaces and blank lines.

In relation to link to code in the guide, the main point is to demonstrate
it is not consistent. That code is not colorized, code is not indented in
that chapter, and it's published. I don't agree the Andrew Pitonyak
extension works given it has, for example, highlighted keywords in part of
python macro names. It needs more customisation.

Indented code blocks are a potential complication that could be overcome

by formatting it left-aligned.

I raised this issue because I foresee indented code blocks will be a
problem using copy/paste from pdf with layout. I suggest code blocks
shouldn't be indented so any indents are part of the code layout,
especially since code style is inconsistent throughout the guides.

HI Flywire

The subject will be better addressed if brought to the developers lists. There are PDF specialists there.

You can reach the developer mailing list at

https://lists.freedesktop.org/mailman/listinfo/libreoffice

So, can we continue there?

If you are lucky you may try to reach a developer with a IRC channel at

https://web.libera.chat/?chan=#libreoffice-dev

Cheers
Olivier