2024-09-29 23:00:02 +04:00
|
|
|
|
using Library14Petrushin;
|
2024-09-30 11:24:43 +04:00
|
|
|
|
using Library14Petrushin.Classes;
|
2024-09-29 23:00:02 +04:00
|
|
|
|
|
|
|
|
|
namespace ExexForm2
|
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
|
|
|
|
private PdfImg pdfImg;
|
|
|
|
|
private List<ImageData> selectedImages;
|
|
|
|
|
private string selectedDirectory;
|
|
|
|
|
private PdfColGroupTable pdfTable;
|
2024-09-30 11:24:43 +04:00
|
|
|
|
private PdfCirclDiagr pdfCirclDiagr;
|
2024-09-29 23:00:02 +04:00
|
|
|
|
|
|
|
|
|
public Form1()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
pdfImg = new PdfImg();
|
|
|
|
|
selectedImages = new List<ImageData>();
|
|
|
|
|
pdfTable = new PdfColGroupTable();
|
2024-09-30 11:24:43 +04:00
|
|
|
|
pdfCirclDiagr = new PdfCirclDiagr();
|
2024-09-29 23:00:02 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-30 11:24:43 +04:00
|
|
|
|
string fileName = Path.Combine(selectedDirectory, "output1.pdf");
|
2024-09-29 23:00:02 +04:00
|
|
|
|
pdfImg.CreatePdfDocument(fileName, txtDocumentTitle.Text, selectedImages);
|
|
|
|
|
MessageBox.Show("PDF document created successfully!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-30 11:24:43 +04:00
|
|
|
|
// 2 -------------------------------------------
|
2024-09-29 23:00:02 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void btnCreatePdfTable_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string selectDirTable = "";
|
|
|
|
|
|
|
|
|
|
using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
|
|
|
|
|
{
|
|
|
|
|
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
selectDirTable = folderBrowserDialog.SelectedPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-30 11:24:43 +04:00
|
|
|
|
string fileName = Path.Combine(selectDirTable, "output2.pdf");
|
2024-09-29 23:00:02 +04:00
|
|
|
|
|
|
|
|
|
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" };
|
2024-09-30 10:56:46 +04:00
|
|
|
|
var commonHeaders = new List<string> { "Name", "", "" };
|
2024-09-29 23:00:02 +04:00
|
|
|
|
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 11:06:19 +04:00
|
|
|
|
(0, 1, 0, 0), // 0 <20> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
(2, 2, 0, 1)
|
2024-09-30 10:56:46 +04:00
|
|
|
|
};
|
2024-09-29 23:00:02 +04:00
|
|
|
|
|
2024-09-30 10:56:46 +04:00
|
|
|
|
generator.GeneratePdf(fileName, "Example Document", mergeCells, rowHeights, headers, commonHeaders, propertyNames, data1);
|
2024-09-29 23:00:02 +04:00
|
|
|
|
}
|
2024-09-30 11:24:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3 -------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void btnCreatePdfCircl_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string selectDir = "";
|
|
|
|
|
|
|
|
|
|
using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
|
|
|
|
|
{
|
|
|
|
|
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
selectDir = folderBrowserDialog.SelectedPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string fileName = Path.Combine(selectDir, "output3.pdf");
|
|
|
|
|
|
|
|
|
|
var pdfCirclDiagr = new PdfCirclDiagr();
|
|
|
|
|
|
|
|
|
|
List<ChartData> chartData = new List<ChartData>
|
|
|
|
|
{
|
|
|
|
|
new ChartData { SeriesName = "Series 1", Value = 10 },
|
|
|
|
|
new ChartData { SeriesName = "Series 2", Value = 20 },
|
|
|
|
|
new ChartData { SeriesName = "Series 3", Value = 30 },
|
|
|
|
|
new ChartData { SeriesName = "Series 4", Value = 40 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pdfCirclDiagr.GeneratePdf(fileName, "Document Title", "Chart Title", LegendPosition.Right, chartData);
|
|
|
|
|
}
|
2024-09-29 23:00:02 +04:00
|
|
|
|
}
|
|
|
|
|
}
|