Pdfkit: Setting just a single coordinate?

Created on 6 Mar 2019  路  2Comments  路  Source: foliojs/pdfkit

Question

Quick question I can't seem to find in the documentation:

I am making modular extensions to the class prototype, and one method I am trying to add requires that ONLY the Y coordinate be specified. Example I am trying to do:

doc.text("text", NULL, YCoordinate, options)

However, my options contain align: center, so everything gets messed up.

Is there an easy way to do this that I am missing? When I set the X coordinate to null I just get left aligned, even if the options specify align: center.

Most helpful comment

Supplying an x and y coordinate to the text function is just shorthand for setting x and y directly on the doc. Both of these are identical and should work for you:

doc.text("text", doc.x, YCoordinate, options)
// or
doc.y = YCoordinate
doc.text("text", options)

All 2 comments

Supplying an x and y coordinate to the text function is just shorthand for setting x and y directly on the doc. Both of these are identical and should work for you:

doc.text("text", doc.x, YCoordinate, options)
// or
doc.y = YCoordinate
doc.text("text", options)

combining it all in one call did not work for me, but I may have been doing something wrong.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

huy-nguyen picture huy-nguyen  路  4Comments

tadarao picture tadarao  路  5Comments

leore picture leore  路  3Comments

raesche picture raesche  路  4Comments

alFReD-NSH picture alFReD-NSH  路  4Comments