From e29cdfa57154961da867320475c6eaf69c896a97 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 14 Jan 2026 16:52:32 +0530 Subject: [PATCH 1/3] 1004234: Updated the proper code in Playground sample. --- .../Program.cs | 2 - .../Program.cs | 44 ++++++++++++++----- 2 files changed, 32 insertions(+), 14 deletions(-) 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/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..aecabd94 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,41 @@ // 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" }, + new { ID = "E02", Name = "Thomas" }, + new { ID = "E03", Name = "John" } + }; + // 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)); + // Access the auto-generated header row and set custom column names + PdfGridRow header = pdfGrid.Headers[0]; + header.Cells[0].Value = "ID"; + header.Cells[1].Value = "Name"; + // Define padding and font for header and body cells + PdfPaddings paddings = new PdfPaddings(10, 8, 10, 8); + PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold); + // Create header style with padding, white text, blue background, and bold font + PdfGridCellStyle headerStyle = new PdfGridCellStyle + { + CellPadding = paddings, + TextBrush = new PdfSolidBrush(Color.White), + BackgroundBrush = new PdfSolidBrush(Color.Blue), + Font = font + }; + // Apply the header style to the header row + pdfGrid.Headers[0].ApplyStyle(headerStyle); + // Apply padding and font style to body cells + pdfGrid.Style.CellPadding = paddings; + pdfGrid.Style.Font = font; + // 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 From 8dfbfd94ddb85e0bc574952800b68a74dfdbb133 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 14 Jan 2026 16:55:41 +0530 Subject: [PATCH 2/3] 1004234: Removed unwanted changes. --- .../.NET/Create-table-from-data-source-in-a-PDF/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 aecabd94..5053b29f 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 @@ -16,7 +16,7 @@ new { ID = "E02", Name = "Thomas" }, new { ID = "E03", Name = "John" } }; - // Assign the data source to the grid (auto-generates a header row) + // Assign the data source to the grid pdfGrid.DataSource = data; // Access the auto-generated header row and set custom column names PdfGridRow header = pdfGrid.Headers[0]; @@ -25,7 +25,7 @@ // Define padding and font for header and body cells PdfPaddings paddings = new PdfPaddings(10, 8, 10, 8); PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold); - // Create header style with padding, white text, blue background, and bold font + // Create header style PdfGridCellStyle headerStyle = new PdfGridCellStyle { CellPadding = paddings, @@ -38,7 +38,7 @@ // Apply padding and font style to body cells pdfGrid.Style.CellPadding = paddings; pdfGrid.Style.Font = font; - // Draw the grid on the PDF page at specified position (with margin) + // Draw the grid on the PDF page at specified position pdfGrid.Draw(page, new PointF(20, 40)); // Save the PDF document document.Save(Path.GetFullPath(@"Output/Output.pdf")); From 914f1f7fbe0124b9c096e44b266da887db7b9ff5 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 14 Jan 2026 18:18:19 +0530 Subject: [PATCH 3/3] 1004234: Resolved given feedback. --- .../README.md | 2 -- .../Program.cs | 34 ++++++------------- .../README.md | 30 +++++++++------- 3 files changed, 28 insertions(+), 38 deletions(-) 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 5053b29f..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 @@ -12,33 +12,19 @@ // Prepare sample data for the grid object data = new List { - new { ID = "E01", Name = "Clay" }, - new { ID = "E02", Name = "Thomas" }, - new { ID = "E03", Name = "John" } + 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 + // Assign the data source to the grid (auto-generates a header row) pdfGrid.DataSource = data; - // Access the auto-generated header row and set custom column names - PdfGridRow header = pdfGrid.Headers[0]; - header.Cells[0].Value = "ID"; - header.Cells[1].Value = "Name"; - // Define padding and font for header and body cells - PdfPaddings paddings = new PdfPaddings(10, 8, 10, 8); - PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold); - // Create header style - PdfGridCellStyle headerStyle = new PdfGridCellStyle - { - CellPadding = paddings, - TextBrush = new PdfSolidBrush(Color.White), - BackgroundBrush = new PdfSolidBrush(Color.Blue), - Font = font - }; - // Apply the header style to the header row - pdfGrid.Headers[0].ApplyStyle(headerStyle); + //Apply built-in table style + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent6); // Apply padding and font style to body cells - pdfGrid.Style.CellPadding = paddings; - pdfGrid.Style.Font = font; - // Draw the grid on the PDF page at specified position + 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")); 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")); }