Files
OnDoc/DOCGEN/Klassen/SyncFPowerPoint.cs
2024-09-18 09:57:27 +02:00

69 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Syncfusion.DocIO.DLS;
using Syncfusion.Presentation;
using Syncfusion.XlsIO;
namespace DOCGEN.Klassen
{
public class SyncFPowerPoint
{
public bool create_nativ(string property, string value, string base64, string originalfile, string destfile)
{
FileStream ms = new FileStream(originalfile, FileMode.Open, FileAccess.Read);
//FileStream os = new FileStream(destfile, FileMode.Create);
IPresentation pptxDoc = Presentation.Open(originalfile);
try
{
pptxDoc.CustomDocumentProperties.Add(property);
pptxDoc.CustomDocumentProperties[property].Value = value;
}
catch
{
pptxDoc.CustomDocumentProperties.Add(property);
pptxDoc.CustomDocumentProperties[property].Value = value;
}
try
{
ITextSelection[] textSelections = pptxDoc.FindAll(property, false, false);
foreach (ITextSelection textSelection in textSelections)
{
ITextPart textPart = textSelection.GetAsOneTextPart();
textPart.Text = value;
}
// ITextSelection[] textSelection = pptxDoc.FindAll(property, false, false);
// foreach (ITextSelection textSelection in textSelections)
// {
// //Get the found text as a single text part.
// ITextPart textPart = textSelection.GetAsOneTextPart();
// //Replace the text.
// textPart.Text = value;
// }
//// ITextPart textPart = textSelection.GetAsOneTextPart();
// // textPart.Text = value;
}
catch { }
ms.Close();
ms.Dispose();
pptxDoc.Save(destfile);
//os.Close();
//os.Dispose();
return true;
}
}
}