Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js throws an error when a survey contains an HTML question #266

Closed
JaneSjs opened this issue Sep 1, 2023 · 2 comments · Fixed by #289
Closed

Node.js throws an error when a survey contains an HTML question #266

JaneSjs opened this issue Sep 1, 2023 · 2 comments · Fixed by #289
Assignees
Labels

Comments

@JaneSjs
Copy link
Contributor

JaneSjs commented Sep 1, 2023

The following exception is raised when a survey contains HTML questions:

(node:12576) UnhandledPromiseRejectionWarning: ReferenceError: document is not defined
    at D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:11374:11
    at process (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:11383:10)
    at Object.jsPDFAPI.fromHTML (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:11921:14)
    at D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:484:54
    at new Promise (<anonymous>)
    at Function.<anonymous> (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:483:46)
    at step (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:222:27)
    at Object.next (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:171:53)
    at D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:164:71
    at new Promise (<anonymous>)
(Use node --trace-warnings ... to show where the warning was created)
(node:12576) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:12576) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@JaneSjs JaneSjs added the bug label Sep 1, 2023
@JaneSjs
Copy link
Contributor Author

JaneSjs commented Sep 1, 2023

The following exception occurs when a document contains Signature Pad:

(node:6868) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined
    at e.__addimage__.getImageFileTypeByImageData (D:\code-examples\surveyjs-pdf-nodejs\node_modules\jspdf\dist\jspdf.node.min.js:115:637)
    at Object._ (D:\code-examples\surveyjs-pdf-nodejs\node_modules\jspdf\dist\jspdf.node.min.js:115:8196)
    at Object.e.addImage (D:\code-examples\surveyjs-pdf-nodejs\node_modules\jspdf\dist\jspdf.node.min.js:115:7975)
    at D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:4284:50
    at new Promise (<anonymous>)
    at ImageBrick.<anonymous> (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:4283:50)
    at step (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:222:27)
    at Object.next (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:171:53)
    at D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:164:71
    at new Promise (<anonymous>)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled 
promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:6868) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When a survey contains an Image:

(node:27556) UnhandledPromiseRejectionWarning: Error: addImage does not support files of type 'UNKNOWN', please ensure that a plugin for 'UNKNOWN' support is added.
    at Object._ (D:\code-examples\surveyjs-pdf-nodejs\node_modules\jspdf\dist\jspdf.node.min.js:115:8215)
    at Object.e.addImage (D:\code-examples\surveyjs-pdf-nodejs\node_modules\jspdf\dist\jspdf.node.min.js:115:7975)
    at D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:4284:50
    at new Promise (<anonymous>)
    at ImageBrick.<anonymous> (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:4283:50)
    at step (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:222:27)
    at Object.next (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:171:53)
    at D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:164:71
    at new Promise (<anonymous>)
    at __awaiter (D:\code-examples\surveyjs-pdf-nodejs\node_modules\survey-pdf\survey.pdf.js:150:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:27556) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:27556) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@JaneSjs JaneSjs assigned dk981234 and JaneSjs and unassigned JaneSjs Sep 1, 2023
@dk981234 dk981234 linked a pull request Nov 28, 2023 that will close this issue
@JaneSjs
Copy link
Contributor Author

JaneSjs commented Feb 20, 2024

+1 T16596 - PDF takes a long time to generate
https://surveyjs.answerdesk.io/internal/ticket/details/T16596

@RomanTsukanov RomanTsukanov changed the title SurveyJS PDF Export on Node.js Fails with the 'ReferenceError: document is not defined' when a document contains an HTML question Node.js throws an error when a survey contains an HTML question Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants