dart_pptx 0.1.3 copy "dart_pptx: ^0.1.3" to clipboard
dart_pptx: ^0.1.3 copied to clipboard

A package for creating pptx files from markdown or slide templates.

dart_pptx #

This is a pure dart library that can create powerpoint presentations with dart classes or markdown. This can be used in native, web, and mobile applications.

Looking for a Flutter plugin? Check out flutter_pptx.

Getting Started #

To use this library, add dart_pptx as a dependency in your pubspec.yaml file.

flutter pub add dart_pptx
copied to clipboard

Usage #

Creating a Presentation #

First, create a new presentation.

import 'package:dart_pptx/dart_pptx.dart';

final pres = Powerpoint();
copied to clipboard

Saving a Presentation #

To save the presentation, call the save method.

final bytes = await pres.save();
copied to clipboard

You then can save the bytes to a file.

import 'dart:io';

final file = File('my_presentation.pptx');
await file.writeAsBytes(bytes);
copied to clipboard

Adding Slides #

All arguments are optional and if not provided will have the "Double Click to Edit" placeholder text.

Title Slide

pres.addTitleSlide(
    title: 'Title'.toTextValue(),
    author: 'Author'.toTextValue(),
);
copied to clipboard

Title and Photo Slide

pres.addTitleAndPhotoSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    author: 'Author'.toTextValue(),
    image: ImageReference(
        path: './samples/images/sample_gif.gif',
        name: 'Sample Gif',
    ),
);
copied to clipboard

Title and Photo Slide (Alternative)

pres.addTitleAndPhotoAltSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    image: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
);
copied to clipboard

Title and Bullets Slide

pres.addTitleAndBulletsSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    bullets: [
        'Bullet 1',
        'Bullet 2',
        'Bullet 3',
        'Bullet 4',
    ].map((e) => e.toTextValue()).toList(),
);
copied to clipboard

Bullets Slide

pres.addBulletsSlide(
    bullets: [
        'Bullet 1',
        'Bullet 2',
        'Bullet 3',
        'Bullet 4',
    ].map((e) => e.toTextValue()).toList(),
);
copied to clipboard

Title, Bullets, and Photo Slide

pres.addTitleBulletsAndPhotoSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    bullets: [
        'Bullet 1',
        'Bullet 2',
        'Bullet 3',
        'Bullet 4',
    ].map((e) => e.toTextValue()).toList(),
    image: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
);
copied to clipboard

Section Slide

pres.addSectionSlide(
    section: 'Section'.toTextValue(),
);
copied to clipboard

Title Only Slide

pres.addTitleOnlySlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
);
copied to clipboard

Agenda Slide #

pres.addAgendaSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    topics: 'Topics'.toTextValue(),
);
copied to clipboard

Statement Slide #

pres.addStatementSlide(
    statement: 'Statement'.toTextValue(),
);
copied to clipboard

Big Fact Slide #

pres.addBigFactSlide(
    information: 'Information'.toTextValue(),
    fact: 'Fact'.toTextLine(),
);
copied to clipboard

Quote Slide #

pres.addQuoteSlide(
    quote: 'Quote'.toTextLine(),
    attribution: 'Attribution'.toTextValue(),
);
copied to clipboard

Photo 3 Up Slide #

pres.addPhoto3UpSlide(
    image1: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
    image2: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
    image3: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
);
copied to clipboard

Photo Slide #

pres.addPhotoSlide(
    image: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
);
copied to clipboard

Blank Slide #

pres.addBlankSlide();
copied to clipboard

Markdown #

It is also possible to create a presentation using markdown.

await pres.addSlidesFromMarkdown('MARKDOWN SOURCE');
copied to clipboard

The markdown follows the same format for md2googleslides.

Slide Background #

Solid Color #

Colors need to be in HEX format and not include the leading #.

slide.background.color = 'FF0000';
copied to clipboard

Image #

slide.background.image = ImageReference(
    path: './samples/images/sample_jpg.jpg',
    name: 'Sample Jpg',
);
copied to clipboard

Speaker Notes #

slide.speakerNotes = 'Notes'.toTextValue();
copied to clipboard

Show Slide Numbers #

slide.showSlideNumber = true;
copied to clipboard

Or for an entire presentation.

pres.showSlideNumbers = true;
copied to clipboard

Images #

Images use the ImageReference class. The path can be the base64 encoded string, remote url, or local file path.

The name is used for the alt and can be overridden with a description.

When the presentation is saved all images will be downloaded and saved in the presentation.

Running on Flutter Web will cause a CORS error when using remote urls if the server does not have the correct headers. To get around this, you can use a proxy server.

Layouts #

4x3 #

pres.layout = Layout.screen4x3();
copied to clipboard

16x9 #

pres.layout = Layout.screen16x9();
copied to clipboard

16x10 #

pres.layout = Layout.screen16x10();
copied to clipboard

Wide #

pres.layout = Layout.screenWide();
copied to clipboard

Custom #

pres.layout = Layout(
    type: 'custom',
    width: 24384000,
    height: 13716000,
);
copied to clipboard

Metadata #

Title #

pres.title = 'Title';
copied to clipboard

Subject #

pres.subject = 'Subject';
copied to clipboard

Author #

pres.author = 'Author';
copied to clipboard

Company #

pres.company = 'Company';
copied to clipboard

Revision #

pres.revision = 'Revision';
copied to clipboard
8
likes
130
points
265
downloads

Publisher

verified publisherrodydavis.com

Weekly Downloads

2024.07.06 - 2025.01.18

A package for creating pptx files from markdown or slide templates.

Repository (GitHub)

Documentation

API reference

Funding

Consider supporting this project:

www.buymeacoffee.com
www.paypal.com

License

Apache-2.0 (license)

Dependencies

archive, collection, file, http, image_size_getter, json_annotation, mustache_template, path, recase

More

Packages that depend on dart_pptx