Question T13152
Visible to All Users

Issue with Survey PDF Generator

created 2 years ago (modified 2 years ago)

[Ticket cloned from T13025: Error with uploaded documents. [urgent]]

that preview thing is my code issue. but now i am facing one more issue with survey-pdf. you can find the example below,

https://codesandbox.io/s/surveyjs-angular-forked-h1cze3

click on the complete after uploading document.

Comments (1)

    Hello,
    Thank you for sharing the demo. I created the following GitHub issue and forwarded it to our developers for further investigation: https://github.com/surveyjs/survey-pdf/issues/244. We'll let you know our results.

    Please stay tuned.

    Answers approved by surveyjs Support

    created 2 years ago

    Hello,
    The exception occurred because a SurveyPDF cannot build a preview for an uploaded image. You can solve the error using the following options:

    • Disable image preview for SurveyPDF.
      Disable the allowImagesPreview option for a File question of a Survey PDF instance to disable an image preview in PDF. Now, the PDF document contains a link; the link should allow users to download an image.
    JavaScript
    surveyPdf.getQuestionByName("question1").allowImagesPreview = false;

    https://codesandbox.io/s/surveyjs-angular-forked-fxthy0?file=/src/app/components/survey.component.ts

    • To display an image preview in PDF, add the onDownloadFile callback for a Survey PDF instance:
    JavaScript
    const onDownloadCallback = (sender, options) => { console.log("download", options.content); const fileObj = this.agreementFiles.find( (item) => item.key === options.content ); if (fileObj) { options.callback("success", window.URL.createObjectURL(fileObj.file)); } else { options.callback("error"); } }; survey.onDownloadFile.add(onDownloadCallback); ... surveyPdf.onDownloadFile.add(onDownloadCallback); surveyPdf.mergeData(survey.data); ...

    https://codesandbox.io/s/surveyjs-angular-forked-zljf0v?file=/src/app/components/survey.component.ts

    Please let me know if you have additional questions.

      Comments (2)

        ohh, i don't know that we can add download callback. I will try this and let you know.
        your customer support is appreciated.

        edit: It worked for us. thank you.

          You're always welcome! Please feel free to contact us if you have any questions.