Hello all,
I have this strange situation where when I make a code block containing empty white lines these empty lines are not copied over after the file has been exported to a PDF.
Example:
```bash
#!/bin/bash
cd "~"
echo "I am now in home"
```
once exported, opened in the PDF reader and copied all the text will be put as:
#!/bin/bash
cd "~"
echo "I am now in home"
Does someone know if this is on purpose, a bug and how I could possibly fix this?
I am using Joplin 1.0.216 on Windows 10 and using your example code block my pdf output looks like this:

What Joplin version / OS are you using? Maybe someone with a similar setup could try it to find out if they can duplicate what you are seeing...
Hello @dpoulton, thanks for responding.
Maybe I was not clear enough, my bad. The issue is not that it looks wrong in the PDF but that if you copy the text from the PDF and paste the copied text to notepad (for example) it is missing the blank new lines.
This is expected. The PDF documented is a rendering of the Markdown text and some information is lost along the way - it’s like if you add an HTML table to a note, then copy that table in PDF, you don’t expect to get the HTML table back.
It’s the same here. The PDF viewer lets you select and copy text, but you won’t get back exactly what you had in the Markdown text.
Thank you for responding.
I can imagine that for the non code block sections the new lines would be rendered as described by you however I would have expected that a code block does contain the blank new lines when copying.
The PDF might be rendering the new lines using margin or padding, in which case it won't be included when copying and pasting.
Ah that makes sense.
Do you know if it by inserting custom CSS into the userstyle.css file that my expected behaviour is possible? Or would this require a deep change somewhere in the PDF rendering system?
It actually might be possible that switching pdf viewers will give you the behaviour that you want. I believe some support more intuitive text copy (I believe okular supports this).
Thank you for responding. I have tried this PDF viewer and it did not work. Thanks for the information.
What I find more interesting is that the preview in the Joplin Desktop app does actually do the expected behaviour but only when exporting to a PDF the new lines are lost.

In Joplin’s case the markdown is rendered to HTML and of course it is showing correctly. Joplin has a markdown renderer.
Laurent already explained why information can get lost when exporting to PDF.
1 Like