private void combineFilesConvertedToPdf_Ordered()
        {
            ModalOverlayIsVisible      = false;
            SetFileOrderModalIsVisible = false;
            UpdateLabelPdf             = "";

            try
            {
                var combined_file_names = new List <string>();
                var combine_files       = FilesConvertedToPdf_Ordered.ToList();

                var ticket_atty   = FilesConvertedToPdf.Where(x => !string.IsNullOrEmpty(x.TicketPlusAttorney)).Select(x => x.TicketPlusAttorney).FirstOrDefault();
                var new_file_name = PdfUtilities.GenerateFilenameForNewPdf(DestinationFolderConvertedFiles, "CombinedPdf", ticket_atty);

                if (StaticSystemTests.IsAdobePdfPrinterAvailable())
                {
                    // create combined pdf
                    Models.MergePdf.SimpleMergedPdf simpleMergedPdf;
                    if (!string.IsNullOrEmpty(new_file_name))
                    {
                        simpleMergedPdf = new Models.MergePdf.SimpleMergedPdf(combine_files, "Acrobat", true, new_file_name);
                    }
                    else
                    {
                        simpleMergedPdf = new Models.MergePdf.SimpleMergedPdf(combine_files, "Acrobat", true);
                    }

                    // add new file to FilesConvertedToPdf collection
                    if (System.IO.File.Exists(simpleMergedPdf?.NewCombinedFile))
                    {
                        if (!FilesConvertedToPdf.Any(x => x.FullName == simpleMergedPdf.NewCombinedFile))
                        {
                            FilesConvertedToPdf.Add(new CockleFilePdf(simpleMergedPdf.NewCombinedFile, SourceFileTypeEnum.Combined_Pdf));
                            UpdateLabelPdf = "Created: " + simpleMergedPdf.NewCombinedFile;
                        }
                    }
                }
                else // using PdfSharp or iTextSharp ???
                {
                    //combined_file_name = new SimpleMergedPdf(SelectedPdfFiles, "PdfSharp").NewCombinedFile;
                    //var combined_file = new SimpleMergedPdf(SelectedPdfFiles, "iTextSharp").NewFileName;
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                UpdateLabelPdf = ex.Message;
            }
        }
        private void combineSelectedPdfFilesOptions()
        {
            // clear old results
            if (null == FilesConvertedToPdf_Ordered)
            {
                FilesConvertedToPdf_Ordered = new ObservableCollection <CockleFilePdf>();
            }
            else
            {
                FilesConvertedToPdf_Ordered.Clear();
            }
            // load list
            var ranked_files = SelectedPdfFiles.OrderBy(x => x.Rank).ToList();

            ranked_files.ForEach(x => FilesConvertedToPdf_Ordered.Add(x));

            // open overlay
            ModalOverlayIsVisible      = true;
            SetFileOrderModalIsVisible = true;
        }
Пример #3
0
        private void clearPdfFiles()
        {
            try
            {
                if (null == FilesConvertedToPdf)
                {
                    FilesConvertedToPdf = new ObservableCollection <CockleFilePdf>();
                }
                else
                {
                    FilesConvertedToPdf.Clear();
                }

                if (null == FilesConvertedToPdf_Ordered)
                {
                    FilesConvertedToPdf_Ordered = new ObservableCollection <CockleFilePdf>();
                }
                else
                {
                    FilesConvertedToPdf_Ordered.Clear();
                }

                if (null == Files)
                {
                    Files = new ObservableCollection <CockleFile>();
                }
                else
                {
                    Files.Clear();
                }

                DestinationFolderConvertedFiles = string.Empty;
                UpdateLabelPdf = "";
            }
            catch (Exception ex)
            {
                UpdateLabelPdf = ex.Message;
            }
        }