Skip to content
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

Support for units #154

Open
HackbrettXXX opened this issue Sep 24, 2020 · 0 comments
Open

Support for units #154

HackbrettXXX opened this issue Sep 24, 2020 · 0 comments

Comments

@HackbrettXXX
Copy link
Member

Currently, svg2pdf does not support units (except for some rare exceptions) and treats every dimension value as in PDF units. The PDF unit is specified in the jsPDF constructor (e.g. new jsPDF({ unit: "mm" })).

We should really support different units.

Resources:

In order to implement this, we should add a method to the Context class that converts a dimension value with unit into a unit-less dimension value. For relative dimensions there is already a viewPort property on the Context with the current viewport.

In order to implement units by specification, we should also factor out the PDF unit/scaleFactor, meaning we need to

  • apply the inverse scale factor. We can access the current jsPDF scaleFactor like this: pdf.internal.scaleFactor.
  • apply a scale that converts between CSS pixels and PDF user space units (pt). The factor is 72/96. See also here.

We can combine these factors to a matrix that is applied once "around everything" in the svg2pdf method.

After this we can replace/remove the toPixels method in the utils/misc file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant