2024-09-29 23:00:02 +04:00
|
|
|
|
using Library14Petrushin;
|
|
|
|
|
|
|
|
|
|
namespace ExexForm2
|
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
|
|
|
|
private PdfImg pdfImg;
|
|
|
|
|
private List<ImageData> selectedImages;
|
|
|
|
|
private string selectedDirectory;
|
|
|
|
|
private PdfColGroupTable pdfTable;
|
|
|
|
|
|
|
|
|
|
public Form1()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
pdfImg = new PdfImg();
|
|
|
|
|
selectedImages = new List<ImageData>();
|
|
|
|
|
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<Person>
|
|
|
|
|
{
|
|
|
|
|
new Person { FirstName = "John", LastName = "Doe", Age = 30 },
|
|
|
|
|
new Person { FirstName = "Jane", LastName = "Smith", Age = 25 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var headers = new List<string> { "First Name", "Last Name", "Age" };
|
|
|
|
|
var propertyNames = new List<string> { "FirstName", "LastName", "Age" };
|
|
|
|
|
var rowHeights = new List<double> { 20, 20 };
|
|
|
|
|
var mergeCells = new List<(int startRow, int endRow, int startColumn, int endColumn)>
|
|
|
|
|
{
|
2024-09-30 00:41:41 +04:00
|
|
|
|
//(0, 0, 0, 1) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-09-29 23:00:02 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
generator.GeneratePdf(fileName, "Example Document", mergeCells, rowHeights, headers, propertyNames, data1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|