[WC-3431]: Doc Viewer Checkbox Fix#2262
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| ## Risks / Trade-offs | ||
|
|
||
| - `window.location.origin` is not available in SSR/test environments. Tests currently stub this or don't exercise PDF rendering — no impact. If server-side rendering is ever added, this will need to be guarded. | ||
| - If the Mendix app is served from a subpath (e.g. `/app/`), `origin` alone is correct — fonts live under `/widgets/`, not the subpath. |
There was a problem hiding this comment.
I would think fonts will live under that subpath as well. This needs checking.
Use mx.appUrl (with window.location.origin fallback) for cMapUrl and standardFontDataUrl so the PDF.js worker can resolve font and cmap resources when loaded from a cross-origin URL. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
AI Code Review
What was reviewed
Skipped (out of scope): Findings
|
Pull request type
Bug fix (non-breaking change which fixes an issue)
Description
Fix PDF standard font rendering in Document Viewer
Problem: PDFs containing glyphs from ZapfDingbats (e.g. checkmarks generated by .NET PDF libraries) rendered as blank rectangles in Document Viewer. The browser's native PDF viewer displayed them correctly.
Root cause: standardFontDataUrl and cMapUrl were relative paths. The PDF.js worker is loaded from //unpkg.com (cross-origin), so fetch() in the worker context has no document origin to resolve relative URLs against — throwing TypeError: Failed to parse URL.
Fix: Prepend window.location.origin to both URLs, making them absolute and resolvable from any worker origin.
Tested with: