diff --git a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj index e8a9aa7a..a78dd36b 100644 --- a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj +++ b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj @@ -181,9 +181,6 @@ - - - diff --git a/src/Infrastructure/BotSharp.Core/Files/BotSharpFileService.Conversation.cs b/src/Infrastructure/BotSharp.Core/Files/BotSharpFileService.Conversation.cs index 246f32e4..ec99764b 100644 --- a/src/Infrastructure/BotSharp.Core/Files/BotSharpFileService.Conversation.cs +++ b/src/Infrastructure/BotSharp.Core/Files/BotSharpFileService.Conversation.cs @@ -1,5 +1,4 @@ using BotSharp.Abstraction.Files.Converters; -using BotSharp.Core.Files.Converters; using Microsoft.EntityFrameworkCore; using System; using System.IO; @@ -330,12 +329,7 @@ public partial class BotSharpFileService private IPdf2ImageConverter? GetPdf2ImageConverter() { var converters = _services.GetServices(); - var converter = converters.FirstOrDefault(x => x.GetType().Name != typeof(PdfiumConverter).Name); - if (converter == null) - { - converter = converters.FirstOrDefault(x => x.GetType().Name == typeof(PdfiumConverter).Name); - } - return converter; + return converters.FirstOrDefault(); } #endregion } diff --git a/src/Infrastructure/BotSharp.Core/Files/Converters/PdfiumConverter.cs b/src/Infrastructure/BotSharp.Core/Files/Converters/PdfiumConverter.cs deleted file mode 100644 index 4ee0e3da..00000000 --- a/src/Infrastructure/BotSharp.Core/Files/Converters/PdfiumConverter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using BotSharp.Abstraction.Files.Converters; -using PdfiumViewer; -using System.IO; - -namespace BotSharp.Core.Files.Converters; - -public class PdfiumConverter : IPdf2ImageConverter -{ - public async Task> ConvertPdfToImages(string pdfLocation, string imageFolderLocation) - { - var paths = new List(); - if (string.IsNullOrWhiteSpace(imageFolderLocation)) return paths; - - if (Directory.Exists(imageFolderLocation)) - { - Directory.Delete(imageFolderLocation, true); - } - Directory.CreateDirectory(imageFolderLocation); - - var guid = Guid.NewGuid().ToString(); - using (var document = PdfDocument.Load(pdfLocation)) - { - var pages = document.PageCount; - - for (var page = 0; page < pages; page++) - { - var size = document.PageSizes[page]; - using (var image = document.Render(page, (int)size.Width, (int)size.Height, 96, 96, true)) - { - var imagePath = Path.Combine(imageFolderLocation, $"{guid}_pg_{page + 1}.png"); - image.Save(imagePath, System.Drawing.Imaging.ImageFormat.Png); - paths.Add(imagePath); - } - } - } - - return await Task.FromResult(paths); - } -} diff --git a/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs b/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs index a3256051..3110c8d5 100644 --- a/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs +++ b/src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs @@ -1,5 +1,3 @@ -using BotSharp.Abstraction.Files.Converters; -using BotSharp.Core.Files.Converters; using BotSharp.Core.Files.Hooks; using Microsoft.Extensions.Configuration; @@ -20,6 +18,5 @@ public class FilePlugin : IBotSharpPlugin services.AddScoped(); services.AddScoped(); - services.AddScoped(); } }