A
A
andreychernyshov2020-06-14 21:57:30
JavaScript
andreychernyshov, 2020-06-14 21:57:30

How to display y in js strings?

There is a function in js:

function getSVG(data) {
    
    return svg = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full">
        <g>
            <text x="${data.x}" y="${data.y}" font-family="${data.font_family}" font-size="${data.font_size}" fill="${data.font_color}">
                ${data.textValue}
            </text>
        </g>
        </svg>`;
}


I refer to it as follows:
let pdfContent = [];
pdfContent.push({svg: getSVG(data)});


Through the data object, I pass the necessary properties to the function. In particular, data.textValue contains text.
Next, pdf is created using pdfmake.

So if there are words with the letter "Y" in data.textValue, then it is not displayed correctly. Either "and" and an empty space, or "and" and a rectangle with diagonals are created.
If you write words with th into the function itself in the text tag, then everything is displayed correctly.
I suspect that the problem is in the encoding of the string.

Tell me, please, how to treat?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question