diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.91k stars 1.18k forks source link

Missing `layoutData` in `onRender` method of `<Document/>` #1360

Closed jeremy-christian closed 1 year ago

jeremy-christian commented 3 years ago

Hi there!

Not sure how to flag this, but moving from V1 -> V2 the layoutData property passed to the onRender arguments for the Document component has disappeared?

I cannot remember if this property was ever documented, but I've been using it to dynamically build a contents page on-the-fly.

const onRender = ({layoutData}) => {
 // do my thing
}
return <Document onRender={onRender}>{children}</Document>

I'm struggling to figure out what happened to it, anyone who could point me in the right direction would be much appreciated! 😁

diegomura commented 3 years ago

I think this got accidentally deleted on v2. I'll work on adding it back asap. Thanks for raising this and sorry

jeremy-christian commented 3 years ago

I think this got accidentally deleted on v2. I'll work on adding it back asap. Thanks for raising this and sorry

That's amazing thank you so much.

It'd be really handy to have it documented too - it turned out to be a massive help when doing multiple re-renders for content specific pages - like table-of-content pages.

evgimov commented 3 years ago

@diegomura Any updates on when it is going to be added?

diegomura commented 3 years ago

@evgimov no updates here

manuschillerdev commented 2 years ago

We would also need to have access to layoutData in onRender as well. I'd love to contribute bringing the feature back to react-pdf@@v2, but I'd need some small hints in the right direction @diegomura - would you be open to a contribution regarding this feature?

manuschillerdev commented 2 years ago

I tried to use https://github.com/diegomura/react-pdf/pull/421 as a starting point, but the APIs have changed too much in the past 4 years for me to understand where I'd need to start :/

manuschillerdev commented 2 years ago

@diegomura since I'm still stuck with this feature - would it be possible to sponsor this feature to bring layoutData back? :) If you are interested you can get in touch via DM as well any time https://twitter.com/ManuSchiller/

bastiampos commented 1 year ago

@diegomuraI I need dimensions and having layoutData in onRender can be very helpful. I would appreciate it if you add it again please!

jeetiss commented 1 year ago

I released the new version with _INTERNAL__LAYOUT__DATA_ in onRender callback. Use it at your own risk