public void TestAutoShapeFonts() { string fontName = "Arial"; float fontSize = 16.5f; //Load update and save the file using (var presentation = new Presentation()) { presentation.LoadFromFile("../../../TestFiles/TestFile - Assorted.pptx"); PowerPointFontUtility.UpdateAllFontStyle(presentation, fontName, fontSize); presentation.SaveToFile("../../../OutputFile/OutputFile - Assorted.pptx", FileFormat.Auto); } //Load the processed file and inspect for the values using (var presentation = new Presentation()) { presentation.LoadFromFile("../../../OutputFile/OutputFile - Assorted.pptx"); foreach (ISlide slide in presentation.Slides) { if (slide.Shapes != null) { foreach (var shape in slide.Shapes) { switch (shape) { case IAutoShape autoShape: if (autoShape?.TextFrame != null) { TextFrameAssert(autoShape?.TextFrame, fontName, fontSize); } break; case ISmartArt smartArt: if (smartArt.Nodes != null) { foreach (ISmartArtNode node in smartArt.Nodes) { RecursiveNodeAssertion(node, fontName, fontSize); } } break; case IChart chart: ChartAssert(chart, fontName, fontSize); break; } } } } } }
public IActionResult ModifyText(IFormFile file, string fontName, float fontSize) { string outputFileRoute = string.Empty; using (var presentation = new Presentation()) { //Load uploaded file presentation.LoadFromStream(file.OpenReadStream(), FileFormat.Auto); //Update all fonts PowerPointFontUtility.UpdateAllFontStyle(presentation, fontName, fontSize); //Generate filename string fileOutputName = $"{Config.OutputPrefix}-{DateTime.Now.ToFileTime()}.pptx"; //Save to new file presentation.SaveToFile($"{Config.OutputFolder}/{fileOutputName}", FileFormat.Auto); outputFileRoute = $"{Config.OutputRoute}/{fileOutputName}"; } return(Ok(outputFileRoute)); }