units in page size don't work any more
Describe the bug Variable dpi support in #1869 removed support for page sizes with units such as mm. The units should be converted to points before dividing by dpi.
To reproduce These pages should be the same size, but the first one has invalid dimensions:
<Page size={{ width:"105mm", height:"148.5mm" }} debug/>
<Page size="A6" debug/>
Here's the react-pdf REPL snippet.
Expected behavior mm values in page sizes should work as in @react-pdf/[email protected] and @react-pdf/[email protected].
Desktop (please complete the following information):
- OS: all
- Browser: all
- React-pdf version 3.0.0
Hi, i've countered the same problem, so right now how can i create custom page size? thanks...
Hi, i've countered the same problem, so right now how can i create custom page size? thanks...
@aditfurk one workaround is to use numeric units and convert the units to points. 1in = 72pt, and 2.54cm = 1in. So if you wanted to define a custom page size that is 10x14in, you can use <Page size={[10*72, 14*72]}></Page>.
For our use case though, this is not a viable solution because we have a large library of PDF templates that would have to be rewritten. I'm hoping for a PR to fix the issue in react-pdf instead.
@bernharduw ahh okay, thanks for the answer
Same here - page size specified in mm used to work, but it seems that since 3.* it's broken. Setting it to points after manually converting as @bernharduw does not solve my issue. The page size seems better but the height of items does not seem correct. If I set the same points size using [email protected] the page looks perfect.
If there's a breaking change somewhere from 3.0.0 I'd love to know where - and have it documented in the release notes. I went through them and could not find anything clearly stated. 2.* to 3.* is a major upgrade so I fully understand if there's breaking changes - just want to know what they are and what are the migration suggestions 🙇♂️
I believe "feat: variable dpi #1869" should be rolled back. Variable DPI should NOT be adjusting page size, but strictly image resolutions (the optional Resolution array %ALDImageResolution (see page 909 of PDF Reference 1.6).
The changes made in #1869 weren't properly tested before being merged. It broke how a pdf is supposed to be structured.
Ideally: Images should be embedded as-is without adjustments (any compression) as default. If a user provides a dpi prop for a page, then the image's resolution gets adjusted accordingly.
any updates on this?