Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow user to locate wrapped text lines #61

Closed
wants to merge 2 commits into from

2 participants

@ef4

This little changes adds an 'eachLine' option to 'text'. You can set
it to a callback that will be called with the arguments (text, x, y)
for each line of text that gets generated.

This makes it possible to figure out eactly where the text has been
placed in order to add annotations to it, or add other graphics that
need to be placed relative to the text.

ef4 added some commits
@ef4 ef4 Allow user to locate wrapped text lines
This little changes adds an 'eachLine' option to 'text'. You can set
it to a callback that will be called with the arguments (text, x, y)
for each line of text that gets generated.

This makes it possible to figure out eactly where the text has been
placed in order to add annotations to it, or add other graphics that
need to be placed relative to the text.
f930b1e
@ef4 ef4 Invoke the callback with the document as "this" 7ec1310
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 21, 2012
  1. @ef4

    Allow user to locate wrapped text lines

    ef4 authored
    This little changes adds an 'eachLine' option to 'text'. You can set
    it to a callback that will be called with the arguments (text, x, y)
    for each line of text that gets generated.
    
    This makes it possible to figure out eactly where the text has been
    placed in order to add annotations to it, or add other graphics that
    need to be placed relative to the text.
  2. @ef4
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/mixins/text.coffee
View
4 lib/mixins/text.coffee
@@ -129,6 +129,10 @@ module.exports =
# indentation support
x += indent
+ # user-accessible hook
+ if options.eachLine
+ options.eachLine.apply(this, [text, x, y])
+
# flip coordinate system
y = @page.height - y - (@_font.ascender / 1000 * @_fontSize)
Something went wrong with that request. Please try again.