yunguo qin
yunguo qin

Reputation: 11

How to convert pixels to inches using PptxGenJs library?

Need help. I am using PptxGenJs library. I want to convert Html pixels to Ppt inches, I tried slide methods.

Sample code:

slide.addText('some message', {
  x: 1,
  y: 1,
  w: 10,
  h: 3
});

what does mean 'x: 1, y: 1' and 'w: 10, h: 3'?

Upvotes: 1

Views: 182

Answers (1)

Gungnir
Gungnir

Reputation: 359

PowerPoint thinks in "paper pages" dimensions so those are inches.

You can safely convert from pixels in inches in pptx by dividing with 96. If your image has 960px wide it will be 960/96 10inches so you put w: 10. PPTXGenJS will try to maintain ratio with sizing: {} options but you need to put those w/h of the image to work.

For x,y these are in inches too and are the position on the page you could do the same conversion.

Upvotes: 1

Related Questions