PptxGenJS icon indicating copy to clipboard operation
PptxGenJS copied to clipboard

Overriding scheme colors?

Open igorski89 opened this issue 5 years ago • 3 comments

Hi @gitbrent !

Thank you very much for all the work you've put into this project!

Lately I've been working on a project using this library and had a quite a pleasant time using it.

One of the tasks I had at hand is to override the default theme colors: Screenshot 2019-10-05 at 17 41 53

Looking at the current APIs https://gitbrent.github.io/PptxGenJS/docs/shapes-and-schemes.html#powerpoint-scheme-colors it appears to be read-only.

In PowerPoint itself, this is possible to customize through the Slide Master editor.

Having a rather limited knowledge of the pptx format, I poked around and compared the contents of the standard and slightly customized color scheme via saved pptx files and quickly discovered the color scheme is stored inside ppt/theme/theme1.xml: Screenshot 2019-10-05 at 17 27 03

I was thinking to prepare a PR with a new API, something in line of defineSlideMaster:

const pptx = new PptxGenJS();
pptx.defineThemeColors({
   accent1: 'FF40FF',
   ...
});

would something like be ok? And do you prefer a PR against the master or the version-3.0 branch?

Looking forward to your feedback!

igorski89 avatar Oct 05 '19 15:10 igorski89

Hi @igorski89

Thanks for the feedback.

I think this would be a very useful feature. You're correct in your assessment, we'll just need some new variables to hold the 6 Scheme and 2 Background colors and a method as you've shown allowing users to override any of the preset values.

Please use the version-3.0 branch as it's nearly complete and will be live soon.

gitbrent avatar Oct 08 '19 02:10 gitbrent

hey @gitbrent sorry to disturb you. I just had some time to develop this feature, started with a test project, switched to the version-3.0 branch in package.json:

"dependencies": {
    "pptxgenjs": "gitbrent/PptxGenJS#version-3.0"
  }

but when running my script I get the following exception:

/Users/igorievsiukov/code/betterppt/node_modules/pptxgenjs/dist/pptxgen.min.js:2
var PptxGenJS=function(d){"use strict";var n,a,i,e,R=914400,N=12700,g="\r\n",s=2147483649,o=/^[0-9a-fA-F]{6}$/,u=1.67,E={color:"666666"},F=[3,3,3,3],m={color:"888888",style:"solid",size:1},A="000000",y=12,f=18,t="LAYOUT_16x9",r="DEFAULT",v=[.5,.5,.5,.5],c={type:"outer",blur:3,offset:23e3/12700,angle:90,color:"000000",opacity:.35,rotateWithShape:!0},h="2094734552",b="2094734553",x="2094734554",C="2094734555",L="2094734556",P="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),T=["C0504D","4F81BD","9BBB59","8064A2","4BACC6","F79646","628FC6","C86360","C0504D","4F81BD","9BBB59","8064A2","4BACC6","F79646","628FC6","C86360"],S=["5DA5DA","FAA43A","60BD68","F17CB0","B2912F","B276B2","DECF3F","F15854","A7A7A7","5DA5DA","FAA43A","60BD68","F17CB0","B2912F","B276B2","DECF3F","F15854","A7A7A7"];(a=n=n||{}).left="left",a.center="center",a.right="right",a.justify="justify",(e=i=i||{}).b="b",e.ctr="ctr",e.t="t";var p,l,w,B,I,O,D,j,k,M,U,z,G="{F7021451-138

ReferenceError: JSZip is not defined
    at Object.<anonymous> (/Users/igorievsiukov/code/testpptx/node_modules/pptxgenjs/dist/pptxgen.min.js:2:189179)
    at Module._compile (internal/modules/cjs/loader.js:971:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10)
    at Module.load (internal/modules/cjs/loader.js:822:32)
    at Function.Module._load (internal/modules/cjs/loader.js:730:14)
    at Module.require (internal/modules/cjs/loader.js:864:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/igorievsiukov/code/testpptx/index.js:3:19)
    at Module._compile (internal/modules/cjs/loader.js:971:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10)

i double-checked and JSZip is installed in node_modules and is perfectly functional.

Google search didn't helped much, would you be able to help me with some guidance how to setup version-3.0 as a dependency for development and contribution?

Thank you very much in advance!

igorski89 avatar Nov 09 '19 16:11 igorski89

Hey, any status updates on this one? Would be interested in picking this up if there's nothing in-progress as I'm looking for this functionality myself :)

CampbellPedersenHA avatar Jun 16 '23 01:06 CampbellPedersenHA