Export notebook to PDF

Am I correct in concluding that I can not export a whole notebook to PDF, but only individual pages?

4 Likes

You’re correct, it’s not currently possible to print a whole notebook.

Is there any plan to include this at some point? Or if it’s too much trouble to export an entire notebook as a single PDF would it be possible to include an option to export all the notes within a notebook as PDFs in a single operation?

3 Likes

I agree, I would definately find it useful if in the page that shows when you ctrl+click several notes for there to be an “export to PDF” button to create a PDF from the whole stack of notes, and/or if each individual note could be exported to a separate PDF.

1 Like

The problem is exporting as PDF can only be done when the note is rendered (visible) in the note view, so exporting a notebook would mean displaying each note one after the other and exporting a PDF from it. Then these PDFs will have be concatenated into a single one using some package.

An alternative for now would be to export as Markdown, then you can use a tool like Pandoc to convert and concat them all to a single PDF.

2 Likes

That’s an… interesting design decision on the Electron people’s part. I guess that’s out of scope for us though…

I do use pandoc often when I need this type of feature, however I wish that there was a way to pass a specific note or list of notes to an external script. I’m sure we can all imagine lots of fancy scripting features, but at a basic level just being able to run a command with the note ID (and maybe also the web clipper API key?) as the argument(s) would make this really straightforward.

I don’t know how electron works, but I think at a minimum useful level this would just be a button that appears after setting a “script command” in the settings which calls that command with the relevant arguments. I’ve been playing with the web clipper API via jq and curl, and have found it both straightforward and useful… being able to easially run a script on a specific note (or list of notes) chosen through the GUI would be super handy, and custom PDF export behavior would be very easy to implement this way.

The Windows people might have it even easier, since AFAIK PowerShell can interface with web APIs natively.

Should I make a separate feature request thread for tis?

Actually we're simply taking advantage of the web view (where the note is rendered) Print functionality, which can also export to PDF. Basically we get this PDF export for free, however there's not really a programmatic API where we can take some HTML and get a PDF back. Like a browser it only work for the currently loaded view.

Implementing custom scripts would be useful but a bit complicated in terms of UI. It wouldn't make sense to support just one command, so we would need something to manage a list of commands, to add them, remove them, modify them etc. We would also need a way to pass arguments to these commands, for example the currently selected notebook, or currently selected note. We can use the same convention as the CLI ($b for the notebook, $n for the note).

Then we can have a commands like ~/bin/create_notebook_pdf.sh $b or ~/bin/send_by_mail $n, etc. And these scripts will use the API to retrieve notes and notebooks.

Feel free to give it a try if you want. It can be done but it's not straightforward I think.

To make it simpler, maybe we can use the same approach as Sublime Text for the build system - just a series of JSON files which can be manually edited. Here's an example:

{
	"shell_cmd": "~/bin/create_notebook_pdf.sh $b",
	"cwd": "$HOME",
}

My thought was that one could use yad or something to that effect to pop up a GUI picker with several options to choose from. Obviously the full monte would be a configuration file and/or a settings panel where many different scripts could be prepared. However one of these is easier than the other.

I have worked a little with JS, but I mostly write Python and C, so Joplin and it's technology stack are a bit outside my area of expertise. That said, time permitting, I will try to create a PoC.

I’ve was toying with how to use joplin to write a book, organizing a notebook where notes would be chapters. I could implement this PDF thing easily, but the problem is the ordering of the notes for that. But for your use-case, I could do it easily if you’re interested. Basically I would create one note for all the notes in a notebook concatenating the notes and saving it as a new note that you could then export.

To solve my use-case where the order matters, I thought about making a note using the copy markdown link feature and then export all referenced notes in order, using the same idea.

It would be cool to be able to export that to epub too.

Have you seen the notes for the latest pre-release?

Well, that solves that problem then :slight_smile:
The next question would be how to deal with note-titles vs headings :slight_smile: How would the separation between notes be handled?

Ah, since we can use SVG I can insert some nice separator :slight_smile:

I just made an experimental separator for now. it’s not beautiful but it works. feel free to contribute a nicer SVG. Anyway on macos:

sudo gem install joplin
joplin nb2n --token <your webclipper token> 'name of notebook'

this will create a new note with the name of the notebook. just check for the latest note and that will have all notes concatenated into one that you can then just export to PDF

Example notebook called “test” with two notes in it:

Update:

Made it a bit more pleasing to look at. I tried it with several notebooks. the output is good

2 years later... Still missing.

1 Like