Officegen and units

64 views
Skip to first unread message

Ziv Barber

unread,
Jul 25, 2019, 5:07:15 PM7/25/19
to node.js officegen package
As you may already know, I created officegen years ago by doing reverse-engineering to the Office documents without using any official documentation.
Back then I didn't know what I'm looking at and what the meaning of anything.

One result of this is the use of strange units for shapes.

So for example:

    slide.addText('Some text', {
      y: 66,
      x: 'c',
      cx: '50%',
      cy: 60
    })

Then what 66 stand for? what unit it is?
Since back then I didn't know what these big number stand for. Now I know that it's EMU.
Anyway, back then I just decided that the user will pass a number and I'll multiply it with 10000.

Anyway, this is not the right way to do it!

So since the next version, 0.6.1, you can use standard units for PowerPoint shapes:

- '1cm' = 1 cm
- '1mm' = 1 mm
- '1in' = 1 inch
- '1pt' = 1 point
- '1pc' = 1 pica
- '1em' = 1 EMU (in case that you want to use the original unit that also used by Office itself).

For now you can use it for the following options data members:

y
x
cy
cx
bodyProps.bIns
bodyProps.lIns
bodyProps.rIns
bodyProps.tIns

The normal numbers will stay in the special "officegen unit" of 10000 EMU = 1 officegen "unit".

That's all for today,
Ziv Barber
officegen creator

Reply all
Reply to author
Forward
0 new messages