Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate working incorrectly #370

Closed
michaelcbrook opened this issue Jul 2, 2018 · 11 comments
Closed

Rotate working incorrectly #370

michaelcbrook opened this issue Jul 2, 2018 · 11 comments
Assignees
Milestone

Comments

@michaelcbrook
Copy link
Contributor

When I rotate text, it becomes skewed on LibreOffice, and in MS Office, it gets rotated completely in a different direction. I've checked that I'm doing it right, but not getting the expected result.

The expected result:

screenshot from 2018-07-01 23 17 08

The actual result (in LibreOffice):

screenshot from 2018-07-01 23 14 06

Can also provide a screenshot with MS Office if necessary. Just cumbersome for me to get it.

Thank you!

@gitbrent
Copy link
Owner

gitbrent commented Jul 3, 2018

Hi @michaelcbrook

What code are you using and can you provide a screenshot of the expected result in PPT?

@michaelcbrook
Copy link
Contributor Author

Yes, you can duplicate the issue with the code below (I automatically generate these measurements):

const pptx = new PptxGenJS();

const slide = pptx.addNewSlide();

slide.addText("This is a test This is a test This is a test", {
  w: 3.915895061728395,
  h: 0.2022839506172839,
  x: 3.76929012345679,
  y: 4.322916666666667,
  rotate: 306,
  align: 'center',
  fontSize: 12.888888888888888,
  isTextBox: true,
  inset: 0,
  margin: 0,
  valign: 'middle'
});

//send file to output
pptx.save("https", (data) => {
  const headers = {
    'Content-Type': 'application/vnd.openxmlformats',
    'Content-Disposition': 'attachment; filename=Test.pptx',
    'Content-Length': data.length
  };
  res.writeHead(200, headers);
  res.end(new Buffer(data, "binary"));
});

Expected output:

screenshot from 2018-07-03 16 38 36

Actual output (using MS Office PowerPoint):

screenshot from 2018-07-03 16 39 43

Actual output (using LibreOffice):

screenshot from 2018-07-03 16 38 56

I'm using the 2010 version of MS Office PowerPoint here, but I've verified with a colleague that the same result happens on more recent versions of PowerPoint.

gitbrent added a commit that referenced this issue Jul 7, 2018
@gitbrent gitbrent self-assigned this Jul 7, 2018
@gitbrent gitbrent added this to the 2.3.0 milestone Jul 7, 2018
@gitbrent
Copy link
Owner

gitbrent commented Jul 7, 2018

Thanks @michaelcbrook !

The incorrect rotation angle issue has been fixed in the current codebase. This also should fix the skewing you reported in LibreOffice. Let me know if that issue persists.

screen shot 2018-07-07 at 18 09 56

gitbrent added a commit that referenced this issue Jul 7, 2018
@michaelcbrook
Copy link
Contributor Author

Awesome. Thank you! Any chance you could push this change to NPM also? I haven't tested the new change yet since I'm still trying to use the NPM package.

@gitbrent
Copy link
Owner

Sure, it'll be in the upcoming 2.3.0 release.

@michaelcbrook
Copy link
Contributor Author

Hate to open this back up, but it looks like this issue isn't totally resolved. The angle of the rotated text seems right, but its position is not. The same code given above results in the text starting off the page.

screenshot from 2018-08-05 19 46 27

Should be more or less centered on the page:

screenshot expected output

The code again:

const pptx = new PptxGenJS();

const slide = pptx.addNewSlide();

slide.addText("This is a test This is a test This is a test", {
  w: 3.915895061728395,
  h: 0.2022839506172839,
  x: 3.76929012345679,
  y: 4.322916666666667,
  rotate: 306,
  align: 'center',
  fontSize: 12.888888888888888,
  isTextBox: true,
  inset: 0,
  margin: 0,
  valign: 'middle'
});

//send file to output
pptx.save("https", (data) => {
  const headers = {
    'Content-Type': 'application/vnd.openxmlformats',
    'Content-Disposition': 'attachment; filename=Test.pptx',
    'Content-Length': data.length
  };
  res.writeHead(200, headers);
  res.end(new Buffer(data, "binary"));
});

I appreciate your help with this!

@gitbrent
Copy link
Owner

gitbrent commented Aug 8, 2018

Hi @michaelcbrook

Your example comes out correctly using the latest build (2.3.0-beta.20180706).

var pptx = new PptxGenJS();
pptx.setLayout('LAYOUT_WIDE');
var slide = pptx.addNewSlide();

slide.addText("This is a test This is a test This is a test", {
  w: 3.915895061728395,
  h: 0.2022839506172839,
  x: 3.76929012345679,
  y: 4.322916666666667,
  rotate: 306,
  align: 'center',
  fontSize: 12.888888888888888,
  isTextBox: true,
  inset: 0,
  margin: 0,
  valign: 'middle'
});

Result:
screen shot 2018-08-07 at 21 50 13

@michaelcbrook
Copy link
Contributor Author

I'm afraid it doesn't because your code is different. You've added pptx.setLayout('LAYOUT_WIDE'); If you remove that part, it comes out like mine.

I've essentially created a script that translates object properties drawn in a canvas into PPT objects using this library. My first inclination is that maybe I got the translation wrong, but everything else aligns perfectly, except for rotated objects. Rotated images don't work at all.

Expected output:
screenshot from 2018-08-08 13 14 19

Actual output:
screenshot from 2018-08-08 13 14 36

It's difficult to post all the code, but here are the object properties for the rotated text element:

{ w: 2.797067901234568,
 h: 0.2022839506172839,
 x: 5.44753086419753,
 y: 4.099151234567901,
 rotate: 270,
 align: 'center',
 bold: false,
 color: '181818',
 fontFace: 'Open Sans',
 fontSize: 12.888888888888888,
 isTextBox: true,
 italic: false,
 underline: false,
 inset: 0,
 margin: 0,
 valign: 'middle' }

And canvas is set to size: LAYOUT_16x9

I hope this helps, and thank you!

@ACPrice
Copy link

ACPrice commented Apr 17, 2019

I think this issue does need to be reopened, unfortunately. I'm seeing the same (incorrect) rotation behavior. I'm on 2.5.0. Also: thanks for the very useful library!

I'm adding a slide like so:

slide.addText('Text Here', {
      shape: pptx.shapes.RECTANGLE,
      x: 0,
      y: 0,
      w: 5,
      h: 5,
      align: 'left',
      valign: 'top',
      line: '000000',
      line_size: 1,
      font_size: fontSize,
      rotate: -90
})

One other note: I'm setting the layout after adding several slides. I'm not sure if setting layout after adding a rotated slide is a possible issue.

If useful, I can provide actual output, but it's similar to @michaelcbrook. The text is rotated, but into the wrong position. It's doesn't seem to be rotating about the center of the text box nor about any other obvious point (i.e. top left corner of box).

@ACPrice
Copy link

ACPrice commented Apr 23, 2019

@gitbrent Thanks again for the fantastic repo. I'm curious if this issue is likely to get another look in the foreseeable future. Trying to figure out if I should implement a workaround on a project.

@gitbrent
Copy link
Owner

Hi @ACPrice

There must be something about your process flow that is causing this as normal test cases work correctly.

Regarding the Aug 2018 comment, whether setLayout is used or not the result is a rotated object at 306*
Screen Shot 2019-04-23 at 22 06 13

Your current code works as well - resulting in an object rotated -90*

Screen Shot 2019-04-23 at 22 10 18

Screen Shot 2019-04-23 at 22 08 48

ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this issue Mar 24, 2020
ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this issue Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants