Error while exporting to pdf in staging env of my project. TypeError: Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 4 is not of type 'Window'

0 Answers 293 Views
General Discussions PDF Processing
akash
Top achievements
Rank 1
akash asked on 04 Jan 2022, 04:33 AM

The

 

 

Below are the versions which I am using, it's working perfectly in local but this error I am receiving in the browser console after being deployed.

 

 

 "@progress/kendo-react-pdf": "4.13.0","react": "^17.0.2",
const handlePrint = () => {
if (container && container.current) {
/* @ts-ignore */
savePDF(container.current, {
paperSize: 'auto',
margin: 40,
fileName: `Report for ${new Date().getFullYear()}`,
})
}

}

Filip
Telerik team
commented on 04 Jan 2022, 02:37 PM

Hello, Akash,

Thank you for reaching out to us. In order to help further we will need more information, can you please provide the following:

  • The current package.json file
  • What are you using to deploy your app?
  • A live URL where the project is deployed, so that we can inspect in case this is possible

  Regards,
  Filip

 

akash
Top achievements
Rank 1
commented on 04 Jan 2022, 04:51 PM

{
"name": "appmanagertemplate",
"version": "0.1.0",
"private": true,
"dependencies": {
"@craco/craco": "^6.2.0",
"@progress/kendo-drawing": "^1.16.0",
"@progress/kendo-licensing": "^1.2.1",
"@progress/kendo-react-pdf": "4.13.0",
"@tailwindcss/aspect-ratio": "^0.2.1",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@tinymce/tinymce-react": "^3.13.0",
"@types/jest": "^26.0.24",
"@types/node": "^12.20.23",
"@types/react": "^17.0.20",
"@types/react-dom": "^17.0.9",
"@types/react-table": "^7.7.2",
"add": "^2.0.6",
"axios": "^0.21.1",
"conviva-ui": "^2.13.6",
"formik": "^2.2.9",
"history": "^4.10.1",
"js-cookie": "^2.2.1",
"lodash": "^4.17.21",
"postcss-loader": "^6.1.1",
"react": "^17.0.2",
"react-custom-events": "^1.0.5",
"react-dom": "^17.0.2",
"react-query": "^3.19.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-select": "^5.1.0",
"react-switch": "^6.0.0",
"react-table": "^7.7.0",
"react-toastify": "^8.1.0",
"tinymce": "^5.10.1",
"typescript": "^4.3.5",
"web-vitals": "^1.1.2",
"yarn": "^1.22.17"
},
"scripts": {
"lint": "eslint --fix --ext .js,.jsx,.ts,.tsx src --color",
"serve": "npx http-server ./build",
"format": "prettier --write 'src/**/*.{ts,tsx,scss,css,json}'",
"isready": "npm run format && npm run lint && npm run build",
"start": " craco start",
"stagging": "craco build",
"production": "craco build",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage --ci --maxWorkers=2"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/react-hooks": "^7.0.1",
"@types/history": "^4.7.9",
"@types/js-cookie": "^2.2.7",
"@types/lodash": "^4.14.172",
"@types/react-router-dom": "^5.1.8",
"@typescript-eslint/eslint-plugin": "4.28.2",
"@typescript-eslint/parser": "4.28.2",
"autoprefixer": "^9.8.6",
"babel-eslint": "10.1.0",
"eslint-config-airbnb": "18.2.1",
"eslint-config-airbnb-typescript": "12.3.1",
"eslint-config-prettier": "8.3.0",
"eslint-config-react-app": "6.0.0",
"eslint-import-resolver-typescript": "2.4.0",
"eslint-plugin-flowtype": "5.8.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-webpack-plugin": "2.5.4",
"husky": "^7.0.1",
"postcss": "^7.0.35",
"prettier": "2.3.2",
"prettier-eslint": "12.0.0",
"prettier-eslint-cli": "5.0.1",
"react-test-renderer": "^17.0.2",
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.4"
}
}
akash
Top achievements
Rank 1
commented on 04 Jan 2022, 04:56 PM

I am using https://qiankun.umijs.org/. Qiankun framework to embed micro react application. I have shared package.json of this project only.
The problem is the window object which has been used in save-as.js

````var e = document.createEvent('MouseEvents');

  e.initMouseEvent('click', true, false, window,
  0, 0, 0, 0, 0, false, false, false, false, 0, null);`````

is getting changed to some different object

Filip
Telerik team
commented on 05 Jan 2022, 02:54 PM

It seems that Qiankun changes the window when the app is deployed, which is causing this error. This behavior is also mentioned in their repository multiple times:

https://github.com/umijs/qiankun/issues/1502

Two things can be tried which could help:

I hope this helps.

Regards,
Philip

No answers yet. Maybe you can help?

Tags
General Discussions PDF Processing
Asked by
akash
Top achievements
Rank 1
Share this question
or