private static void Main(string[] args) { if (args == null | args?.Length == 0) { WriteLine("Requires arg with path to fantasy grounds character xml"); } else { if (File.Exists(args[0])) { try { var currentDirectory = System.IO.Directory.GetCurrentDirectory(); var characters = FG5eXml.LoadCharacters(args[0]); if (characters.Count() == 0) { WriteLine($"No characters found!"); } foreach (var character in characters) { var charName = character.Properities.FirstOrDefault((x) => x.Name == "Name")?.Value; var level = character.Properities.FirstOrDefault((x) => x.Name == "LevelTotal")?.Value; var outFile = $@"{currentDirectory}\{charName} ({level}).pdf"; FG5ePdf.Write(character, outFile); WriteLine($"Wrote: {outFile}"); } } catch (Exception e) { WriteLine(e); throw; } } else { WriteLine("Can't find the file"); } } }
private static void GenerateSheet(string file, string currentDirectory) { try { var xml = XDocument.Load(Path.Combine(currentDirectory, file)); if (xml?.Root?.Element("character") == null) { return; } var characters = FG5eXml.LoadCharacters(Path.Combine(currentDirectory, file)); var character = characters.First(); var charName = character.Properities.FirstOrDefault((x) => x.Name == "Name")?.Value; var level = character.Properities.FirstOrDefault((x) => x.Name == "LevelTotal")?.Value; FG5ePdf.Write( character, $@"{currentDirectory}\{charName} ({level}).pdf"); } catch (Exception e) { Console.WriteLine(e); throw; } }