Posted 29 April 2024, 9:05 am EST
Hello,
Since we switched to Angular 17, we’ve encountered a critical error during PDF export (see the end of this message).
When looking at the following example, we couldn’t figure out the source of the error:
https://developer.mescius.com/wijmo/demos/Grid/ImportExportPrint/PDF/ExportToFile/angular
After downloading the code (click the zip icon), I realized that this example used Angular 16 and wasn’t integrated into a real Angular application. So, I created a new Angular 17 application using the following command:
npx @angular/cli new
I chose “sass” for the style and responded “no” for server-side rendering (SSR). Then, I copied and pasted the example into this new Angular application.
Then, I served the application.
When I clicked on the export button, I reproduced the error.
In the provided zip file, make sure to use the pdf-export-bug branch and then run npm ci.
The problem seems to originate from the following function:
function _asPdfFont(e, t) {
void 0 === t && (t = true);
assert(null == e && t || e instanceof PdfFont, _Errors.InvalidArg(“value”));
return e;
}
More specifically, the problem seems to come from the instanceof PdfFont condition, which returns false even when setting the font as follows:
doc.setFont(new PdfFont(‘Helvetica’, 12));
We also noticed an error with the use of doc.drawSvg, where we get the following error message:
ERROR ** Assertion failed in Wijmo: This method cannot be used until the current path is finished.
I didn’t try to reproduce this error, because I think it is similar to the one encountered with exporting the grid to a PDF.
=> You just need to test your code examples in a real Angular 17 application.
Export pdf grid :
ERROR ** Assertion failed in Wijmo: Invalid argument: “value”. assert@http://localhost:4200/@fs/C:/aefface/Grid_ImportExportPrint_PDF_ExportToPdfDocument_Ang/pdf-export-wijmo/.angular/cache/17.3.6/vite/deps/chunk-C3FHCRWA.js?v=d01ed2a0:935:13
_asPdfPen@http://localhost:4200/@fs/C:/aefface/Grid_ImportExportPrint_PDF_ExportToPdfDocument_Ang/pdf-export-wijmo/.angular/cache/17.3.6/vite/deps/@mescius_wijmo__pdf.js?v=d01ed2a0:15056:9
pdf-export-wijmo.7z