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

#228 Placeholder object for Master Slides #359

Closed
wants to merge 6 commits into from

Conversation

conbow
Copy link
Contributor

@conbow conbow commented Jun 21, 2018

#228

  • Added new placeholder type to master slides objects
  • Updated example/demo page to use new API
  • Refactored some reused code
  • Tested working with text, image, and charts

- Added new `placeholder` type to master slides objects
- Updated example/demo page to use new API
- Refactored some reused code

Closes gitbrent#228
@gitbrent gitbrent self-assigned this Jun 23, 2018
@gitbrent
Copy link
Owner

Hi @conbow

Thanks for the patch.

The placeholder master slide's appear fine, but when adding other text to them, it's pushed to the very bottom and stuck into what looks like the last master slide's object - the footer bar in this case:

var pptx = new PptxGenJS();
pptx.setLayout('LAYOUT_WIDE');
pptx.defineSlideMaster({
  title : 'MASTER_SLIDE',
  margin: [0.5, 0.25, 1.25, 0.25],
  bkgd  : 'EEEEEE',
  objects: [
    {rect: { x:0, y:6.9, w:'100%', h:0.6, fill:'003b75' }},
    {text: { text:'S.T.A.R. Laboratories', options:{x:0.17, y:0.1, color:'FFFFFF'} }}
  ],
  slideNumber: { x:1.0, y:7.0, color:'FFFFFF' }
});

var slide = pptx.addNewSlide('MASTER_SLIDE');

// Bullets with indent levels
slide.addText(
  [
    { text:'1st line', options:{ fontSize:24, bullet:true, color:'99ABCC' } },
    { text:'2nd line', options:{ fontSize:36, bullet:true, color:'FFFF00', indentLevel:1 } },
    { text:'3rd line', options:{ fontSize:48, bullet:true, color:'0088CC', indentLevel:2 } }
  ],
  { x:1.5, y:1.5, w:6, h:2, margin:0.1, fill:'232323' }
);

pptx.save('PptxGenJS-patch');

screen shot 2018-07-09 at 23 03 55

Without including
screen shot 2018-07-09 at 23 07 04
a master slide, the results are correct:

My merged, WIP branch is:
pr/359

@conbow
Copy link
Contributor Author

conbow commented Jul 10, 2018

@gitbrent Thanks for catching this. There was a missing condition that allowed the p:ph tag to be incorrectly added to objects that shouldn't have had it. I've pushed a fix for this, as well as some minor code styling fixes to more closely match the style of the repo.

@gitbrent
Copy link
Owner

Awesome, the placeholder ph tag checkin fixed the issue:

screen shot 2018-07-11 at 20 19 53

@gitbrent gitbrent added this to the 2.3.0 milestone Aug 21, 2018
@gitbrent
Copy link
Owner

Thanks @conbow - great work on adding support for placeholder!

This was a feature that was much requested and sorely lacking.

Patch #393 implements this feature. The only change I made was to utilize name instead of idx for targeting objects to given placeholders.

// Master
pptx.defineSlideMaster({
    title: 'THANKS_SLIDE',
    bkgd: '36ABFF',
    objects: [
        { 'placeholder': { options:{ name:'thanksText', type:'title', x:0.0, y:0.9, w:'100%', h:1, color:'FFFFFF' } }}
    ]
});

// Add text to placeholder
slide.addText('Thank You!', { placeholder:'thanksText' });

@gitbrent gitbrent closed this Aug 21, 2018
gitbrent added a commit that referenced this pull request Aug 21, 2018
@adong
Copy link

adong commented Nov 29, 2018

@gitbrent Could you give an example of using image with corp, as placeholder?
I could not get it to work. Thank you.

My mistake, I was using pptxgen 2.2.0

	var APP_VER = "2.2.0";
	var APP_BLD = "20180617";

After I upgrade to 2.4.0, it works fine.

ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this pull request Mar 24, 2020
ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this pull request 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

Successfully merging this pull request may close these issues.

3 participants