node-html-pdf
node-html-pdf copied to clipboard
Loading custom fonts
I'm using Persian fonts like IRANSANS. can I import my custom font ?
This can help you https://github.com/marcbachmann/node-html-pdf/issues/322#issuecomment-327045134
I had the same problem and solved it by using file://
in my html code, for example, I imported my font-face declration css file in them main like this:
<style> @import url("file:///home/myname/projects/myprojectname/public/font/IRANSansWeb/index.css"); </style>
the base
option doesn't word for me.
If you use docker, this solution works
- install fonts globally
COPY ./my-custom-font.ttf ./
RUN mkdir -p /usr/share/fonts/truetype/
RUN install -m644 my-custom-font.ttf /usr/share/fonts/truetype/
RUN rm ./my-custom-font.ttf
- just use this font in
font-family
without imports