I am trying to use the SurveyJS "Export to PDF" feature, described here, on a form with several pages. I follow the steps for a JavaScript application (importing Javascript libraries in HEAD, adding the rest of their code after I define the JSON of the survey) and nothing happens. When I open the Javascript console, I see two errors:
Uncaught TypeError: Cannot read properties of undefined (reading 'Serializer')
at survey.pdf.min.js:2:33043
at survey.pdf.min.js:2:179807
at survey.pdf.min.js:2:179813
at survey.pdf.min.js:2:306
at survey.pdf.min.js:2:326
survey.js:33 Uncaught ReferenceError: SurveyPDF is not defined
at savePdf (survey_rct_wrapper.js:33:23)
at t.action (survey_rct_wrapper.js:41:19)
at HTMLInputElement.<anonymous> (survey.jquery.min.js:11:47630)
at HTMLInputElement.dispatch (jquery.min.js:2:40035)
at v.handle (jquery.min.js:2:38006)
As suggested in the comments, I tried using the unminified version of the libraries. Here is a minimal reproducible example in Jade/PUG:
doctype html
html
head
<!-- jsPDF library -->
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.umd.js"></script>
<!-- SurveyJS PDF Generator library -->
<script src="https://unpkg.com/survey-pdf/survey.pdf.js"></script>
And now the console shows more details on the source of the error:
flat_question.ts:170 Uncaught TypeError: Cannot read properties of undefined (reading 'Serializer')
at ./src/flat_layout/flat_question.ts (flat_question.ts:170:1)
at __webpack_require__ (bootstrap:19:1)
at ./src/flat_layout/flat_repository.ts (flat_rating.ts:98:61)
at __webpack_require__ (bootstrap:19:1)
at ./src/helper_survey.ts (flat_textbox.ts:28:60)
at __webpack_require__ (bootstrap:19:1)
at ./src/doc_controller.ts (index.js:46:1)
at __webpack_require__ (bootstrap:19:1)
at ./src/survey.ts (pdf_titlepanel.ts:18:2)
at __webpack_require__ (bootstrap:19:1)
How can I fix this issue, or find another way to export from a SurveyJS JSON form to a PDF file?
survey-corepackage, which the SurveyJS team mentioned just now in a reply to a ticket. Can you please write an answer and I'll accept it? And can you please also mention the simpler methods to export multi-page surveys as PDFs?