Pdfmake: Manual Positioning

Created on 19 Feb 2017  路  10Comments  路  Source: bpampuch/pdfmake

I wonder if we can put contents in any given position individually, despite their order in the content array, like absolute position in HTML.
I know that there is a trick using textAlign: 'right' and margin.
for example: margin: [100, 30, 0, -15-30], will put the content in right: 100 and top: 30. (-15 removes fontSize: 15 and extra 30 for top value)

Most helpful comment

would be nice to have this added to the docs

All 10 comments

Example with absolute positioning:

var dd = {
   content: [
        {
            text: 'text 1',
            absolutePosition: {x:123, y:200}
        },
        {
            text: 'text 2',
            absolutePosition: {x:400, y:250}
        },
        {
            text: 'text 3',
            absolutePosition: {x:300, y:270}
        },
    ]
}

thanks a lot >:D<

would be nice to have this added to the docs

Example is available in examples folder: https://github.com/bpampuch/pdfmake/tree/master/examples

Is there an easy way to get the current position of text so I can absolutely position _relative_ to it?

@chis: a variable+/-X?

I found the answer (silly me) there's a relativePosition parameter. That's awesome! exactly what I needed!

Necroing, but would be nice to see it added to the docs anyway, or see some comments in code at least about positions (relative to what? or can I do absolute from bottom of page? etc)

This just saved me centering a QR code on multiple pages, margin wasn't working well, please add this to the documentation it will be helpfull for other people.

Example with absolute positioning:

var dd = {
   content: [
        {
            text: 'text 1',
            absolutePosition: {x:123, y:200}
        },
        {
            text: 'text 2',
            absolutePosition: {x:400, y:250}
        },
        {
            text: 'text 3',
            absolutePosition: {x:300, y:270}
        },
    ]
}

Are we able to set "current position" like moving the cursor in a text editor? A workaround seems to be using margins. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

einfallstoll picture einfallstoll  路  3Comments

davidyeiser picture davidyeiser  路  3Comments

ValeSauer picture ValeSauer  路  3Comments

m-brudi picture m-brudi  路  3Comments

sayjeyhi picture sayjeyhi  路  3Comments