Issue T3803
Visible to All Users

my imagepicker question won't export in pdf

created 5 years ago

Hi, I am having trouble with exporting imagepicker question.

Other questions like radiogroup or checkboxes are working just fine but I am getting error on imagepicker question when I try to export as PDF.

The error says …

"Uncaught (in promise) TypeError: Cannot read property 'imageLink' of undefined
at B.<anonymous> (survey.pdf.min.js:6)"

I really cannot find any solution onto this.
Please give me some advice on this problem…

Here is my imagepicker question.

questions: [
{
type: "imagepicker",
name: "step3",
title: {"ko" : "헤어라인 모양?",
"default" : "test2"
},
//hasOther: true,
//isRequired: true,
//colCount: 1,
visibleIf: "{step2}='yes.'",
showLabel: true,
choices: [
{
"value": "1",
"imageLink": "https://shingoonktest.cafe24.com/img/hair1.png"
}, {
"value": "2",
"imageLink": "https://shingoonktest.cafe24.com/img/hair2.png"
}, {
"value": "3",
"imageLink": "https://shingoonktest.cafe24.com/img/hair3.png"
}, {
"value": "4",
"imageLink": "https://shingoonktest.cafe24.com/img/hair4.png"
}, {
"value": "5",
"imageLink": "https://shingoonktest.cafe24.com/img/hair5.png"
}, {
"value": "6",
"imageLink": "https://shingoonktest.cafe24.com/img/hair6.png"
}
]
}
]

Comments (2)

    Hello,

    Thank you for the report. I've reproduced the issue in this plunker - https://plnkr.co/edit/wUszgGd81cod5RHm.
    We'll worn on the fix.

    Wrong rows/cols count in our code. rows 2 cols 4. index = 6 - item (this.question.visibleChoices[index]) is undefined

    JavaScript
    let index: number = i * cols + j; this.controller.margins.left = currMarginLeft; this.controller.margins.right = this.controller.paperWidth - currMarginLeft - colWidth; currMarginLeft = this.controller.paperWidth - this.controller.margins.right + this.controller.unitWidth; currPoint.xLeft = this.controller.margins.left; let itemFlat: IPdfBrick = await this.generateFlatItem(currPoint, this.question.visibleChoices[index], index);

    Thanks, Serge
    SurveyJS Team

      Hi

      I thought that I was doing something wrong :)

      Thanks for the fast reply.
      When do you think the fix is going to be updated?

      Answers approved by surveyjs Support

      created 5 years ago

      Hello,

      We fixed this issue via this commit. It will available with next minor update most likely today. However, please, note that SurveyPDF can't export images via URL imageLink. You need to convert images to base64 URL format to export it via SurveyPDF

      Thanks, Alex
      SurveyJS Team

        Show previous comments (2)

          Hi

          If automatic converting format is provided from the library, that would be very nice and convenient.

          Thanks, Andrew.

            Hello,

            As a workaround right now you can search in Google something like convert image to base64 and use any online tool like this. Just upload image, get base64 code and paste into SurveyJSON to imagelink. Here is live sample of export imagepicker via SurveyPDF

            Thanks, Alex
            SurveyJS Team

              Hello,

              We performed investigation about loading images to export to PDF document. In SurveyPDF we use jsPDF MIT library to produce PDF. We use jsPDF to process html and images too. It turned out that jsPDF processes url image links fine and problem is very trivial ― image will be not drawn in produced PDF document if server which hosts the image has no allow cross origin header (CORS policy). So you can use your own server with allow cross origin policy for your images, use proxy server or convert your images to base64

              Thanks, Alex
              SurveyJS Team