Skip to content

thnhmai06/SlideGenerator.Framework

SlideGenerator.Framework

.NET 10 EmguCV CodeFactor Lines of Code License

A powerful, standalone .NET library for orchestrating the generation of PowerPoint presentations from Excel data sources. It provides high-level abstractions for template manipulation, data extraction, and intelligent image processing.

Documentation: English | Tiếng Việt

Modules

The framework is composed of four core modules:

Module Namespace Description
☁️ Cloud SlideGenerator.Framework.Cloud Resolves direct download links from Google Drive, OneDrive, and Google Photos.
📊 Sheet SlideGenerator.Framework.Sheet efficient reading of Excel (.xlsx) and CSV files.
🖼️ Slide SlideGenerator.Framework.Slide PowerPoint manipulation: template loading, slide cloning, text/image replacement.
🧠 Image SlideGenerator.Framework.Image Advanced image processing: Face detection, ROI (Region of Interest) cropping, resizing.

Prerequisites

EmguCV Runtime

This framework relies on EmguCV for computer vision tasks. You must install the native runtime package matching your target OS in the consuming project.

OS Package
Windows (x64) Emgu.CV.runtime.windows
Linux (x64) Emgu.CV.runtime.ubuntu-x64
Linux (ARM) Emgu.CV.runtime.debian-arm
Linux (ARM64) Emgu.CV.runtime.debian-arm64

🔗 Official EmguCV Installation Guide

Project Configuration Example:

<ItemGroup Condition="'$(RuntimeIdentifier)'=='win-x64'">
    <PackageReference Include="Emgu.CV.runtime.windows" Version="4.12.0.5764" />
</ItemGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)'=='linux-x64'">
    <PackageReference Include="Emgu.CV.runtime.ubuntu-x64" Version="4.12.0.5764" />
</ItemGroup>

Note: macOS is currently not supported due to EmguCV runtime limitations in this context.

Usage

☁️ Cloud Module

Resolve shareable links to direct raw image streams.

using SlideGenerator.Framework.Cloud;

var directUrl = await CloudUrlResolver.ResolveLinkAsync("https://drive.google.com/file/d/...");

📊 Sheet Module

Read data from spreadsheets.

using SlideGenerator.Framework.Sheet.Models;

using var workbook = new Workbook("data.xlsx");
var sheet = workbook.Worksheets["Sheet1"];
var rowData = sheet.GetRow(1); // Returns Dictionary<string, object>

🖼️ Slide Module

The core generation logic.

using SlideGenerator.Framework.Slide.Models;
using SlideGenerator.Framework.Slide;

// 1. Load Template & Create Output
using var template = new TemplatePresentation("template.pptx");
using var working = template.SaveAs("output.pptx");

// 2. Clone a slide from template
var slidePart = working.CopySlide(template.MainSlideRelationshipId);

// 3. Replace Text
var replacements = new Dictionary<string, string>
{
    ["Name"] = "Alice",
    ["Title"] = "Engineer"
};
await TextReplacer.ReplaceAsync(slidePart, replacements);

// 4. Replace Image (by Shape ID)
var shapeId = 4U; // Discovered via template.GetAllPreviewImageShapes()
var shape = Presentation.GetShapeById(slidePart, shapeId);
using var imgStream = File.OpenRead("photo.png");

ImageReplacer.ReplaceImage(slidePart, shape!, imgStream);

// 5. Save
working.Save();

🧠 Image Module

Intelligent cropping based on Region of Interest (ROI).

using SlideGenerator.Framework.Image.Models;
using SlideGenerator.Framework.Image.Modules.Roi;

using var image = new Image("photo.png");
using var faceModel = new YuNetModel(); // Pre-trained face detector

var roiModule = new RoiModule(new RoiOptions { FaceDetectionModel = faceModel });
var selector = roiModule.GetRoiSelector(RoiType.Face);

// Crop image focusing on the face
await RoiModule.CropToRoiAsync(image, new Size(200, 200), selector, CropType.Fill);

Star History

Star History Chart

Contributors


thnhmai06

Hair-Nguyeenx
👑 💻 💻

Sponsor this project

 

Packages

 
 
 

Contributors 2

  •  
  •  

Languages