public void OnPost(List <IFormFile> files) { var service = CCFServicesManager.GetService <IDocumentProcessor>(); var fileName = @"D:\Users\maksa\Desktop\DocsToPictures\doc.docx"; var memstr = new MemoryStream(); files[0].CopyTo(memstr); memstr.Position = 0; var document = service.AddToHandle("file.docx", memstr); memstr.Position = 0; using (var file = System.IO.File.Create(fileName)) memstr.CopyTo(file); while (document.ReadyPagesCount != document.PagesCount) { for (int i = 20; i >= 0; i--) { Console.WriteLine(i); Thread.Sleep(TimeSpan.FromSeconds(1)); } } var pages = document.GetAvailablePages(); Console.WriteLine($"getted {pages.Count} pages"); foreach (var page in pages) { Console.WriteLine($"page num : {page}"); using (var pic = System.IO.File.Create($@"D:\Users\maksa\Desktop\DocsToPictures\{page}.png")) document.GetPicture(page).CopyTo(pic); } }
public static void AddTransientSafeCFF <T>(this IServiceCollection services, Func <IServiceProvider, T> AlternativeFactory) where T : class { services.AddTransient(SP => { try { return(CCFServicesManager.GetService <T>()); } catch { return(AlternativeFactory?.Invoke(SP)); } }); }
public CCFCollection AddCCFService <T>() where T : class { services.AddTransient(SP => ccfManager.GetService <T>()); return(this); }