Masters and Placeholders

defineSlideMaster() and defineLayout(): reusable backgrounds, logos and placeholders.

0Namespaces used by the C# samples

using NetCorePpt;                  // PptxGen, Slide
using NetCorePpt.CoreInterfaces;   // option objects: TextProps* / ShapeProps / ImageProps / TableProps / HAlign / VAlign ...
using NetCorePpt.CoreEnums;        // ShapeType, ChartType, MediaType, ShadowType, BulletType, DashType, SCHEME_COLORS ...
using TableRow = System.Collections.Generic.List<NetCorePpt.CoreInterfaces.TableCell>;

Slide Masters

Generating sample slides like those shown in the Examples section are great for demonstrating library features, but the reality is most of us will be required to produce presentations that have a certain design or corporate branding.

NetCorePpt lets you define Slide Master Layouts in code. Define a master once, then pass its title to addSlide() to get a slide that already carries its branding.

Slide Masters are created by calling the defineSlideMaster() method along with an options object (same style used in Slides). Once defined, you can pass the Master title to addSlide() and that Slide will use the Layout previously defined. See the demo under /examples for several working examples.
The defined Masters become first-class Layouts in the exported PowerPoint presentation and can be changed via View > Slide Master and will affect the Slides created using that layout.

Properties

Slide Master Props ( SlideMasterProps )

OptionTypeReqd?DescriptionPossible Values
titlestringYLayout title/nameunique name for this Master
backgroundBackgroundPropsbackground props(see Background Props)
marginnumberSlide margins(inches) 0.0 through Slide.width
marginarraySlide margins(inches) array of numbers in TRBL order. Ex: [0.5, 0.75, 0.5, 0.75]
slideNumberSlideNumberPropsSlide numbers(see SlideNumber Props)

Background Props ( BackgroundProps )

OptionTypeDefaultDescriptionPossible Values
colorstring000000colorhex color code or scheme color constant. Ex: {line:'0088CC'}
transparencynumber0transparencyPercentage: 0-100

SlideNumber Props ( SlideNumberProps )

OptionTypeDefaultDescriptionPossible Values
xnumber1.0horizontal location (inches)0-n OR 'n%'. (Ex: {x:'50%'} will place object in the middle of the Slide)
ynumber1.0vertical location (inches)0-n OR 'n%'.
wnumberwidth (inches)0-n OR 'n%'. (Ex: {w:'50%'} will make object 50% width of the Slide)
hnumberheight (inches)0-n OR 'n%'.
alignstringleftalignmentleft or center or right
colorstring000000colorhex color code or scheme color constant. Ex: {line:'0088CC'}

NOTES

  • Slide Number: more props are available that shown above - SlideNumberProps inherits from TextProps
  • Pre-encode your images (base64) and add the string as the optional data key/val (see bkgd above)

Example

Slide Master Example

Define the master, then hand its title to addSlide as masterName.

NetCorePpt · C#
var pptx = new PptxGen();
pptx.layout = "LAYOUT_WIDE";

pptx.defineSlideMaster(new SlideMasterProps
{
    title = "MASTER_SLIDE",
    background = new BackgroundProps { color = "FFFFFF" },
    margin = new Margin(0.5),
    slideNumber = new SlideNumberProps { x = 0.3, y = "90%" },
});

var slide = pptx.addSlide(new AddSlideProps { masterName = "MASTER_SLIDE" });
slide.addText("How To Create PowerPoint Presentations",
    new TextPropsOptions { x = 0.5, y = 0.7, fontSize = 18 });

await pptx.exportToFile("Presentation.pptx");

Slide Master Example Output

The master becomes a first-class layout in the exported file: it shows up under View > Slide Master and every slide that used it follows its background, margins and slide-number placement.