diff --git a/Utility/BotCode/PdfProcessor.cs b/Utility/BotCode/PdfProcessor.cs index 6005a68f..531e3bd3 100644 --- a/Utility/BotCode/PdfProcessor.cs +++ b/Utility/BotCode/PdfProcessor.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing.Text; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -134,5 +135,35 @@ namespace Swarmops.Utility.BotCode Console.WriteLine(" done."); } + + public static string TemplateToPdf(string svgFileName) + { + if (svgFileName.Contains('\"')) + { + throw new ArgumentException("Filename must not contain double quotes"); + } + if (svgFileName.Contains(' ')) + { + throw new ArgumentException("Filename must not contain whitespace"); + } + + if (!File.Exists(svgFileName)) + { + throw new ArgumentException("File does not exist"); + } + + string tempFolder = @"/tmp/"; + + Guid guid = new Guid(); + + string tempFileName = tempFolder + guid.ToString("D") + ".pdf"; + + Process process = Process.Start("bash", + "-c \"inkscape --without-gui --export-to-pdf=" + tempFileName + " " + svgFileName + "\""); // inkscape is a package-level dependency + + process.WaitForExit(); + + return tempFileName; + } } }