-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Acroforms not working with zone.js (Angular 7 dependency) #2429
Comments
As I'm digging into this more I found that, the problem is not with the zone.js override of Object.getOwnPropertyDescriptor but rather with its override of Object.defineProperty. If you take the "DA" property of an AcroForm object and step into the code where it's being defined, you will see that because the prop name is 'DA' and not 'prototype' and the desc object is not frozen, the configurable property of the desc object will be changed to true. Offending code is lines 27 and 70 here: https://github.com/angular/zone.js/blob/a5fe09b0fac27ac5df1fa746042f96f05ccb6a00/lib/browser/define-property.ts So maybe the fix for this is to use Object.preventExtensions on the property description objects? I also verified that a simple |
I've got a fork going to test that potential fix: https://github.com/sirhcybe/jsPDF/tree/master |
I actually needed to use Object.freeze but I can confirm that this fixes the issue. The branch I tested with is https://github.com/sirhcybe/jsPDF/tree/zone.js-fix. |
Ok?! but why dont you report to zone.js that their Function does not work as expected? |
And why dont you just change Object.defineProperty in your local code to fix this issue of zone.js? var origDefineProperty = Object.prototype.defineProperty; Object.prototype.defineProperty = function() { Not tested. |
@arasabbasi You make a good point about reporting to zone.js so I've opened an issue with them as well. I'm afraid to re-override Object.defineProperty because zone.js is tied so tightly into Angular that |
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant. |
Did anyone find a solution for this? |
Could you check if this is still an issue when using the files from #2804? Run |
I think they fixed it with a subsequent release of zone.js. |
Any fixes for this? Having the same problem with Angular v17, zone.js v14 and jsPDF v2.5.2, everything works fine except for the AcroForms simply not showing |
I've got an Angular 7 app and I want to generate some PDFs using jsPDF from it. I can generate text based PDFs with no problems but when I try to add an Acroform field the PDF is generated but the fields are missing. Here's the steps to reproduce the problem:
Create a new Angular app with Angular-CLI:
Install jspdf
npm install -s jspdf
Add jspdf code to the app.component.ts file
Run the app and a PDF will download that contains the test text but no text field.
After careful debugging it looks like the Object.getOwnPropertyDescriptor method from zone.js is being called instead of the browser's Object.getOwnPropertyDescriptor method. Apparently they work differently and it's breaking jsPDF because jsPDF expects some properties not to be configurable (line 667 of src/modules/acroform.js) and zone.js is reporting them as configurable.
The text was updated successfully, but these errors were encountered: