public string AddDocumentToFulltext(string id) { string file = SimpleServerExtensionMethods.GetFilePath(id); var ocr = new AdvancedOcr() { CleanBackgroundNoise = true, EnhanceContrast = true, EnhanceResolution = true, Language = IronOcr.Languages.German.OcrLanguagePack, Strategy = IronOcr.AdvancedOcr.OcrStrategy.Advanced, ColorSpace = AdvancedOcr.OcrColorSpace.Color, DetectWhiteTextOnDarkBackgrounds = true, InputImageType = AdvancedOcr.InputTypes.AutoDetect, RotateAndStraighten = true, ReadBarCodes = false, ColorDepth = 4 }; var results = ocr.Read(file); _saveFullText(file, results.Text); return(results.Text); }
public void RemoveDocumentFromFulltext(string id) { string file = SimpleServerExtensionMethods.GetFilePath(id); var textFile = Path.ChangeExtension(file, ".txt").Replace("basis", "fulltext"); File.Delete(textFile); }
public static bool MergePDFs(List <string> files) { string intrayPath = SimpleServerExtensionMethods.GetIntrayPath("DMSArchiv"); string firstFileName = Path.GetFileName(files.First()); string targetPath = Path.Combine(intrayPath, firstFileName); try { using (PdfDocument targetDoc = new PdfDocument()) { foreach (string fileName in files) { using (PdfDocument pdfDoc = PdfReader.Open(fileName, PdfDocumentOpenMode.Import)) for (int i = 0; i < pdfDoc.PageCount; i++) { targetDoc.AddPage(pdfDoc.Pages[i]); } File.Delete(fileName); } targetDoc.Save(targetPath); } return(true); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); return(false); } }
public static List <SordType> GetSordTypes() { var file = Path.Combine(SimpleServerExtensionMethods.GetRootPath(), "Content", "data", "sordtypes.json"); var json = System.IO.File.ReadAllText(file); var list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SordType> >(json); return(list); }
private string _createPDF() { Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); // C# doesn't have optional arguments so we'll need a dummy value object oMissing = System.Reflection.Missing.Value; word.Visible = false; word.ScreenUpdating = false; //FileInfo wordFile = _filePath; // Cast as Object for word Open method //Object filename = (Object)wordFile.FullName; Object filename = _filePath; // Use the dummy value as a placeholder for optional arguments Document doc = word.Documents.Open(ref filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); doc.Activate(); //object outputFileName = wordFile.FullName.Replace(".doc", ".pdf"); object outputFileName = Path.Combine(SimpleServerExtensionMethods.GetArchivePath(_archive), "preview", _hexFolder, _hexValue + ".pdf"); object fileFormat = WdSaveFormat.wdFormatPDF; // Save document into PDF Format doc.SaveAs(ref outputFileName, ref fileFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); object saveChanges = WdSaveOptions.wdDoNotSaveChanges; ((_Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing); doc = null; ((_Application)word).Quit(ref oMissing, ref oMissing, ref oMissing); word = null; return(outputFileName.ToString()); }
public static bool SplitPDFs(List <string> files) { string intrayPath = SimpleServerExtensionMethods.GetIntrayPath("DMSArchiv"); string firstFileName = Path.GetFileName(files.First()); int pageNumber; try { foreach (string fileName in files) { pageNumber = 1; string pathName = Path.GetDirectoryName(fileName); string fileNameOnly = Path.Combine(pathName, Path.GetFileNameWithoutExtension(fileName)); using (PdfDocument pdfDoc = PdfReader.Open(fileName, PdfDocumentOpenMode.Import)) for (int i = 0; i < pdfDoc.PageCount; i++) { using (PdfDocument targetDoc = new PdfDocument()) { targetDoc.AddPage(pdfDoc.Pages[i]); string targetPath = fileName.Replace(fileNameOnly, fileNameOnly + "_" + pageNumber.ToString().PadLeft(4, '0')); targetDoc.Save(targetPath); pageNumber++; } } } foreach (string pdf in files) { File.Delete(pdf); } return(true); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); return(false); } }
public static string GetFilePath(string objid, string ext = "pdf", string scope = "basis") { return(Path.Combine(SimpleServerExtensionMethods.GetArchivePath("DMSArchiv"), scope, GetHexFolder(objid), GetHexValue(objid) + "." + ext)); }