public static void Execute(PdfBatchEditData data, string databasePath, string dbAccessDataFileName)
        {
            if (!File.Exists(databasePath))
            {
                Console.WriteLine($"Database not found: '{databasePath}'");
                return;
            }

            string templateFilePath = Path.Combine(Utils.MainDirectory, "template_data", dbAccessDataFileName);
            if (!File.Exists(templateFilePath))
            {
                Console.WriteLine($"Template file not found: '{templateFilePath}'");
                return;
            }

            DBAccessData accessData = DBAccessData.FromFile(templateFilePath);
            accessData.CustomizeSQLWithCommandLineArguments("ARGUMENT");
            Console.WriteLine(accessData);
            Console.WriteLine();

            List<BatchFileData> batchFileDataList = LoadAndCorrectData(databasePath, accessData);
            batchFileDataList.Sort(BatchFileData.SortByNumber);

            TextEffect effect = new TextEffect("");
            effect.UseLocalTexts = accessData.useLocalTexts;
            effect.FontColor = XColors.Black;
            effect.FontSize = 20;
            effect.VerticalAlignment = VerticalAlignment.Top;
            effect.HorizontalAlignment = HorizontalAlignment.Right;
            effect.RelativeX = 0.96;
            effect.RelativeY = 0.01;
            effect.UseOrientation = true;
            data.AddEffectToAllFiles(effect);

            int counter = 0;
            foreach(BatchFileData batchFileData in batchFileDataList)
            {
                if (File.Exists(batchFileData.path))
                {
                    BatchFile file = data.AddFileWithAllEffects(batchFileData.path);

                    file.OutputNameType = accessData.outputNameType;
                    int prefixNumber = batchFileData.GetLowestSortElement();
                    string prefixNumberString = Convert.ToString(prefixNumber).PadLeft(3, '0');

                    if (accessData.outputNameType == FileNameType.SourceName)
                        file.OutputNamePrefix = "";
                    if (accessData.outputNameType == FileNameType.PrefixOnly)
                        file.OutputNamePrefix = prefixNumberString;
                    if (accessData.outputNameType == FileNameType.SourceNameAndPrefix)
                        file.OutputNamePrefix = prefixNumberString + "_";

                    LocalTextEffectSettings settings = (LocalTextEffectSettings)file.GetLocalSettingsForEffect(effect);
                    settings.Text = accessData.textPrefix + batchFileData.CombinedText;
                    counter++;
                }
                else
                {
                    Console.WriteLine($"File '{batchFileData.path}' not found.");
                }
            }

            Console.WriteLine($"{counter} files loaded.");
        }
예제 #2
0
 public LocalTextEffectSettings(TextEffect main, string text = "")
 {
     this.main = main;
     this.text = text;
 }