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
64 stars 32 forks source link

Cannot create property 'objectFit' on string 'XXX.jpg' when overriding File Question rendering using the onRenderQuestion event #308

Closed JaneSjs closed 8 months ago

JaneSjs commented 8 months ago

To reproduce the issue, run this demo, upload an image and click Save as PDF.

The following exception appears:

Uncaught (in promise) TypeError: Cannot create property 'objectFit' on string 'https://api.surveyjs.io/private/Surveys/getTempFile?name=1a331ba4-8e0d-4ca0-ac4c-6de404c5c67b.jpg'
    at Function.eval (helper_survey.ts:493:35)
    at step (helpers.ts:83:23)
    at Object.eval [as next] (helpers.ts:64:63)
    at eval (helpers.ts:57:71)
    at new Promise (<anonymous>)
    at __awaiter (helpers.ts:53:12)
    at SurveyHelper.createImageFlat (helper_survey.ts:491:142)
    at eval (SurveyPdfComponent.jsx:109:53)
    at async Promise.all (4ph8l6.csb.app/index 0)
    at async Array.eval (SurveyPdfComponent.jsx:93:14)
JaneSjs commented 8 months ago

The following demo fixes the issue: View CodeSandbox.

imageBrick = await SurveyHelper.createImageFlat(
   { 
      xLeft: options.point.xLeft + 20, 
      yTop: top 
   },
   options.question,
   options.controller,
   {
      link: file.content,
      width: imageSize,
      height: imageSize,
   }
);