# Masters and Placeholders

defineSlideMaster() and defineLayout(): reusable backgrounds, logos and placeholders.

```csharp
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 )

| Option | Type | Reqd? | Description | Possible Values |
| --- | --- | --- | --- | --- |
| `title` | string | Y | Layout title/name | unique name for this Master |
| `background` | BackgroundProps |  | background props | (see [Background Props](#background-props-backgroundprops)) |
| `margin` | number |  | Slide margins | (inches) 0.0 through Slide.width |
| `margin` | array |  | Slide margins | (inches) array of numbers in TRBL order. Ex: `[0.5, 0.75, 0.5, 0.75]` |
| `slideNumber` | SlideNumberProps |  | Slide numbers | (see [SlideNumber Props](#slidenumber-props-slidenumberprops)) |

### Background Props ( BackgroundProps )

| Option | Type | Default | Description | Possible Values |
| --- | --- | --- | --- | --- |
| `color` | string | `000000` | color | hex color code or [scheme color constant](shapes-and-schemes.md). Ex: `{line:'0088CC'}` |
| `transparency` | number | `0` | transparency | Percentage: 0-100 |

### SlideNumber Props ( SlideNumberProps )

| Option | Type | Default | Description | Possible Values |
| --- | --- | --- | --- | --- |
| `x` | number | `1.0` | horizontal location (inches) | 0-n OR 'n%'. (Ex: `{x:'50%'}` will place object in the middle of the Slide) |
| `y` | number | `1.0` | vertical location (inches) | 0-n OR 'n%'. |
| `w` | number |  | width (inches) | 0-n OR 'n%'. (Ex: `{w:'50%'}` will make object 50% width of the Slide) |
| `h` | number |  | height (inches) | 0-n OR 'n%'. |
| `align` | string | `left` | alignment | `left` or `center` or `right` |
| `color` | string | `000000` | color | hex color code or [scheme color constant](shapes-and-schemes.md). Ex: `{line:'0088CC'}` |

### NOTES

- Slide Number: more props are available that shown above - `SlideNumberProps` inherits from [TextProps](api-text.md)
- 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#**

```csharp
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.
