-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow units for page size #2773
Conversation
🦋 Changeset detectedLatest commit: baec01d The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
Thank you for merging #2771 @diegomura, in addition I also merged the branch and prepared this PR. |
Could you have a look on this please @diegomura? Thank you so much! |
Bump @diegomura :) |
Update version update to minor (see separate comment)
Co-authored-by: Diego Muracciole <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nikischin !
# By Diego Muracciole (31) and others # Via GitHub * upstream/master: (60 commits) feat: allow units for page size (diegomura#2773) chore: bump jay-peg chore: release packages (diegomura#2981) fix(textkit): make indentation only affect first line. (diegomura#2975) fix: conditional rendering (diegomura#2983) fix(reconciler): missing dependencies (diegomura#2980) chore: release packages (diegomura#2959) feat: rem border widths (diegomura#2960) fix: add scheduler dependency (diegomura#2958) chore: update README chore: release packages (diegomura#2953) feat: support rem units (diegomura#2955) feat: add image stress test example (diegomura#2954) feat: support multiple line-height units (diegomura#2952) chore: release packages (diegomura#2946) fix: note rendering (diegomura#2951) feat: accept commas between transformations (diegomura#2950) fix: document metadata setters (diegomura#2949) fix: stroke dash array computation (diegomura#2948) feat: remove cross-fetch (diegomura#2947) ... # Conflicts: # packages/renderer/index.d.ts
In addition to #2771 I also implemented the support for units
"in"
,"cm"
,"mm"
to the<Page/>
size
attribute.Includes the fixes for the dpi from #2771 already but had to be a bit rewritten.
implements #2008
fixes #2885
Some background about this and also #2771:
The PDF spec doesn't really have DPI and always expects the unit to be
user points
which always expects points in an PDF to be1/72 of an inch
. So any unitless value in a PDF always should be considered auser point
. The dpi setting then should represent auser unit
which defaults to72 dots per inch
and can change this conversion to anything else.Please check out more details to this here or here
The thing with PDF is, you always want to have a font set to 12pt to be the same size no matter what dpi setting you have. You can check on Adobe Indesign and create two pdfs, one with 72dpi and one with 300dpi, and in both the font will have the same size (relative to the page size) if set to 12pt (which equals 12 user points). This was not working before the fix and was therefore super confusing. Why should the complete layout of the page change when I change the dpi setting?
Please note that debug mode also represents the user points and not pixels.
Expected behavior
A page with
"A4"
will result in595 x 841
points no matter what dpi is setA page with
{{width: "210mm", height: "297mm"}}
will result in595 x 841
points no matter what dpi is setA page with
{{width: 595, height: 841 }}
will result in595 x 841
points no matter what dpi is setA page with
{{width: "595px", height: "841px" }}
will result in595 x 841
points on72 dpi
, but only142 x 202
points on300dpi
A element with a width of
590
points will almost fill the page for a A4 page no matter what dpiA element with a width of
"99vw"
will almost fill the page for a A4 page no matter what dpiA element with a width of
"590px"
will almost fill the page for a A4 page on 72dpi but will only fill about 1/4 or 1/5 on 300dpi