LibreOffice Draw does not save the formatting of imported PDFs

I’m trying to attach images to PDFs (using the TexMaths extension), however, when I import a PDF, LO automatically converts it to ODT, usually messing up the formatting. However, since I don’t need to actually edit the PDF, just putting images created from TexMaths, is there a way to open PDFs so that formatting is retained, at the expense of editability? For example, DocHub retains PDFs’ formatting, but doesn’t actually allow edits to the PDFs, as you mostly can only write over it with text boxes and images. So, is there something analogous to it in LO? For reference, I am using LO 7.0.3.1 (x64).

For example, in this PDF, Draw tries its best to retain formatting, yet it still mess up.

LO is not a PDF editor.

You don’t import a PDF (unless you didn’t tell the whole story to describe your work process), you can open it. Writer does not handle PDF files, so they open in Draw, the drawing application. All Draw can do is to show a page (or set of pages) containing graphics objects. Even text is a collection of rectangles containing homogeneous runs of characters (same formatting).

You can add images or other objects but don’t expect text to be laid out again because there is no text in Draw, only geometric shapes with a (short) label. What was text is now a label for the tons of shapes a page can display. Remember also there is no text flow in PDF once the file is built. PDF is a page description language, not a document processing tool.

Eventually, on save, Draw will save the pages as .odg or they can be exported again as PDF.

Improve your question by editing it if you feel I didn’t understand your problem.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

In case you need clarification, edit your question (not an answer which is reserved for solutions) or comment the relevant answer.

I know Draw tries to change a PDF into a collection of shapes, but how come it doesn’t always retain the formatting, but can sometimes mess up?

Not a definitive answer. I think the problem stems from the way the PDF has been created. From its “properties”, it was made by M$ Word from a docx document. Perhaps the encoding is not fully compliant with PDF 1.3 spec version (as claimed). Fonts are only partly embedded in the document (I get different formatting on computers with different configurations – in one case a monospace font is substituted!). To make things worse, tab characters are used within the text boxes to space elements and some boxes (formulas) are overlaid above pure text ones to position them “inline”. As the base text is not laid out correctly, the formula doesn’t appear where it should. I don’t think the font metrics is at stake. Though the document fonts are not installed on my system, characters are rendered just like in a PDF viewer.

However, I suspect a side effect of the US usage of double space after a punctuation. Apparently, double spaces are replaced by Tab, which causes the discrepancies.

Interesting that you say this was created in Word (why do you use “M$” instead of “MS”?)-- I tried to open this up in Word and the formatting again got screwed up. Also, you can see that the words go out of the page sometimes-- do you know why that is the case?

Once formatting is corrupted in a PDF, nothing more can be done. I thought that the errors came from the lack of the fonts on my Linux box. I’m “glad” to see that the problem is not “local” but more fundamental (meaning it does not depend on how you display it). Then using Draw or Word doesn’t change the issue.

I’ve always found very strange that the lines may overflow the page. I guess this is probably a bad interpretation of the encoding. Maybe there is an ambiguity about some features in the PDF specification or, as is frequent, M$ freely interprets and diverges from standards to impose its own views

(M$ to emphasise the commercial and monopolistic sides of the company very often not considering real user needs)

Yeah, I made sure I installed all the fonts. Oh well. It’s just weird though, as it LO worked fine on other files. Thanks anyways.

I’ve found a quick and dirty way to preserve formatting on a PDF, though your provided document was a bit trickier to get to cooperate because the pages are landscape and for whatever reason Firefox did not like that.

I was able to lock in the formatting of the PDF by downloading it, opening it in my browser (in this case Firefox), then using the Print dialogue to “print to PDF”. I was able to save the “printed” PDF as the same file or as a new file, and when I opened it up in Draw the formatting matched up. This worked right off the bat with my own document, but it gave me more trouble with I tried the PDF linked by @DUO . I was able to get that document to a state I’d consider “expected” for opening it by formatting the document as landscape once it was opened in Draw and then using Ctrl+A and F4 on each page to select the contents and rotate them 270 degrees.