surveyjs / survey-pdf

Supplementary component to the SurveyJS Form Library to download surveys as PDF files and generate editable PDF forms.
https://surveyjs.io/pdf-generator/examples/survey-pdf-export/
Other
60 stars 30 forks source link

Characters in Element that is type of Html is not rendered truely #105

Closed sahin52 closed 1 year ago

sahin52 commented 2 years ago

Are you requesting a feature, reporting a bug or asking a question?

Reporting a bug

What is the current behavior?

The downloaded file has changed Turkish characters in it, but only in the parts of elements of html

What is the expected behavior?

The Turkish characters should be written truely

How would you reproduce the current behavior (if this is a bug)?

Create a html element with ı character in it, and download it, it will be rendered as 1.

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://codesandbox.io/s/young-currying-nq3kb?file=/src/App.js Test code

import * as SurveyPDF from "survey-pdf";
let modelQuestions =
 {
    pages: [
      {
        name: 'page1',
        elements: [
          {
            type: 'html',
            name: 'isten_ayrilmaya_iten_faktorler',
            html: '<h5>1) Sizi işten ayrılmaya iten faktörler nelerdi?</h5>',
          },
          {
            type: 'checkbox',
            name: 'ucret_ve_Yan_Haklar',
            indent: 2,
            title: '1.1) Ücret ve Yan Haklar',
            hideNumber: true,
            choices: [
              {
                value: 'Ücretin yeterli olmaması',
                text: 'Ücretin yeterli olmaması',
              },
              {
                value: 'Ücret zamlarının adil ve belirli bir politikaya uygun olmaması',
                text: 'Ücret zamlarının adil ve belirli bir politikaya uygun olmaması',
              },
            ],
          },
]}]}
var surveyPDF = new SurveyPDF.SurveyPDF(modelQuestions, {});
      surveyPDF.data = {};
      surveyPDF.save("survey");

Specify your

tsv2013 commented 2 years ago

I believe similar question was discussed in this thread - https://github.com/surveyjs/survey-pdf/issues/42 You need to load custom font supporting Turkish characters and use it in exported document

sahin52 commented 2 years ago

I can't find the example font strings (there was a string for roboto in the example) anywhere and the given examples does not have any effect on mine. The result has still weird results only in html parts. Can you give me an example?

tsv2013 commented 2 years ago

Here is the example on our site how to use a font with Japanese symbols - https://surveyjs.io/Examples/Pdf-Export?id=survey-pdf-customfont&platform=Knockoutjs&theme=modern#content-js

sahin52 commented 2 years ago

In the example there is a line with

var mouhitsuBold = "AAEAAAASAQAABAAgR1NVQlaTjWkAAq50AAAJoE9TLzJ7u4xIAAAByAAAAFZjbWFwM6.....

how can I find this string for font? I couldn't find it anywhere.

tsv2013 commented 2 years ago

It's described in jsPdf library documentation - https://github.com/parallax/jsPDF#use-of-unicode-characters--utf-8

sahin52 commented 2 years ago

Thanks a lot, this solved it but it would be better if the users didn't struggle with this.