-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
[Feat?] make slide masters/layouts editable. #85
Comments
Hi Matt, I really like your idea, but I'm afraid, this is more complicated than expected. :) It's basically because a modification applies only on adding it - regardless of a shape's location (slide or slideMaster). It can't be modified in place, this would require some more refactoring. But I could imagine a shurtcut like this: const pres = await automizer
.loadRoot(`EmptyTemplate.pptx`)
.load('SlideWithShapes.pptx')
// modifyMaster could wrap around addMaster:
.modifyMaster('SlideWithShapes.pptx', 1, (master) => {
master.modifyElement(
`MasterRectangle`,
ModifyTextHelper.setText('my text on master'),
);
}) This is similar to |
Yes, I agree. I was thinking something that wrapped add master that 'offloaded' looking up the relationship and deduplication (in practice i suppose addMaster actually would overwrite the existing master). If we have one master applied to many slides it should ensure we are not actually copying the master each time and it remains a single master file. Thinking about this further though there would potentially be cases where the master is on the root template, is there a way we could edit this once, without calling .addMaster on each slide manually. |
I tried adding the masters making the modifications, then removing the originals. It does add the masters then remove the old ones; however, I am running into the repair issue. I believe the issue might be that the If the default master id were increased, I think it may solve the issue?
async function removeMasters(pres, length, from) {
const xml = await XmlHelper.getXmlFromArchive(
pres.rootTemplate.archive,
`ppt/presentation.xml`,
);
const existingMasters = xml.getElementsByTagName('p:sldMasterId');
XmlHelper.sliceCollection(existingMasters, length, from);
XmlHelper.writeXmlToArchive(
await pres.rootTemplate.archive,
`ppt/presentation.xml`,
xml,
);
await pres.modify(ModifyPresentationHelper.normalizeSlideMasterIds);
} |
Big surprise it's more complicated than that. I don't think FileHelper is the correct function to use here? possibly remove from
|
Hi @jhaase1! Thanks a lot for your code. I've edited it a little and moved it to pptx-automizer/src/helper/modify-presentation-helper.ts Lines 190 to 200 in 7948705
Please check out Some thoughts on it:
Please let me know if this is useful! |
I think this would be 'not too difficult' to add; we just need to work out how to present it to the user.. maybe slide.modifyMaster()?
I appreciate the same can be achieved by re adding the master pres.addMaster() that's already there but this seems really inefficient and requires user to have already looked up the slide master relationship.
This would enable us to change text or logos that are stored in the masters. For example if a user puts the customer name and logo in the master we can still automate that without requiring them to pull them out of the master.
What do you think?
Alongside this I'd also like to work on getting slide backgrounds something we can edit.
The text was updated successfully, but these errors were encountered: