Enhancement suggestion -- allow getting document width/height in non-pixel units
Closed this issue · 2 comments
gatesphere commented
It would be tremendously handy in my use to be able to fetch the size of a vpype.document object in a defined unit, like:
doc.get_width('in') -> float (document width in inches)
abey79 commented
There isn't any explicit API for that, but you may use vpype.Document.page_size
and vpype.UNITS
to the same effect. Both are public API so it shouldn't break in the future.
import vpype
# a document with some page size
doc = vpype.Document()
doc.page_size = (100, 200)
# document width in inches
print(doc.page_size[0] / vpype.UNITS['in'])
# -> 1.0416666666666667
Edit: to be clear, I'd certainly consider a PR with a proper API for that ;)
gatesphere commented
Good enough for me, thanks.