using Library14Petrushin; namespace ExexForm2 { public partial class Form1 : Form { private PdfImg pdfImg; private List selectedImages; private string selectedDirectory; private PdfColGroupTable pdfTable; public Form1() { InitializeComponent(); pdfImg = new PdfImg(); selectedImages = new List(); pdfTable = new PdfColGroupTable(); } private void btnSelectImages_Click(object sender, EventArgs e) { using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp;*.gif"; openFileDialog.Multiselect = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { foreach (string fileName in openFileDialog.FileNames) { selectedImages.Add(new ImageData { ImagePath = fileName }); lstImages.Items.Add(fileName); } } } } private void btnSelectDirectory_Click(object sender, EventArgs e) { using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) { if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { selectedDirectory = folderBrowserDialog.SelectedPath; lblDirectory.Text = "Selected Directory: " + selectedDirectory; } } } private void btnCreatePdf_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtDocumentTitle.Text) || selectedImages.Count == 0 || string.IsNullOrEmpty(selectedDirectory)) { MessageBox.Show("Please select images, directory, and enter a document title."); return; } string fileName = Path.Combine(selectedDirectory, "output.pdf"); pdfImg.CreatePdfDocument(fileName, txtDocumentTitle.Text, selectedImages); MessageBox.Show("PDF document created successfully!"); } // ------------------------------------------- private void btnCreatePdfTable_Click(object sender, EventArgs e) { string selectDirTable = ""; using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) { if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { selectDirTable = folderBrowserDialog.SelectedPath; } } string fileName = Path.Combine(selectDirTable, "output.pdf"); var generator = new PdfColGroupTable(); var data1 = new List { new Person { FirstName = "John", LastName = "Doe", Age = 30 }, new Person { FirstName = "Jane", LastName = "Smith", Age = 25 } }; var headers = new List { "First Name", "Last Name", "Age" }; var propertyNames = new List { "FirstName", "LastName", "Age" }; var rowHeights = new List { 20, 20 }; var mergeCells = new List<(int startRow, int endRow, int startColumn, int endColumn)> { //(0, 0, 0, 1) // Объединение первых двух столбцов в первой строке }; generator.GeneratePdf(fileName, "Example Document", mergeCells, rowHeights, headers, propertyNames, data1); } } }