Esempio n. 1
0
        static int Main(string[] args)
        {
            try
            {
                string inputFilePath  = args[0];
                string outputFilePath = args[1];

                var html      = File.ReadAllText(inputFilePath);
                var extension = Path.GetExtension(outputFilePath).Remove(0, 1).ToLower();
                var image     = HtmlToXConverter.ConvertToImage(html, extension, 600, 0);
                File.WriteAllBytes(outputFilePath, image);
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(1);
            }
        }
        public void Export(string markdownType, string sourceCodePath, string cssFile, string outputPath)
        {
            var tmpFilePath = Path.GetTempFileName() + ".html";

            DocumentExporter.Export("Html", markdownType, cssFile, sourceCodePath, tmpFilePath);

            //Process process = new Process();
            //process.StartInfo.FileName = "wkhtmltoimage";
            //process.StartInfo.Arguments = $"--width 600 \"{tmpFilePath}\" \"{outputPath}\"";
            //process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            //process.Start();
            //process.WaitForExit();
            //if (process.ExitCode != 0)
            //    throw new Exception(Properties.Resources.FailedToExport + "\n" + "wkhtmltoimage error" + process.ExitCode);

            var html      = File.ReadAllText(tmpFilePath);
            var extension = Path.GetExtension(outputPath).Remove(0, 1).ToLower();
            var image     = HtmlToXConverter.ConvertToImage(html, extension, 600, 0);

            File.WriteAllBytes(outputPath, image);

            File.Delete(tmpFilePath);
        }