Git Product home page Git Product logo

Comments (9)

kMutagene avatar kMutagene commented on May 28, 2024

You should be able to do this as long as there is a way to load the font in the html enclosing the chart.

A quick search for me turned out that this must be done via css (https://stackoverflow.com/questions/64508137/how-to-use-ttf-as-font-family-in-html). You can include such a css file in your chart output head tags by usingh the DisplayOptions API just as it is done here for the bulma stylesheet.

from plotly.net.

jaguarxii avatar jaguarxii commented on May 28, 2024

Hi, in my use case there is no web page for the chart, I need the svg-rendered chart so it can be embedded into a pdf file (server-side).

it is really strange because using a proper linux distro (debian 12) there is no font for the charts (squares instead of letters), using a wsl instance (debian 11) i got proper letters (dejavusansmono)

image

somehow it takes a "default font" from the wsl instance eventhough x-server is not installed.

from plotly.net.

kMutagene avatar kMutagene commented on May 28, 2024

Hi, in my use case there is no web page for the chart, I need the svg-rendered chart so it can be embedded into a pdf file (server-side).

You will still need the html page to display properly, because rendering as svg is done in a headless browser. So i would expect everything to work once you manage the chart to reference the font via css

from plotly.net.

kMutagene avatar kMutagene commented on May 28, 2024

could you maybe attach the svg that has no font as well? maybe that helps narrowing it down

from plotly.net.

jaguarxii avatar jaguarxii commented on May 28, 2024

Here is the sample SVG

it seems a valid file, but when it is attached to the PDF it has wrong letters (font)

image

out_svg

from plotly.net.

kMutagene avatar kMutagene commented on May 28, 2024

it seems a valid file, but when it is attached to the PDF it has wrong letters (font)

Are you creating that pdf programmatically? You can include fonts in pdfs, so that might be a solution for you.

I did some digging and this is not natively supported in plotly.js either (see here for reference). This means you have to either patch the generated SVG or the PDF with your custom font if you want to make the files self contained.

from plotly.net.

jaguarxii avatar jaguarxii commented on May 28, 2024

Hi @kMutagene, thanks for the references, will test and come back with the results

The PDF file is created programmatically using QuestPDF (already created an issue about this behavior), it includes the fonts that are required. QuestPDF Issue

Using Plotly.js (client side) I had no troubles creating PDFs using pdfmake, the approach was the same, render the chart in SVG format then embed in the PDF document.

from plotly.net.

kMutagene avatar kMutagene commented on May 28, 2024

Using Plotly.js (client side) I had no troubles creating PDFs using pdfmake, the approach was the same, render the chart in SVG format then embed in the PDF document.

Could you maybe also attach that pdf that is working here? maybe we can spot a difference between the 2

from plotly.net.

sproott avatar sproott commented on May 28, 2024

As I've mentioned in the linked QuestPDF issue, I have the same issue with QuestPDF and ScottPlot 5, so it might be an issue on the QuestPDF side.

from plotly.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.