diff --git a/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures.sln b/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures.sln new file mode 100644 index 00000000..d99de2ab --- /dev/null +++ b/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Get-number-of-digital-signatures", "Get-number-of-digital-signatures\Get-number-of-digital-signatures.csproj", "{3129BC31-7611-4A6D-9ED0-C4ECB7888852}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3129BC31-7611-4A6D-9ED0-C4ECB7888852}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3129BC31-7611-4A6D-9ED0-C4ECB7888852}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3129BC31-7611-4A6D-9ED0-C4ECB7888852}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3129BC31-7611-4A6D-9ED0-C4ECB7888852}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Data/Input.pdf b/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Data/Input.pdf new file mode 100644 index 00000000..b088815a Binary files /dev/null and b/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Data/Input.pdf differ diff --git a/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Get-number-of-digital-signatures.csproj b/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Get-number-of-digital-signatures.csproj new file mode 100644 index 00000000..7426d8a2 --- /dev/null +++ b/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Get-number-of-digital-signatures.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Get_number_of_digital_signatures + enable + enable + + + + + + + diff --git a/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Program.cs b/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Program.cs new file mode 100644 index 00000000..35b0684b --- /dev/null +++ b/Digital Signature/Get-number-of-digital-signatures/.NET/Get-number-of-digital-signatures/Program.cs @@ -0,0 +1,38 @@ +using Syncfusion.Pdf.Parsing; + +// Initialize a counter to count the number of signature fields in the PDF document +int signedFieldsCount = 0; +int unSignedFieldsCount = 0; + +// Open the PDF document as a file stream +using (FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read)) +{ + // Load the PDF document from the file stream + using (PdfLoadedDocument doc = new PdfLoadedDocument(docStream)) + { + // Access the form inside the loaded PDF document + PdfLoadedForm form = doc.Form; + + // Iterate through each field in the form field collection + foreach (PdfLoadedField field in form.Fields) + { + PdfLoadedSignatureField sigField = field as PdfLoadedSignatureField; + // Check whether the signature field is signed or not + if (sigField != null) + { + if (sigField.IsSigned) + { + signedFieldsCount++; + } + else + { + unSignedFieldsCount++; + } + } + } + + // Display the total number of signature fields found in the PDF document + Console.WriteLine("The number of signed signature fields in the PDF document: " + signedFieldsCount); + Console.WriteLine("The number of unSigned signature fields in the PDF document: " + unSignedFieldsCount); + } +} \ No newline at end of file diff --git a/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width.sln b/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width.sln new file mode 100644 index 00000000..89a2a74d --- /dev/null +++ b/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resize-font-to-fit-grid-cell-width", "Resize-font-to-fit-grid-cell-width\Resize-font-to-fit-grid-cell-width.csproj", "{13AC0FBB-D3CE-4370-BA00-2A639A4990BA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {13AC0FBB-D3CE-4370-BA00-2A639A4990BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13AC0FBB-D3CE-4370-BA00-2A639A4990BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13AC0FBB-D3CE-4370-BA00-2A639A4990BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13AC0FBB-D3CE-4370-BA00-2A639A4990BA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width/Output/.gitkeep b/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width/Program.cs b/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width/Program.cs new file mode 100644 index 00000000..75b0146c --- /dev/null +++ b/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width/Program.cs @@ -0,0 +1,107 @@ +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Drawing; + +class Program +{ + static void Main(string[] args) + { + // Create a new PDF document. + PdfDocument document = new PdfDocument(); + + // Add a page to the document. + PdfPage page = document.Pages.Add(); + + // Create a PdfGrid. + PdfGrid grid = new PdfGrid(); + + // Set the font for the grid. + grid.Style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); + + // Add three columns to the grid. + grid.Columns.Add(3); + + // Set the width of each column. + for (int i = 0; i < 3; i++) + { + grid.Columns[i].Width = page.GetClientSize().Width / 3; + } + + // Set up the header cells. + PdfGridRow pdfGridHeader = grid.Headers.Add(1)[0]; + pdfGridHeader.Cells[0].Value = "Employee ID"; + pdfGridHeader.Cells[1].Value = "Employee Name"; + pdfGridHeader.Cells[2].Value = "Details"; + + // Add rows to the grid. + for (int i = 1; i <= 5; i++) + { + PdfGridRow row = grid.Rows.Add(); + row.Height = 20; + row.Cells[0].Value = "E0" + i; + row.Cells[1].Value = "Employee " + i; + row.Cells[2].Value = String.Format("Employee {0} is a software engineer with over ten years of experience in developing scalable applications. He specializes in full-stack development and enjoys working on innovative projects.", i); + } + + // Adjust the font size to fit the cell content. + AdjustFontSize(grid); + + // Draw the PdfGrid on the page. + grid.Draw(page, PointF.Empty); + + // Save and close the document. + using (FileStream stream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + document.Save(stream); + } + document.Close(true); + } + + // Method to adjust the font size to fit the cell content. + public static void AdjustFontSize(PdfGrid grid) + { + for (int i = 0; i < grid.Rows.Count; i++) + { + for (int j = 0; j < grid.Columns.Count; j++) + { + // Get the cell. + PdfGridCell cell = grid.Rows[i].Cells[j]; + + // Get the cell font. + PdfFont initialFont = cell.Style.Font ?? grid.Style.Font; + + // Get the cell value. + string text = cell.Value?.ToString() ?? string.Empty; + + // Get the cell size. + SizeF cellSize = new SizeF(grid.Columns[j].Width, grid.Rows[i].Height); + + // Get the initial font size. + float fontSize = initialFont.Size; + + PdfFont currentFont = initialFont; + + while (fontSize > 0) + { + // Measure the text. + SizeF textSize = currentFont.MeasureString(text, cellSize.Width); + if (textSize.Height <= cellSize.Height) + { + cell.Style.Font = currentFont; + break; + } + fontSize--; + if (initialFont is PdfStandardFont) + { + currentFont = new PdfStandardFont(initialFont as PdfStandardFont, fontSize); + } + else + { + currentFont = new PdfTrueTypeFont(initialFont as PdfTrueTypeFont, fontSize); + } + } + } + } + } +} diff --git a/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width/Resize-font-to-fit-grid-cell-width.csproj b/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width/Resize-font-to-fit-grid-cell-width.csproj new file mode 100644 index 00000000..1c53042a --- /dev/null +++ b/Table/PdfGrid/Resize-font-to-fit-grid-cell-width/.NET/Resize-font-to-fit-grid-cell-width/Resize-font-to-fit-grid-cell-width.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Resize_font_to_fit_grid_cell_width + enable + enable + + + + + + + diff --git a/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid.sln b/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid.sln new file mode 100644 index 00000000..f55c70e6 --- /dev/null +++ b/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Set-different-margins-for-multi-page-PDF-grid", "Set-different-margins-for-multi-page-PDF-grid\Set-different-margins-for-multi-page-PDF-grid.csproj", "{C8EB4001-9E7D-4340-8E5A-73B50908E0F0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C8EB4001-9E7D-4340-8E5A-73B50908E0F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8EB4001-9E7D-4340-8E5A-73B50908E0F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8EB4001-9E7D-4340-8E5A-73B50908E0F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8EB4001-9E7D-4340-8E5A-73B50908E0F0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid/Output/.gitkeep b/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid/Program.cs b/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid/Program.cs new file mode 100644 index 00000000..7f2a4498 --- /dev/null +++ b/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid/Program.cs @@ -0,0 +1,40 @@ +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; + +//Create a new PDF document. +PdfDocument document = new PdfDocument(); +//Set page margins +document.PageSettings.Margins.Top = 50; +document.PageSettings.Margins.Bottom = 50; +//Add a new PDF page. +PdfPage page = document.Pages.Add(); +//Create a PdfGrid. +PdfGrid pdfGrid = new PdfGrid(); +//Add values to the list. +List data = new List(); +for (int i = 0; i < 100; i++) +{ + Object row1 = new { ID = "1", Name = "Clay", Price = "$10" }; + Object row2 = new { ID = "2", Name = "Gray", Price = "$20" }; + Object row3 = new { ID = "3", Name = "Ash", Price = "$30" }; + data.Add(row1); + data.Add(row2); + data.Add(row3); +} +//Add list to IEnumerable. +IEnumerable tableData = data; +//Assign data source. +pdfGrid.DataSource = tableData; +PdfGridLayoutFormat format = new PdfGridLayoutFormat(); +//Set paginate bounds +format.PaginateBounds = new Syncfusion.Drawing.RectangleF(0, 15, page.GetClientSize().Width, page.GetClientSize().Height - 15); +//Draw the grid, letting Syncfusion handle pagination. +pdfGrid.Draw(page, new Syncfusion.Drawing.RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format); +//Create file stream. +using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document to file stream. + document.Save(outputFileStream); +} +//Close the document. +document.Close(true); \ No newline at end of file diff --git a/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid/Set-different-margins-for-multi-page-PDF-grid.csproj b/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid/Set-different-margins-for-multi-page-PDF-grid.csproj new file mode 100644 index 00000000..e1d298e7 --- /dev/null +++ b/Table/PdfGrid/Set-different-margins-for-multi-page-PDF-grid/.NET/Set-different-margins-for-multi-page-PDF-grid/Set-different-margins-for-multi-page-PDF-grid.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Set_different_margins_for_multi_page_PDF_grid + enable + enable + + + + + + +