Save body email as PDF

Describe the issue/error/question

I am trying to save to PDF the body of an email. I have thought to use the field HTML from IMAP node to convert to PDF but I haven’t found the way to do it.
Do someone some idea about how can I do it?

Any help will be welcome.
Thank you very much for your time and patient!
BR!

Please share the workflow

Information on your n8n setup

  • **n8n version:**0.182.0
  • Database you’re using (default: SQLite): N/A
  • **Running n8n with the execution process [own(default), main]:**own
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**desktop app

Hi @franchogarcia, this isn’t an operation built into n8n I am afraid. You could use an API for the job, for example OneSimpleAPI. n8n has a node for it, but it only supports converting HTML coming from a URL into a PDF.

If you want to use your email HTML you’d need to use the HTTP Request node. Like so:

Your credentials would need to be set up like so (Name = token, Value would be your actual token):

The above workflow would transform this:

Into a PDF like this:

Thank you very much @MutedJam!! You are the best! :blush:
Do you think that your solution will support embebed pictures into the html code? IMAP returns the embebed pictures into the body as base64.

I doubt it tbh, but it’s worth simply trying it out. If not, it could be worth checking directly with the folks offering this API. I believe @Jon mentioned they’re pretty active when it comes to the development of their tool.

There might be other APIs out there as well, though I am not super familiar with this space.

Okey, thank you very much again @MutedJam!!

Yes, there are tons of alternatives - if what you have works, that’s great. Generally HTML→PDF conversion isn’t great, but if you can be sure the content won’t be very complex or dynamic you’ll be ok (or if you don’t care about the output).

If you’re finding this isn’t performing well enough, you could consider converting the HTML to markdown then using a simple library like pdfmake to produce a PDF.