diff --git a/Compression/Compress-the-existing-PDF-document/.NET/Compress-the-existing-PDF-document/Program.cs b/Compression/Compress-the-existing-PDF-document/.NET/Compress-the-existing-PDF-document/Program.cs index ee80de90..297cca76 100644 --- a/Compression/Compress-the-existing-PDF-document/.NET/Compress-the-existing-PDF-document/Program.cs +++ b/Compression/Compress-the-existing-PDF-document/.NET/Compress-the-existing-PDF-document/Program.cs @@ -6,8 +6,6 @@ { // Create a new PdfCompressionOptions object PdfCompressionOptions options = new PdfCompressionOptions(); - //Enable the compress image - options.CompressImages = true; //Set the image quality options.ImageQuality = 50; // Compress the PDF document diff --git a/Compression/Compress-the-existing-PDF-document/.NET/Compress-the-existing-PDF-document/README.md b/Compression/Compress-the-existing-PDF-document/.NET/Compress-the-existing-PDF-document/README.md index 84920bec..59183442 100644 --- a/Compression/Compress-the-existing-PDF-document/.NET/Compress-the-existing-PDF-document/README.md +++ b/Compression/Compress-the-existing-PDF-document/.NET/Compress-the-existing-PDF-document/README.md @@ -25,8 +25,6 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath { // Create a new PdfCompressionOptions object PdfCompressionOptions options = new PdfCompressionOptions(); - //Enable the compress image - options.CompressImages = true; //Set the image quality options.ImageQuality = 50; // Compress the PDF document diff --git a/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/Program.cs b/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/Program.cs index a749a26c..faed8513 100644 --- a/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/Program.cs +++ b/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/Program.cs @@ -5,21 +5,27 @@ // Create a new PDF document using (PdfDocument document = new PdfDocument()) { - //Add a page to the document + // Add a new page to the PDF document PdfPage page = document.Pages.Add(); - // Create a PdfGrid + // Create a PdfGrid to display tabular data PdfGrid pdfGrid = new PdfGrid(); - // Add values to the list - List data = new List - { - new { ID = "E01", Name = "Clay" }, - new { ID = "E02", Name = "Thomas" }, - new { ID = "E03", Name = "John" } - }; - // Assign the data source to the grid + // Prepare sample data for the grid + object data = new List + { + new { ID = "E01", Name = "Clay", Department = "HR" }, + new { ID = "E02", Name = "Thomas", Department = "Finance" }, + new { ID = "E03", Name = "John", Department = "IT" }, + new { ID = "E04", Name = "Emma", Department = "Marketing" }, + new { ID = "E05", Name = "Sophia", Department = "Operations" } + }; + // Assign the data source to the grid (auto-generates a header row) pdfGrid.DataSource = data; - // Draw the grid on the PDF page - pdfGrid.Draw(page, new PointF(10, 10)); + //Apply built-in table style + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent6); + // Apply padding and font style to body cells + pdfGrid.Style.CellPadding = new PdfPaddings(10, 6, 10, 6); + // Draw the grid on the PDF page at specified position (with margin) + pdfGrid.Draw(page, new PointF(20, 40)); // Save the PDF document document.Save(Path.GetFullPath(@"Output/Output.pdf")); } \ No newline at end of file diff --git a/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/README.md b/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/README.md index ac8216c3..363c17a3 100644 --- a/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/README.md +++ b/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/README.md @@ -22,21 +22,27 @@ Step 4: **Add a table to the PDF**: Use the following code in **Program.cs** to // Create a new PDF document using (PdfDocument document = new PdfDocument()) { - //Add a page to the document + // Add a new page to the PDF document PdfPage page = document.Pages.Add(); - // Create a PdfGrid + // Create a PdfGrid to display tabular data PdfGrid pdfGrid = new PdfGrid(); - // Add values to the list - List data = new List - { - new { ID = "E01", Name = "Clay" }, - new { ID = "E02", Name = "Thomas" }, - new { ID = "E03", Name = "John" } - }; - // Assign the data source to the grid + // Prepare sample data for the grid + object data = new List + { + new { ID = "E01", Name = "Clay", Department = "HR" }, + new { ID = "E02", Name = "Thomas", Department = "Finance" }, + new { ID = "E03", Name = "John", Department = "IT" }, + new { ID = "E04", Name = "Emma", Department = "Marketing" }, + new { ID = "E05", Name = "Sophia", Department = "Operations" } + }; + // Assign the data source to the grid (auto-generates a header row) pdfGrid.DataSource = data; - // Draw the grid on the PDF page - pdfGrid.Draw(page, new PointF(10, 10)); + //Apply built-in table style + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent6); + // Apply padding and font style to body cells + pdfGrid.Style.CellPadding = new PdfPaddings(10, 6, 10, 6); + // Draw the grid on the PDF page at specified position (with margin) + pdfGrid.Draw(page, new PointF(20, 40)); // Save the PDF document document.Save(Path.GetFullPath(@"Output/Output.pdf")); }