public SettingsModel checkProgrammArguments(string[] args) { try { if (args.Length < 1 || new [] { 2, 4 }.Contains(args.Length) || args.Length > 5) { throw new Exception("Incorrect arguments."); } SettingsModel settingsModel = new SettingsModel(); // --- SourcePdfFilePath --- if (!File.Exists(args[0])) { throw new Exception($"SourcePdfFilePath not found. Path: {args[0]}"); } else { settingsModel.SourcePdfFilePath = args[0]; } // --- First Option --- if (args.Length > 1 && args[1] != null && args[2] != null) { settingsModel = checkOptions(args[1], args[2], settingsModel); } // --- Second Option --- if (args.Length > 3 && args[3] != null && args[4] != null) { settingsModel = checkOptions(args[3], args[4], settingsModel); } return(settingsModel); } catch (System.Exception ex) { ExceptionsService.displaySynopsis(ex); return(null); } }
private void loadLicence() { try { License lic = new License(); lic.SetLicense("Aspose.Total.lic"); _readyState = true; } catch (Exception) { ExceptionsService.displayError(new Exception("Error in loading License file.")); _readyState = false; } }
public void doSplit() { try { Document sourceDocument = new Document(_settings.SourcePdfFilePath); int n = 0; sourceDocument.Pages.ToList().ForEach( sourcePage => { n++; PageNameModel pageSettings = _settings.PageNameList.FirstOrDefault(x => x.Id == n); if (pageSettings?.Name?.Trim().Length > 0) { Document destinationDocument = new Document(); destinationDocument.Pages.Add(sourcePage); destinationDocument.Save($"{_settings.OutputFilesPath}{pageSettings.Name}"); } }); } catch (Exception ex) { ExceptionsService.displayError(ex); } }