diff --git a/Digital Signature/Add-a-digital-signature-to-an-existing-document/.NET/Add-a-digital-signature-to-an-existing-document/Program.cs b/Digital Signature/Add-a-digital-signature-to-an-existing-document/.NET/Add-a-digital-signature-to-an-existing-document/Program.cs index 307f7282..dbd2ec36 100644 --- a/Digital Signature/Add-a-digital-signature-to-an-existing-document/.NET/Add-a-digital-signature-to-an-existing-document/Program.cs +++ b/Digital Signature/Add-a-digital-signature-to-an-existing-document/.NET/Add-a-digital-signature-to-an-existing-document/Program.cs @@ -10,7 +10,8 @@ // Gets the first page of the document PdfPageBase page = loadedDocument.Pages[0]; // Load the certificate from a PFX file with a private key - PdfCertificate pdfCert = new PdfCertificate(Path.GetFullPath(@"Data/PDF.pfx"), "syncfusion"); + using FileStream certificate = new FileStream(Path.GetFullPath(@"Data/PDF.pfx"), FileMode.Open, FileAccess.Read); + PdfCertificate pdfCert = new PdfCertificate(certificate, "syncfusion"); // Create a signature PdfSignature signature = new PdfSignature(loadedDocument, page, pdfCert, "Signature"); // Set signature information diff --git a/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs b/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs index 47d3348a..4d5f3a9d 100644 --- a/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs +++ b/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs @@ -1,12 +1,14 @@ using Syncfusion.Pdf; -//Creates a new PDF document +//Creates a PDF document. using (PdfDocument document = new PdfDocument()) { - //Creates a string array of source files to be merged - string[] source = { Path.GetFullPath(@"Data/file1.pdf"), Path.GetFullPath(@"Data/file2.pdf") }; - //Merge PDF documents - PdfDocument.Merge(document, source); - //Saves the PDF document + using FileStream stream1 = new FileStream(Path.GetFullPath(@"Data/file1.pdf"), FileMode.Open, FileAccess.Read); + using FileStream stream2 = new FileStream(Path.GetFullPath(@"Data/file2.pdf"), FileMode.Open, FileAccess.Read); + //Creates a PDF stream for merging. + Stream[] streams = { stream1, stream2 }; + //Merges PDFDocument. + PdfDocumentBase.Merge(document, streams); + //Save the merged document document.Save(Path.GetFullPath(@"Output/Output.pdf")); } \ No newline at end of file diff --git a/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/Program.cs b/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/Program.cs index 94091d2e..0c67c2d9 100644 --- a/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/Program.cs +++ b/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/Program.cs @@ -4,5 +4,5 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf"))) { //Split the pages into separate documents - loadedDocument.Split("Output" + "{0}.pdf"); + loadedDocument.Split(Path.GetFullPath(@"Output/Output"+ "{0}.pdf")); } \ No newline at end of file diff --git a/Performance Metrics/.NET/Apply-watermark/Apply-watermark.slnx b/Performance Metrics/.NET/Apply-watermark/Apply-watermark.slnx new file mode 100644 index 00000000..54ac5a7b --- /dev/null +++ b/Performance Metrics/.NET/Apply-watermark/Apply-watermark.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Apply-watermark.csproj b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Apply-watermark.csproj new file mode 100644 index 00000000..d7db6fff --- /dev/null +++ b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Apply-watermark.csproj @@ -0,0 +1,15 @@ + + + + Exe + net10.0 + Apply_watermark + enable + enable + + + + + + + diff --git a/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Data/JavaScript_Succinctly.pdf b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Data/JavaScript_Succinctly.pdf new file mode 100644 index 00000000..420529b5 Binary files /dev/null and b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Data/JavaScript_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Data/PDF_Succinctly.pdf b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Data/PDF_Succinctly.pdf new file mode 100644 index 00000000..3e155123 Binary files /dev/null and b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Data/PDF_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Output/gitkeep.txt b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Program.cs b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Program.cs new file mode 100644 index 00000000..77ff4598 --- /dev/null +++ b/Performance Metrics/.NET/Apply-watermark/Apply-watermark/Program.cs @@ -0,0 +1,59 @@ +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; +using System.Diagnostics; +using Syncfusion.Drawing; + +class Program +{ + private static readonly PdfFont WatermarkFont = new PdfStandardFont(PdfFontFamily.Helvetica, 60, PdfFontStyle.Bold); + private static readonly PdfBrush WatermarkBrush = new PdfSolidBrush(Color.Gray); + private const string WatermarkText = "CONFIDENTIAL"; + + static void Main() + { + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY"); + string inputFolder = Path.GetFullPath("../../../Data/"); + string outputFolder = Path.GetFullPath("../../../Output/"); + Directory.CreateDirectory(outputFolder); + string[] files = Directory.GetFiles(inputFolder, "*.pdf"); + foreach (string inputPath in files) + { + string fileName = Path.GetFileName(inputPath); + string outputPath = Path.Combine(outputFolder, fileName); + Stopwatch stopwatch = Stopwatch.StartNew(); + try + { + PdfLoadedDocument document = new PdfLoadedDocument(inputPath); + // Apply watermark to all pages + foreach (PdfPageBase page in document.Pages) + { + AddWatermark(page.Graphics, page.Size); + } + document.Save(outputPath); + stopwatch.Stop(); + Console.WriteLine($"{fileName} Apply watermark processed in {stopwatch.Elapsed.TotalSeconds:F2} seconds"); + document.Close(true); + } + catch (Exception ex) + { + stopwatch.Stop(); + Console.WriteLine($" Error processing {fileName}: {ex.Message}"); + } + } + } + static void AddWatermark(PdfGraphics graphics, SizeF pageSize) + { + PdfGraphicsState state = graphics.Save(); + graphics.SetTransparency(0.3f); + + SizeF textSize = WatermarkFont.MeasureString(WatermarkText); + + graphics.TranslateTransform(pageSize.Width / 2, pageSize.Height / 2); + graphics.RotateTransform(-45); + graphics.TranslateTransform(-textSize.Width / 2, -textSize.Height / 2); + + graphics.DrawString(WatermarkText, WatermarkFont, WatermarkBrush, 0, 0); + graphics.Restore(state); + } +} diff --git a/Performance Metrics/.NET/Compress-pdf/Compress-pdf.slnx b/Performance Metrics/.NET/Compress-pdf/Compress-pdf.slnx new file mode 100644 index 00000000..cb3c7043 --- /dev/null +++ b/Performance Metrics/.NET/Compress-pdf/Compress-pdf.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Compress-pdf.csproj b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Compress-pdf.csproj new file mode 100644 index 00000000..5e0505ad --- /dev/null +++ b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Compress-pdf.csproj @@ -0,0 +1,15 @@ + + + + Exe + net10.0 + Compress_pdf + enable + enable + + + + + + + diff --git a/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Data/JavaScript_Succinctly.pdf b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Data/JavaScript_Succinctly.pdf new file mode 100644 index 00000000..420529b5 Binary files /dev/null and b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Data/JavaScript_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Data/PDF_Succinctly.pdf b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Data/PDF_Succinctly.pdf new file mode 100644 index 00000000..3e155123 Binary files /dev/null and b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Data/PDF_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Output/gitkeep.txt b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Program.cs b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Program.cs new file mode 100644 index 00000000..bc380f5b --- /dev/null +++ b/Performance Metrics/.NET/Compress-pdf/Compress-pdf/Program.cs @@ -0,0 +1,41 @@ +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; +using System.Diagnostics; + +class Program +{ + static void Main() + { + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY"); + string inputFolder = Path.GetFullPath("../../../Data/"); + string outputFolder = Path.GetFullPath("../../../Output/"); + Directory.CreateDirectory(outputFolder); + // Get all .pdf files in the Data folder + string[] files = Directory.GetFiles(inputFolder, "*.pdf"); + foreach (string inputPath in files) + { + string fileName = Path.GetFileName(inputPath); + string outputPath = Path.Combine(outputFolder, fileName); + Stopwatch stopwatch = Stopwatch.StartNew(); + try + { + // Load the PDF document + PdfLoadedDocument document = new PdfLoadedDocument(inputPath); + // Create compression options + PdfCompressionOptions options = new PdfCompressionOptions(); + options.ImageQuality = 50; // Set the image quality to 50% for compression + // Compress the PDF document + document.Compress(options); + // Save the compressed document to Output folder + document.Save(outputPath); + Console.WriteLine($"{fileName} Compress-pdf Time: {stopwatch.Elapsed.TotalSeconds:F2} seconds\n"); + document.Close(true); + } + catch (Exception ex) + { + stopwatch.Stop(); + Console.WriteLine($" Error processing {fileName}: {ex.Message}\n"); + } + } + } +} \ No newline at end of file diff --git a/Performance Metrics/.NET/Document_creation/Document_creation.slnx b/Performance Metrics/.NET/Document_creation/Document_creation.slnx new file mode 100644 index 00000000..9ad8feb0 --- /dev/null +++ b/Performance Metrics/.NET/Document_creation/Document_creation.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Performance Metrics/.NET/Document_creation/Document_creation/Data/logo.png b/Performance Metrics/.NET/Document_creation/Document_creation/Data/logo.png new file mode 100644 index 00000000..02194707 Binary files /dev/null and b/Performance Metrics/.NET/Document_creation/Document_creation/Data/logo.png differ diff --git a/Performance Metrics/.NET/Document_creation/Document_creation/Document_creation.csproj b/Performance Metrics/.NET/Document_creation/Document_creation/Document_creation.csproj new file mode 100644 index 00000000..199fb3da --- /dev/null +++ b/Performance Metrics/.NET/Document_creation/Document_creation/Document_creation.csproj @@ -0,0 +1,14 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + diff --git a/Performance Metrics/.NET/Document_creation/Document_creation/Output/gitkeep.txt b/Performance Metrics/.NET/Document_creation/Document_creation/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Performance Metrics/.NET/Document_creation/Document_creation/Program.cs b/Performance Metrics/.NET/Document_creation/Document_creation/Program.cs new file mode 100644 index 00000000..e84744c0 --- /dev/null +++ b/Performance Metrics/.NET/Document_creation/Document_creation/Program.cs @@ -0,0 +1,48 @@ +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using System.Diagnostics; + +class Program +{ + static void Main() + { + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("your License key"); + + string inputFolder = Path.GetFullPath("../../../Data/"); + string outputFolder = Path.GetFullPath("../../../Output/"); + Directory.CreateDirectory(outputFolder); + string Outputfile = "DocumentCreation"; + int[] count = { 1, 100, 500, 1000 }; + string content = "Syncfusion is a leading provider of software components and frameworks for enterprise application development, established in 2001 and headquartered in Research Triangle Park, North Carolina. Over the past two decades, the company has grown to become one of the most comprehensive providers of UI controls, frameworks, and development tools for modern application development across multiple platforms. With a global presence serving customers in over 125 countries, Syncfusion has established itself as a trusted partner for developers building modern, scalable, and feature-rich applications.\r\n\r\nSyncfusion specializes in providing over 1,800+ components and frameworks that span across various platforms including web, mobile, and desktop applications. Their extensive product portfolio includes controls for popular frameworks such as ASP.NET Core, ASP.NET MVC, Blazor, JavaScript, Angular, React, Vue.js, jQuery, Xamarin, .NET MAUI, Flutter, WinForms, WPF, WinUI, and UWP. This comprehensive coverage ensures that developers can maintain consistency and quality across different platforms while using familiar tools and components. The company's offerings are specifically designed for enterprise-grade applications with features that include high performance optimization for handling large datasets, WCAG 2.2 compliant accessibility standards, built-in localization support for internationalization, comprehensive theming capabilities, and responsive designs that work seamlessly on touch-enabled devices.\r\n\r\nOne of Syncfusion's core strengths lies in its extensive library of professionally designed UI components and controls. The product suite includes sophisticated data grids with advanced filtering and editing capabilities, comprehensive charting libraries featuring dozens of chart types from basic visualizations to advanced financial charts and 3D representations, powerful schedulers and calendar controls, diagram libraries supporting flowcharts and organizational charts, spreadsheet components, PDF viewers and editors, word processors, and much more. These components are known for their high performance, rich feature sets, consistent design across platforms, and ability to handle complex enterprise requirements. Additionally, Syncfusion provides powerful file format libraries that enable developers to create, read, edit, and convert various file formats including PDF documents, Excel spreadsheets, Word documents, and PowerPoint presentations without requiring Microsoft Office or Adobe dependencies, making them ideal for server-side and cloud-based applications.\r\n\r\nSyncfusion demonstrates exceptional commitment to developer productivity and experience through multiple channels. The company provides extensive documentation with comprehensive examples and API references, hundreds of demo applications showcasing component capabilities and best practices, industry-leading technical support with direct access to experienced engineers, regular updates with new features and improvements, and seamless integration with Visual Studio and other popular IDEs. This focus on developer experience extends to their flexible licensing options, which include commercial licenses for businesses and enterprises, a notable Community License program that provides free access to the complete product suite for individual developers and small businesses with less than $1 million in annual gross revenue, and free educational licenses for students and educators. This Community License program has been particularly impactful in making professional-grade components accessible to startups, freelancers, and small development teams who might otherwise be unable to afford enterprise-level tools.\r\n\r\nThe company continues to innovate and push boundaries in the development tools space."; + PdfFont font = new PdfStandardFont(Syncfusion.Pdf.Graphics.PdfFontFamily.Helvetica, 12); + FileStream fileStream = File.OpenRead("../../../Data/logo.png"); + foreach (int numberOfPages in count) + { + string outputPath = Path.Combine(outputFolder, Outputfile); + Stopwatch stopwatch = Stopwatch.StartNew(); + try + { + PdfDocument document = new PdfDocument(); + fileStream.Position = 0; + PdfBitmap image = new PdfBitmap(fileStream); + for (int i=0; i< numberOfPages; i++) + { + PdfPage page = document.Pages.Add(); + page.Graphics.DrawImage(image, 0, 0, 100, 100); + page.Graphics.DrawString(content, font, PdfBrushes.Black, new RectangleF(0, 110, page.Graphics.ClientSize.Width, page.Graphics.ClientSize.Height)); + + } + // Save the document to Output folder + document.Save(outputPath + numberOfPages+".pdf"); + document.Close(true); + stopwatch.Stop(); + Console.WriteLine($"Document Creation Number of pages {numberOfPages} in {stopwatch.Elapsed.TotalSeconds} seconds"); + } + catch (Exception ex) + { + Console.WriteLine($"Error processing : {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/Performance Metrics/.NET/Merge-Documents/Merge-Documents.slnx b/Performance Metrics/.NET/Merge-Documents/Merge-Documents.slnx new file mode 100644 index 00000000..98061173 --- /dev/null +++ b/Performance Metrics/.NET/Merge-Documents/Merge-Documents.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Data/JavaScript_Succinctly.pdf b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Data/JavaScript_Succinctly.pdf new file mode 100644 index 00000000..420529b5 Binary files /dev/null and b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Data/JavaScript_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Data/PDF_Succinctly.pdf b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Data/PDF_Succinctly.pdf new file mode 100644 index 00000000..3e155123 Binary files /dev/null and b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Data/PDF_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Merge-Documents.csproj b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Merge-Documents.csproj new file mode 100644 index 00000000..99bec313 --- /dev/null +++ b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Merge-Documents.csproj @@ -0,0 +1,19 @@ + + + + Exe + net10.0 + Merge_Documents + enable + enable + + + + + + + + + + + diff --git a/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Output/gitkeep.txt b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Program.cs b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Program.cs new file mode 100644 index 00000000..63c5db14 --- /dev/null +++ b/Performance Metrics/.NET/Merge-Documents/Merge-Documents/Program.cs @@ -0,0 +1,44 @@ +using Syncfusion.Pdf; +using System.Diagnostics; + +class Program +{ + static void Main() + { + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY"); + // Get input and output folder + string inputFolder = Path.GetFullPath("../../../Data/"); + string outputFolder = Path.GetFullPath("../../../Output/"); + string fileName = "MergePdf.pdf"; + string inputFile = string.Empty; + Directory.CreateDirectory(outputFolder); + // Get all .pdf files in the Data folder + string[] source = Directory.GetFiles(inputFolder, "*.pdf"); + Stream[] streams = new Stream[source.Length]; + for (int i = 0; i < source.Length; i++) + { + //Open the PDF document as a stream. + streams[i] = new FileStream(source[i], FileMode.Open, FileAccess.Read, FileShare.Read); + inputFile += Path.GetFileName(source[i]); + inputFile = (i + 1 < source.Length) ? inputFile += ", " : inputFile += string.Empty; + } + string outputPath = Path.Combine(outputFolder, fileName); + Stopwatch stopwatch = Stopwatch.StartNew(); + try + { + //Create a new PDF document. + PdfDocument finalDoc = new PdfDocument(); + PdfDocument.Merge(finalDoc, streams); + //Save the final document. + finalDoc.Save(outputPath); + //Close the document. + finalDoc.Close(true); + stopwatch.Stop(); + Console.WriteLine($"{inputFile} Merge Documents in {stopwatch.Elapsed.TotalSeconds} seconds"); + } + catch (Exception ex) + { + Console.WriteLine($"Error processing {fileName}: {ex.Message}"); + } + } +} \ No newline at end of file diff --git a/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document.slnx b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document.slnx new file mode 100644 index 00000000..2e6c7ce9 --- /dev/null +++ b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Data/JavaScript_Succinctly.pdf b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Data/JavaScript_Succinctly.pdf new file mode 100644 index 00000000..420529b5 Binary files /dev/null and b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Data/JavaScript_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Data/PDF_Succinctly.pdf b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Data/PDF_Succinctly.pdf new file mode 100644 index 00000000..3e155123 Binary files /dev/null and b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Data/PDF_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Open-and-Save-document.csproj b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Open-and-Save-document.csproj new file mode 100644 index 00000000..b4395506 --- /dev/null +++ b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Open-and-Save-document.csproj @@ -0,0 +1,15 @@ + + + + Exe + net10.0 + Open_and_Save_document + enable + enable + + + + + + + diff --git a/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Output/gitkeep.txt b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Program.cs b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Program.cs new file mode 100644 index 00000000..9fbfca57 --- /dev/null +++ b/Performance Metrics/.NET/Open-and-Save-document/Open-and-Save-document/Program.cs @@ -0,0 +1,36 @@ +using Syncfusion.Pdf.Parsing; +using System.Diagnostics; + +class Program +{ + static void Main() + { + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY"); + + string inputFolder = Path.GetFullPath("../../../Data/"); + string outputFolder = Path.GetFullPath("../../../Output/"); + Directory.CreateDirectory(outputFolder); + // Get all .pdf files in the Data folder + string[] files = Directory.GetFiles(inputFolder, "*.pdf"); + foreach (string inputPath in files) + { + string fileName = Path.GetFileName(inputPath); + string outputPath = Path.Combine(outputFolder, fileName); + Stopwatch stopwatch = Stopwatch.StartNew(); + try + { + // Load or open document + PdfLoadedDocument document = new PdfLoadedDocument(inputPath); + // Save the document to Output folder + document.Save(outputPath); + stopwatch.Stop(); + Console.WriteLine($"{fileName} open and saved in {stopwatch.Elapsed.TotalSeconds} seconds"); + document.Close(true); + } + catch (Exception ex) + { + Console.WriteLine($"Error processing {fileName}: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/Performance Metrics/.NET/Split-PDF/Split-PDF.slnx b/Performance Metrics/.NET/Split-PDF/Split-PDF.slnx new file mode 100644 index 00000000..1870208e --- /dev/null +++ b/Performance Metrics/.NET/Split-PDF/Split-PDF.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Performance Metrics/.NET/Split-PDF/Split-PDF/Data/JavaScript_Succinctly.pdf b/Performance Metrics/.NET/Split-PDF/Split-PDF/Data/JavaScript_Succinctly.pdf new file mode 100644 index 00000000..420529b5 Binary files /dev/null and b/Performance Metrics/.NET/Split-PDF/Split-PDF/Data/JavaScript_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Split-PDF/Split-PDF/Data/PDF_Succinctly.pdf b/Performance Metrics/.NET/Split-PDF/Split-PDF/Data/PDF_Succinctly.pdf new file mode 100644 index 00000000..3e155123 Binary files /dev/null and b/Performance Metrics/.NET/Split-PDF/Split-PDF/Data/PDF_Succinctly.pdf differ diff --git a/Performance Metrics/.NET/Split-PDF/Split-PDF/Output/gitkeep.txt b/Performance Metrics/.NET/Split-PDF/Split-PDF/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Performance Metrics/.NET/Split-PDF/Split-PDF/Program.cs b/Performance Metrics/.NET/Split-PDF/Split-PDF/Program.cs new file mode 100644 index 00000000..0cadf555 --- /dev/null +++ b/Performance Metrics/.NET/Split-PDF/Split-PDF/Program.cs @@ -0,0 +1,36 @@ +using Syncfusion.Pdf.Parsing; +using System.Diagnostics; + +class Program +{ + static void Main() + { + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY"); + + string inputFolder = Path.GetFullPath("../../../Data/"); + string outputFolder = Path.GetFullPath("../../../Output/"); + Directory.CreateDirectory(outputFolder); + // Get all .pdf files in the Data folder + string[] files = Directory.GetFiles(inputFolder, "*.pdf"); + foreach (string inputPath in files) + { + string fileName = Path.GetFileName(inputPath); + string outputPath = Path.Combine(outputFolder, fileName); + Stopwatch stopwatch = Stopwatch.StartNew(); + try + { + // Load the PDF document + PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPath); + loadedDocument.Split(outputPath); + stopwatch.Stop(); + Console.WriteLine($"{fileName} Split PDF documents in {stopwatch.Elapsed.TotalSeconds} seconds"); + // Close the original document + loadedDocument.Close(true); + } + catch (Exception ex) + { + Console.WriteLine($"Error processing {fileName}: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/Performance Metrics/.NET/Split-PDF/Split-PDF/Split-PDF.csproj b/Performance Metrics/.NET/Split-PDF/Split-PDF/Split-PDF.csproj new file mode 100644 index 00000000..b88f5be0 --- /dev/null +++ b/Performance Metrics/.NET/Split-PDF/Split-PDF/Split-PDF.csproj @@ -0,0 +1,15 @@ + + + + Exe + net10.0 + Split_PDF + enable + enable + + + + + + +