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;
            }
        }
Exemplo n.º 2
0
 private bool canConvertFilesToPdf()
 {
     return(SelectedFile != null && !IsExecutingSearch && !IsConvertingToPdf &&
            StaticSystemTests.IsAdobePdfPrinterAvailable());
 }