react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

fix for dynamic image render

Open Justinio99 opened this issue 2 years ago • 3 comments

There are ongoing challenges with dynamically rendering the <Image /> component. The primary issue identified was the absence of image properties on the child node. To rectify this, I introduced a new validation step for the Image type, ensuring the creation of a new node instance with the appropriate attributes.

  if (isImage(element)) {
    const node = { props, type, style, box: {} };
    await fetchImage(node);
    return [node];
  }

To facilitate this solution, I needed to modify several functions to execute asynchronously, particularly because fetchImage was already an asynchronous function.

As my expertise with react-pdf is limited, I'm hopeful that this solution proves effective. I'm more than open to feedback and help in this area.

Justinio99 avatar Dec 19 '23 14:12 Justinio99

🦋 Changeset detected

Latest commit: 5c2d111c9e90b69e4964749bc2efb72e5348b2ce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@react-pdf/layout Minor
@react-pdf/renderer Patch
@react-pdf/examples Patch
@react-pdf/e2e-node-cjs Patch
@react-pdf/e2e-node-esm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Dec 19 '23 14:12 changeset-bot[bot]

Tests do not pass for me with the fix.

mskec avatar Jan 05 '24 13:01 mskec

Would appreciate this fix a lot! :)

jrtell1 avatar Jan 19 '24 08:01 jrtell1