* Render an embedded PDF from EMF using pdfjs-dist. * Populates the wrapper asynchronously — the wrapper is returned immediately.
( pdfData: Uint8Array, wrapper: HTMLElement, node: PicNodeData, ctx: RenderContext, mediaPath: string )
| 410 | * Populates the wrapper asynchronously — the wrapper is returned immediately. |
| 411 | */ |
| 412 | function renderEmfPdf( |
| 413 | pdfData: Uint8Array, |
| 414 | wrapper: HTMLElement, |
| 415 | node: PicNodeData, |
| 416 | ctx: RenderContext, |
| 417 | mediaPath: string |
| 418 | ): void { |
| 419 | const cacheKey = `${mediaPath}:emf-pdf` |
| 420 | const cached = ctx.mediaUrlCache.get(cacheKey) |
| 421 | if (cached) { |
| 422 | wrapper.appendChild(createFillImage(cached)) |
| 423 | return |
| 424 | } |
| 425 | |
| 426 | renderPdfToImage(pdfData, node.size.w, node.size.h) |
| 427 | .then((url) => { |
| 428 | if (url) { |
| 429 | ctx.mediaUrlCache.set(cacheKey, url) |
| 430 | wrapper.appendChild(createFillImage(url)) |
| 431 | } |
| 432 | }) |
| 433 | .catch(() => { |
| 434 | // PDF rendering failed — leave wrapper empty (transparent) |
| 435 | }) |
| 436 | } |
| 437 | |
| 438 | /** |
| 439 | * Render an embedded DIB bitmap from EMF. |
no test coverage detected