vectorDoc
.rotate(90, {origin: [650, 45]})
.fillColor(is_express ? 'red' : 'black')
.font('OpenSans-Light')
.fontSize(12)
.text('hello', 650, 53)
Seems to make my script fail, I've even tried setting rotation to 89.9, tried this as well:
vectorDoc
.save()
.rotate(90, {origin: [650, 45]})
.fillColor(is_express ? 'red' : 'black')
.font('OpenSans-Light')
.fontSize(12)
.text('hello', 650, 53)
.restore()
I've tried removing the font/fontSize options but nothing seems to work. Using the latest npm version with pdftk 2.01 a Handy Tool for Manipulating PDF Documents
Up
So, after some researches, I decided to open this StackOverflow question, and @olance gave me a really helpful answer, that lead me to fix my issue, so if you want to rotate text, you may want to read it.
http://stackoverflow.com/questions/41469801/is-there-any-trick-to-rotate-text-in-pdfkit
This is essentially what I ended up doing, completely forgot about this issue though, thanks for updating me and this issue. Hopefully it'll help others in the future :+1:
The best way to write rotated text is to rotate pdf around certain point, then write it normally and rotate the pdf document back.
Code example:
doc.rotate(angle, { origin: [x,y] };
doc.text( 'TEST', x, y);
doc.rotate(angle * (-1), { origin: [x,y] };
This way you don't need to calculate new position.
Most helpful comment
The best way to write rotated text is to rotate pdf around certain point, then write it normally and rotate the pdf document back.
Code example:
doc.rotate(angle, { origin: [x,y] };
doc.text( 'TEST', x, y);
doc.rotate(angle * (-1), { origin: [x,y] };
This way you don't need to calculate new position.