Node PDF to Picture / Manipulate PDF

Hi, is there any possibility to convert a pdf in a picture ? We would like to receive a pdf from a node and put some other information in it.
What do you think ?

Thanmks,
Stefan

No sadly not. You would have to look for an external API which offers that. Then you could simply use the HTTP Request Node to use that API.

1 Like

Jan, i think about to store the file via write binary and execute mybe imagemagick on my server and then …

Ah you are right. I did not think about that imagemagick supports PDF. Anyway checked then if graphicsmagick does because the Edit Image-Node use that one. Good news, it does.

So what I want to say is that it is then after all possible already. Here an example workflow:

{
  "nodes": [
    {
      "parameters": {
        "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
        "responseFormat": "file",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        450,
        450
      ]
    },
    {
      "parameters": {
        "operation": "rotate",
        "options": {
          "format": "png"
        }
      },
      "name": "Edit Image",
      "type": "n8n-nodes-base.editImage",
      "typeVersion": 1,
      "position": [
        600,
        450
      ]
    }
  ],
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Edit Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Jan, your sample dont work with pdf right now ? Right ?

Yes, it does at least if you have graphicsmagick installed.

Must GraphicsMagick installed in the docker container ?

image

What docker image are you using? One of ours or one you did create yourself?

yours i use it.

That is strange. There it should be installed by default. Will have a look.

Not sure why but for some reason does it not seem to like graphicsmagick in the Alpine based image. So if you are currently using n8nio/n8n:0.75.0 switch to the ubuntu based one n8nio/n8n:0.75.0-ubuntu. There it will work fine.

Great, that work. A idea put these feature in the description of the node.

Jan, another question to these node, you wrote that graphicsmagick works behind this node. What do you think its possible to make it workable txt and html files ?

to build up a converter from html/txt to picture.

Thanks,
Stefan

Yes that should be possible. Maybe it already works by simply supplying the html/txt file. But it looks like it would need then also need html2ps installed. So you can just try and check and maybe you are lucky :wink:

I use docker it must be integrate ?

Yes, you would have to create a new docker image. You can base it on our existing one and then simply install additionally html2ps.

i try it. Thanks