private static void Convert(Options options)
        {
            var converter = new SvgToVectorDocumentConverter(options.BlankVectorDrawablePath, options.FixFillType);

            foreach (var inputFile in Directory.GetFiles(options.InputDirectory, options.InputMask + ".pdf", SearchOption.AllDirectories))
            {
                Console.Write(".");

                var subpath  = PathHelper.Subpath(inputFile, options.InputDirectory);
                var tempFile = PathHelper.GenerateTempFileName("svg");

                try
                {
                    Inkscape.ConvertPdfToSvg(Inkscape.FindAppPath(), inputFile, tempFile);

                    SvgO.OptimizeSvg(options.SvgOPath, tempFile, tempFile);
                    SvgPreprocessor.Preprocess(tempFile, tempFile);

                    var svgDocument    = SvgDocumentWrapper.CreateFromFile(tempFile);
                    var outputDocument = converter.Convert(svgDocument).WrappedDocument;
                    PrintWarnings(subpath, converter.Warnings);

                    var outputFile = Path.Combine(options.OutputDirectory, subpath);
                    outputFile = Path.ChangeExtension(outputFile, "xml");
                    outputFile = PathHelper.NormalizeFileName(outputFile);

                    Directory.CreateDirectory(Path.GetDirectoryName(outputFile));
                    var settings = new XmlWriterSettings
                    {
                        Encoding            = new UTF8Encoding(false),
                        Indent              = true,
                        IndentChars         = new string(' ', 4),
                        NewLineOnAttributes = true
                    };
                    using (var writer = XmlWriter.Create(outputFile, settings))
                    {
                        outputDocument.Save(writer);
                    }
                }
                catch (FixFillTypeException e)
                {
                    PrintError($"{subpath}: Failure due to the --fix-fill-type option. {e.InnerException.Message}");
                }
                catch (Exception e)
                {
                    PrintError($"{subpath}: {e.Message}");
                }

                File.Delete(tempFile);
            }
        }
Пример #2
0
        public void Test_implementsSearchForNewer()
        {
            var i = new Inkscape(false);

            Assert.IsTrue(i.implementsSearchForNewer());
        }