Open SethThoburn opened 9 months ago
If you're in a pinch and need a workaround... you can add resolveAssets
a second time to asyncCompose
above resolvePagination
. Theoretically, this wouldn't work correctly if the size of images was dependent on the page number, but that's not an issue for my use case.
This is in packages/layout/src/index.js
. I applied the change with yarn patch-package.
const layout = asyncCompose(
resolveZIndex,
resolveOrigins,
resolveAssets,
resolvePagination,
resolveTextLayout,
resolvePercentRadius,
resolveDimensions,
resolveSvg,
resolveAssets,
resolveInheritance,
resolvePercentHeight,
resolvePagePaddings,
resolveStyles,
resolveLinkSubstitution,
resolveBookmarks,
resolvePageSizes,
resolveYoga,
);
I am also getting the same issue.
Tried doing the patch using pnpm but not sure I got it correctly also the issue is with the package @react-pdf/layout
that is being referenced in @react-pdf/renderer
. But this doesn't seem to be working correctly, probably due to the patch not being properly configured rather than the solution itself.
Is there any other solution? I will see if I can have some time to try and deep into the root problem.
Yes, I spent a bit longer fighting with the configuration. You have to update your package.json so yarn applies the patch to dependencies of dependencies. I'm not certain how this works with pnpm.
"resolutions": {
"@react-pdf/layout@^3.11.2": "patch:@react-pdf/layout@npm%3A3.11.2#~/.yarn/patches/@react-pdf-layout-npm-3.11.2-0ee6b2ccb4.patch"
}
Thanks it was actually quite easy with pnpm as I can see the changes reflected in the package in node_modules but it still wasn't working for me.
I did find an alternate solution that worked for me which is to use the url of the static file. I am using NextJS so accessing the files through the url is simple enough and will leave that there until this issue is fixed for local files.
Describe the bug Images throw an error in a view render prop.
To Reproduce
TypeError [Error]: Cannot read properties of undefined (reading 'width') at drawImage
The error is in this file: packages/render/src/primitives/renderImage.js Happens because image source isn't resolved. I'm new to this library, so couldn't fix it, but I think I see the issue after some digging. This file doesn't look into render functions: packages/layout/src/steps/resolveAssets.js
Expected behavior The image is displayed