# Pdfmake - how to add times new roman font

**URL:** <https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535>\
**Category:** General\
**Created:** [20 February 2025 13:11 UTC](https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535 "2025-02-20T13:11:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucianv](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lucianv](https://discourse.nodered.org/u/lucianv)\
**Post date:** [20 February 2025 13:11 UTC](https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535/1 "2025-02-20T13:11:29Z")

</div>

Hi,  
I am using pdfmake for generate pdf's from nodered. All is good, just I was not able to find any example/tutorial for change the default font. I would like to use TimesNewRoman (or whatever other font).  
Can anyone point me to an example which is using other than default font?

Thank you very much

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [20 February 2025 14:00 UTC](https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535/2 "2025-02-20T14:00:51Z")

</div>

Have you tried

```auto
msg.payload = {
  content: [
    'Text styled by default style'
  ],

  defaultStyle: {
    fontSize: 15,
    font: " name of font"
  }
};

```

More examples here [pdfmake](https://pdfmake.github.io/docs/0.1/document-definition-object/styling/)  
Font names here [pdfmake](https://pdfmake.github.io/docs/0.1/fonts/standard-14-fonts/)

---

<div class="post-metadata">

**Author:** ![lucianv](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lucianv](https://discourse.nodered.org/u/lucianv)\
**Post date:** [21 February 2025 07:24 UTC](https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535/3 "2025-02-21T07:24:45Z")

</div>

I tried like this but is just crashing. Probably because does not find the font

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [21 February 2025 11:35 UTC](https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535/4 "2025-02-21T11:35:22Z")

</div>

Does applying the font to the text paragraph work?

```auto
msg.payload = {
	content: [
	   	{
			text: "some text here", 
			font:"font name"	
		}
	]
}

```

Are you using the correct font names?  
There are 13 -14 default fonts that i linked to previously.

With out more info like example flows you have tried and any error code or log info it is really hard to offer more help.

---

<div class="post-metadata">

**Author:** ![lucianv](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lucianv](https://discourse.nodered.org/u/lucianv)\
**Post date:** [21 February 2025 12:35 UTC](https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535/5 "2025-02-21T12:35:36Z")

</div>

Yes is the same behaviour  
I will put here my test, if you want to test yourself. I am not sure what I miss or do wrong.

```auto
[
    {
        "id": "0532e4eaf6063d8f",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "3108bb639f2e775a",
        "type": "inject",
        "z": "0532e4eaf6063d8f",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 600,
        "y": 240,
        "wires": [
            [
                "dd568d4d509e44a5"
            ]
        ]
    },
    {
        "id": "dd568d4d509e44a5",
        "type": "function",
        "z": "0532e4eaf6063d8f",
        "name": "set pdf",
        "func": "var pdf_content = \"\";\n\npdf_content = {\n\n pageSize: 'A4', \n pageMargins: [15, 30, 15, 30],\n \n content: [\n {\n text: \"some text here\",\n font: \"Helvetica\"\n }\n],\n styles: {\n header: {\n fontSize: 18,\n bold: true,\n margin: [0, 0, 0, 10]\n },\n subheader: {\n fontSize: 16,\n bold: true,\n margin: [0, 10, 0, 5]\n },\n tableExample: {\n margin: [0, 5, 0, 15]\n },\n tableHeader: {\n bold: true,\n fontSize: 13,\n color: 'black'\n }\n },\n defaultStyle: {\n // font: 'Helvetica'\n }\n}\n\n\nmsg.payload = pdf_content;\nmsg.filename = \"/home/bisol/test/\" + Date.now() + \".pdf\";\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 790,
        "y": 240,
        "wires": [
            [
                "5d0cd13528ad66f1"
            ]
        ]
    },
    {
        "id": "5d0cd13528ad66f1",
        "type": "pdfmake",
        "z": "0532e4eaf6063d8f",
        "name": "",
        "outputType": "Buffer",
        "inputProperty": "payload",
        "options": "{}",
        "outputProperty": "payload",
        "x": 1000,
        "y": 240,
        "wires": [
            [
                "8b6983796f58596e"
            ]
        ]
    },
    {
        "id": "8b6983796f58596e",
        "type": "file",
        "z": "0532e4eaf6063d8f",
        "name": "",
        "filename": "filename",
        "filenameType": "msg",
        "appendNewline": true,
        "createDir": true,
        "overwriteFile": "true",
        "encoding": "none",
        "x": 1200,
        "y": 240,
        "wires": [
            []
        ]
    }
]

```

Thanks

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [21 February 2025 14:09 UTC](https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535/6 "2025-02-21T14:09:21Z")

</div>

Sorry can not test my device is having issues installing pdfmake node.  
simplify you test payload to minimum and please report errors.

There is also this open issue that tells you where you can add fonts [Using other font via url · Issue #6 · ollixx/node-red-contrib-pdfmake · GitHub](https://github.com/ollixx/node-red-contrib-pdfmake/issues/6)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 May 2025 14:10 UTC](https://discourse.nodered.org/t/pdfmake-how-to-add-times-new-roman-font/95535/7 "2025-05-22T14:10:14Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
