diff --git a/Annotation/Add-popup-annotation-in-a-PDF-document/.NET/Add-popup-annotation-in-a-PDF-document/README.md b/Annotation/Add-popup-annotation-in-a-PDF-document/.NET/Add-popup-annotation-in-a-PDF-document/README.md new file mode 100644 index 00000000..43459eb3 --- /dev/null +++ b/Annotation/Add-popup-annotation-in-a-PDF-document/.NET/Add-popup-annotation-in-a-PDF-document/README.md @@ -0,0 +1,58 @@ +# PDF Annotations + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) provides powerful tools to create, read, and edit PDF documents. This library also includes features to add, edit, and manage annotations in PDF files, enabling effective markup and collaboration. + +## Steps to add annotations to a PDF + +Follow these steps to add a popup annotation to a PDF file using the Syncfusion library: + +1. **Create a new project**: Set up a new C# Console Application project. + +2. **Install NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your .NET Standard application from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add the following namespaces to your `Program.cs` file: + + ```csharp + using Syncfusion.Drawing; + using Syncfusion.Pdf; + using Syncfusion.Pdf.Graphics; + using Syncfusion.Pdf.Interactive; + using Syncfusion.Pdf.Parsing; + ``` + +4. **Code to add annotations**: Use the following code snippet in `Program.cs` to insert annotations into a PDF file: + + ```csharp + // Create a FileStream object to read the input PDF file + using (FileStream inputFileStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read)) + { + // Load the PDF document from the input stream + using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream)) + { + // Access the first page of the PDF document + PdfPageBase loadedPage = loadedDocument.Pages[0]; + + // Create a new popup annotation + PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation(new RectangleF(100, 100, 20, 20), "Comment"); + + // Set the icon for the popup annotation + popupAnnotation.Icon = PdfPopupIcon.Comment; + + // Set the color for the popup annotation + popupAnnotation.Color = new PdfColor(Color.Yellow); + + // Add the annotation to the page + loadedPage.Annotations.Add(popupAnnotation); + + // Save the updated document + using (FileStream outputFileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) + { + loadedDocument.Save(outputFileStream); + } + } + } + ``` + +For a complete working example, visit the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Annotation/Add-a-popup-annotation-to-an-existing-PDF-document/.NET). + +To learn more about the extensive features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Compression/Compress-the-images-in-an-existing-PDF-document/.NET/Compress-the-images-in-an-existing-PDF-document/README.md b/Compression/Compress-the-images-in-an-existing-PDF-document/.NET/Compress-the-images-in-an-existing-PDF-document/README.md new file mode 100644 index 00000000..09c54a0f --- /dev/null +++ b/Compression/Compress-the-images-in-an-existing-PDF-document/.NET/Compress-the-images-in-an-existing-PDF-document/README.md @@ -0,0 +1,59 @@ +# Compressing PDF Files + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) allows users to seamlessly create, read, and edit PDF documents. Additionally, it offers features for compressing PDF files, which helps reduce their size without sacrificing quality—optimizing storage and enhancing the efficiency of file sharing. + +## Steps to compress PDF files + +Follow these steps to compress PDF files using the Syncfusion library: + +1. **Create a new project**: Set up a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project from [NuGet.org](https://www.nuget.org/). + +3. **Add required namespaces**: Include the following namespaces in your `Program.cs` file: + + ```csharp + using Syncfusion.Pdf.Parsing; + using Syncfusion.Pdf; + ``` + +4. **Implement PDF compression**: Use the following code snippet in `Program.cs` to compress PDF files: + + ```csharp + // Open a file stream to read the input PDF file + using (FileStream fileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) + { + // Load the PDF document from the file stream + using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream)) + { + // Create a new PdfCompressionOptions object + PdfCompressionOptions options = new PdfCompressionOptions(); + + // Enable image compression and set the image quality + options.CompressImages = true; + options.ImageQuality = 50; + + // Enable font optimization + options.OptimizeFont = true; + + // Enable page content optimization + options.OptimizePageContents = true; + + // Remove metadata from the PDF + options.RemoveMetadata = true; + + // Compress the PDF document + loadedDocument.Compress(options); + + // Save the document into a memory stream + using (MemoryStream outputStream = new MemoryStream()) + { + loadedDocument.Save(outputStream); + } + } + } + ``` + +You can download a complete working sample from the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Compression/Compress-the-images-in-an-existing-PDF-document). + +To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Digital Signature/Add-a-digital-signature-to-an-existing-document/.NET/Add-a-digital-signature-to-an-existing-document/README.md b/Digital Signature/Add-a-digital-signature-to-an-existing-document/.NET/Add-a-digital-signature-to-an-existing-document/README.md new file mode 100644 index 00000000..f01637d9 --- /dev/null +++ b/Digital Signature/Add-a-digital-signature-to-an-existing-document/.NET/Add-a-digital-signature-to-an-existing-document/README.md @@ -0,0 +1,68 @@ +# Digital Signature + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) offers powerful capabilities for creating, reading, and editing PDF documents. One of its robust features is the ability to apply digital signatures to PDF files, ensuring document authenticity, integrity, and security. + +## Steps to add a digital signature to PDF files + +Follow these steps to digitally sign PDF files using the Syncfusion library: + +1. **Create a new project**: Start by creating a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add the following namespaces in your `Program.cs` file: + + ```csharp + using Syncfusion.Pdf; + using Syncfusion.Pdf.Graphics; + using Syncfusion.Pdf.Parsing; + using Syncfusion.Pdf.Security; + using Syncfusion.Drawing; + ``` + +4. **Add digital signature code**: Use the following code snippet in `Program.cs` to add a digital signature to a PDF file: + + ```csharp + // Open the existing PDF document as a stream + using (FileStream inputStream = new FileStream(Path.GetFullPath("Input.pdf"), FileMode.Open, FileAccess.Read)) + { + // Load the existing PDF document + PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream); + + // Get the first page of the document + PdfPageBase page = loadedDocument.Pages[0]; + + // Load the certificate from a PFX file with a private key + FileStream certificateStream = new FileStream(@"PDF.pfx", FileMode.Open, FileAccess.Read); + PdfCertificate pdfCert = new PdfCertificate(certificateStream, "password123"); + + // Create a signature + PdfSignature signature = new PdfSignature(loadedDocument, page, pdfCert, "Signature"); + + // Set signature information + signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(200, 100)); + signature.ContactInfo = "johndoe@owned.us"; + signature.LocationInfo = "Honolulu, Hawaii"; + signature.Reason = "I am the author of this document."; + + // Load the image for the signature field + FileStream imageStream = new FileStream("signature.png", FileMode.Open, FileAccess.Read); + PdfBitmap signatureImage = new PdfBitmap(imageStream); + + // Draw the image on the signature field + signature.Appearance.Normal.Graphics.DrawImage(signatureImage, new RectangleF(0, 0, signature.Bounds.Width, signature.Bounds.Height)); + + // Save the document to a file stream + using (FileStream outputFileStream = new FileStream("signed.pdf", FileMode.Create, FileAccess.ReadWrite)) + { + loadedDocument.Save(outputFileStream); + } + + // Close the document + loadedDocument.Close(true); + } + ``` + +For a complete working example, visit the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Digital%20Signature/Add-a-digital-signature-to-an-existing-document/). + +To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Forms/Add-a-textbox-field-to-a-new-PDF-document/.NET/Add-a-textbox-field-to-a-new-PDF-document/README.md b/Forms/Add-a-textbox-field-to-a-new-PDF-document/.NET/Add-a-textbox-field-to-a-new-PDF-document/README.md new file mode 100644 index 00000000..93b0c6c7 --- /dev/null +++ b/Forms/Add-a-textbox-field-to-a-new-PDF-document/.NET/Add-a-textbox-field-to-a-new-PDF-document/README.md @@ -0,0 +1,68 @@ +# PDF Forms + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) provides an easy way to create, read, and edit PDF documents. It also includes features for creating, filling, and editing PDF forms, which can include interactive form fields and form data. + +## Steps to create PDF forms + +Follow these steps to create a PDF form with a textbox field: + +1. **Create a new project**: Start by creating a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add the following namespaces in your `Program.cs` file: + + ```csharp + using Syncfusion.Drawing; + using Syncfusion.Pdf; + using Syncfusion.Pdf.Graphics; + using Syncfusion.Pdf.Interactive; + ``` + +4. **Create PDF forms**: Implement the following code in `Program.cs` to add a textbox field to a PDF document: + + ```csharp + // Create a new PDF document + using (PdfDocument pdfDocument = new PdfDocument()) + { + // Add a new page to the PDF document + PdfPage pdfPage = pdfDocument.Pages.Add(); + + // Set the standard font + PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 16); + + // Draw the title "Job Application" + pdfPage.Graphics.DrawString("Job Application", font, PdfBrushes.Black, new PointF(250, 0)); + + // Change the font size for form fields + font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); + + // Draw the label "Name" + pdfPage.Graphics.DrawString("Name", font, PdfBrushes.Black, new PointF(10, 20)); + + // Create a textbox field for the name + PdfTextBoxField nameField = new PdfTextBoxField(pdfPage, "Name"); + nameField.Bounds = new RectangleF(10, 40, 200, 20); + nameField.ToolTip = "Name"; + pdfDocument.Form.Fields.Add(nameField); + + // Draw the label "Email address" + pdfPage.Graphics.DrawString("Email address", font, PdfBrushes.Black, new PointF(10, 80)); + + // Create a textbox field for the email address + PdfTextBoxField emailField = new PdfTextBoxField(pdfPage, "Email address"); + emailField.Bounds = new RectangleF(10, 100, 200, 20); + emailField.ToolTip = "Email address"; + pdfDocument.Form.Fields.Add(emailField); + + // Save the PDF document to a file stream + using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create)) + { + pdfDocument.Save(outputFileStream); + } + } + ``` + +For a full working example, you can download the sample from the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Forms/Add-a-textbox-field-to-a-new-PDF-document). + +To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/HTML to PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/README.md b/HTML to PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/README.md new file mode 100644 index 00000000..c5cd2b4e --- /dev/null +++ b/HTML to PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document/README.md @@ -0,0 +1,40 @@ +# HTML to PDF Conversion + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) allows you to create, read, and edit PDF documents. It also includes functionality for accurately converting HTML content into PDF files. + +## Steps to convert HTML to PDF + +Follow these steps to convert HTML content into a PDF file using the Syncfusion library: + +1. **Create a new project**: Initialize a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.HtmlToPdfConverter.Net.Windows](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows) package as a reference in your .NET Standard application from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add the following namespaces in your `Program.cs` file: + + ```csharp + using Syncfusion.HtmlConverter; + using Syncfusion.Pdf; + using System.Runtime.InteropServices; + ``` + +4. **Convert HTML to PDF**: Implement the following code in `Program.cs` to convert a website URL to a PDF file: + + ```csharp + // Initialize the HTML to PDF converter + HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + + // Convert a URL to a PDF document + PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); + + // Create the FileStream to save the PDF document + FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); + + // Save and close the PDF document + document.Save(fileStream); + document.Close(true); + ``` + +You can download a complete working sample from the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Convert-website-URL-to-PDF-document). + +To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Images/Convert_Image_to_PDF/.NET/Convert_Image_to_PDF/README.md b/Images/Convert_Image_to_PDF/.NET/Convert_Image_to_PDF/README.md new file mode 100644 index 00000000..ed962cf4 --- /dev/null +++ b/Images/Convert_Image_to_PDF/.NET/Convert_Image_to_PDF/README.md @@ -0,0 +1,51 @@ +# Converting Images to PDF + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) offers tools to create, read, and edit PDF documents. It also provides functionality to convert images into PDF files, making it easy to integrate image content into your PDF documents. + +## Steps to convert images to PDF + +Follow these steps to convert an image into a PDF file using the Syncfusion library: + +1. **Create a new project**: Start a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Imaging.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Imaging.Net.Core) package as a reference to your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add the following namespace in your `Program.cs` file: + + ```csharp + using Syncfusion.Pdf; + ``` + +4. **Convert image to PDF**: Implement the following code in `Program.cs` to convert an image into a PDF file: + + ```csharp + // Create an instance of the ImageToPdfConverter class + var imageToPdfConverter = new ImageToPdfConverter(); + + // Set the page size for the PDF + imageToPdfConverter.PageSize = PdfPageSize.A4; + + // Set the position of the image in the PDF + imageToPdfConverter.ImagePosition = PdfImagePosition.TopLeftCornerOfPage; + + // Create a file stream to read the image file + using (var imageStream = new FileStream("Autumn Leaves.jpg", FileMode.Open, FileAccess.Read)) + { + // Convert the image to a PDF document using the ImageToPdfConverter + var pdfDocument = imageToPdfConverter.Convert(imageStream); + + // Create a file stream for the output PDF file + using (var outputFileStream = new FileStream(Path.GetFullPath("Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + // Save the generated PDF document to the output file stream + pdfDocument.Save(outputFileStream); + } + + // Close the document + pdfDocument.Close(true); + } + ``` + +You can download a complete working sample from the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Images/Convert_Image_to_PDF/.NET). + +To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/README.md b/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/README.md new file mode 100644 index 00000000..a528102b --- /dev/null +++ b/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/README.md @@ -0,0 +1,46 @@ +# Merging PDF Files + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) allows you to easily create, read, edit, and merge PDF documents. This library provides a straightforward way to combine multiple PDF files into a single document. + +## Steps to merge PDF files + +Follow these steps to merge PDF files using the Syncfusion library: + +1. **Create a new project**: Start by creating a new C# Console Application project. + +2. **Install the NuGet package**: Reference the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package in your project from [NuGet.org](https://www.nuget.org/). + +3. **Include required namespaces**: Add the following namespace in your `Program.cs` file: + + ```csharp + using Syncfusion.Pdf; + ``` + +4. **Merge PDF files**: Use the following code snippet in `Program.cs` to merge PDF files: + + ```csharp + // Create a PDF document for the final merged output + using (PdfDocument finalDocument = new PdfDocument()) + { + // Open streams for existing PDF documents + using (FileStream firstFileStream = new FileStream("File1.pdf", FileMode.Open, FileAccess.Read)) + using (FileStream secondFileStream = new FileStream("File2.pdf", FileMode.Open, FileAccess.Read)) + { + // Create an array of streams to merge + Stream[] streams = { firstFileStream, secondFileStream }; + + // Merge PDF documents into the final document + PdfDocumentBase.Merge(finalDocument, streams); + + // Save the merged document to a file stream + using (FileStream outputFileStream = new FileStream("MergedDocument.pdf", FileMode.Create, FileAccess.Write)) + { + finalDocument.Save(outputFileStream); + } + } + } + ``` + +You can download a complete working sample from the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Merge%20PDFs/Merge-multiple-documents-from-stream/). + +To explore additional features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/OCR/.NET/Perform-OCR-for-the-entire-PDF-document/Perform-OCR-for-the-entire-PDF-document/README.md b/OCR/.NET/Perform-OCR-for-the-entire-PDF-document/Perform-OCR-for-the-entire-PDF-document/README.md new file mode 100644 index 00000000..47dfe316 --- /dev/null +++ b/OCR/.NET/Perform-OCR-for-the-entire-PDF-document/Perform-OCR-for-the-entire-PDF-document/README.md @@ -0,0 +1,51 @@ +# OCR on PDF Files + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) enables you to create, read, and edit PDF documents effortlessly. Additionally, the library provides OCR (Optical Character Recognition) capabilities, allowing you to extract text from scanned images within PDF files. + +## Steps to perform OCR on PDF files + +Follow these steps to apply OCR to PDF files using the Syncfusion library: + +1. **Create a new project**: Set up a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.PDF.OCR.Net.Core](https://www.nuget.org/packages/Syncfusion.PDF.OCR.Net.Core) package as a reference in your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add the following namespaces in your `Program.cs` file: + + ```csharp + using Syncfusion.OCRProcessor; + using Syncfusion.Pdf.Parsing; + ``` + +4. **Implement OCR Processing**: Use the following code snippet in `Program.cs` to perform OCR on a PDF document: + + ```csharp + // Initialize the OCR processor + using (OCRProcessor processor = new OCRProcessor()) + { + // Load the existing PDF document + using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) + { + PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(stream); + + // Set the language for OCR processing + processor.Settings.Language = Languages.English; + + // Perform OCR on the PDF document + processor.PerformOCR(pdfLoadedDocument); + + // Save the OCR-processed document + using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) + { + pdfLoadedDocument.Save(outputFileStream); + } + + // Close the document + pdfLoadedDocument.Close(true); + } + } + ``` + +For a complete working sample, you can download the example from the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/OCR/.NET/Perform-OCR-for-the-entire-PDF-document). + +To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/PDF Conformance/Convert-PDF-to-PDFA-conformance-document/.NET/Convert-PDF-to-PDFA-conformance-document/README.md b/PDF Conformance/Convert-PDF-to-PDFA-conformance-document/.NET/Convert-PDF-to-PDFA-conformance-document/README.md new file mode 100644 index 00000000..6e494167 --- /dev/null +++ b/PDF Conformance/Convert-PDF-to-PDFA-conformance-document/.NET/Convert-PDF-to-PDFA-conformance-document/README.md @@ -0,0 +1,46 @@ +# Convert PDF to PDF/A + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) provides tools for creating, reading, and editing PDF documents. Among its features, the library enables conversion of standard PDF files into the PDF/A format, suitable for long-term archiving and meeting archival standards. + +## Steps to convert a PDF to PDF/A + +Follow these steps to convert a PDF document to PDF/A format using the Syncfusion library: + +1. **Create a new project**: Start by creating a new C# Console Application project. + +2. **Install the NuGet package**: Reference the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package in your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add the following namespaces in your `Program.cs` file: + + ```csharp + using Syncfusion.Pdf; + using Syncfusion.Pdf.Parsing; + ``` + +4. **Convert PDF to PDF/A**: Implement the following code in `Program.cs` to perform the conversion: + + ```csharp + // Load an existing PDF document + using (FileStream inputPdfStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) + { + // Initialize PdfLoadedDocument with the input file stream + PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPdfStream); + + // Convert the loaded document to PDF/A format with the specified conformance level + loadedDocument.ConvertToPDFA(PdfConformanceLevel.Pdf_A1B); + + // Save the converted PDF/A document to a new file + using (FileStream outputPdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.Write)) + { + // Save the modified PDF document to the output file stream + loadedDocument.Save(outputPdfStream); + } + + // Close the loaded document to release resources + loadedDocument.Close(true); + } + ``` + +You can download a complete working sample from the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/PDF%20Conformance/Get-PDF-to-PDFA-conversion-progress/.NET). + +To explore additional features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/PDF Conformance/Get-PDF-to-PDFA-conversion-progress/.NET/Get-PDF-to-PDFA-conversion-progress/Program.cs b/PDF Conformance/Get-PDF-to-PDFA-conversion-progress/.NET/Get-PDF-to-PDFA-conversion-progress/Program.cs index a308f6f2..87c4b894 100644 --- a/PDF Conformance/Get-PDF-to-PDFA-conversion-progress/.NET/Get-PDF-to-PDFA-conversion-progress/Program.cs +++ b/PDF Conformance/Get-PDF-to-PDFA-conversion-progress/.NET/Get-PDF-to-PDFA-conversion-progress/Program.cs @@ -3,22 +3,27 @@ using Syncfusion.Pdf; using Syncfusion.Pdf.Parsing; -// Load an existing PDF document -using (FileStream inputPdfStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read)) +//Get stream from an existing PDF document. +FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); + +//Load an existing PDF document. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); + +//Subscribe to the PdfAConversionProgress event to track the PDF to PDF/A conversion process +loadedDocument.PdfAConversionProgress += new PdfLoadedDocument.PdfAConversionProgressEventHandler(pdfAConversion_TrackProgress); + +loadedDocument.ConvertToPDFA(PdfConformanceLevel.Pdf_A1B); + +//Save the document +FileStream outputStream = new FileStream(Path.GetFullPath(@"Output.pdf"), FileMode.Create, FileAccess.Write); +loadedDocument.Save(outputStream); + +//Close the document +loadedDocument.Close(true); + + +//Event handler for Track PDF to PDF/A conversion process +void pdfAConversion_TrackProgress(object sender, PdfAConversionProgressEventArgs arguments) { - // Initialize PdfLoadedDocument with the input file stream - PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPdfStream); - - // Convert the loaded document to PDF/A format with specified conformance level - loadedDocument.ConvertToPDFA(PdfConformanceLevel.Pdf_A1B); - - // Save the converted PDF/A document to a new file - using (FileStream outputPdfStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.Write)) - { - // Save the modified PDF document to the output file stream - loadedDocument.Save(outputPdfStream); - } - - // Close the loaded document to release resources - loadedDocument.Close(true); + Console.WriteLine(String.Format("PDF to PDF/A conversion process " + arguments.ProgressValue + "% completed")); } \ No newline at end of file diff --git a/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/README.md b/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/README.md new file mode 100644 index 00000000..c9a1f2aa --- /dev/null +++ b/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/README.md @@ -0,0 +1,50 @@ +# Split PDF Files + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) allows for creating, reading, and editing PDF documents, as well as splitting them into separate files. + +## Steps to split PDF files + +1. **Create a new project**: Begin by setting up a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: In your **Program.cs** file, include the following namespaces: + + ```csharp + using Syncfusion.Pdf.Parsing; + using Syncfusion.Pdf; +``` + +4. **Split the PDF file:** Implement the following code in **Program.cs** to split the PDF file: + +```csharp +// Create a FileStream object to read the input PDF file +using (FileStream inputFileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) +{ + // Load the PDF document from the input stream + using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream)) + { + // Iterate over each page of the loaded document + for (int pageIndex = 0; pageIndex < loadedDocument.PageCount; pageIndex++) + { + // Create a new PdfDocument for the output + using (PdfDocument outputDocument = new PdfDocument()) + { + // Import the page into the new document + outputDocument.ImportPage(loadedDocument, pageIndex); + + // Create a FileStream to write the output PDF file + using (FileStream outputFileStream = new FileStream($"Output{pageIndex}.pdf", FileMode.Create, FileAccess.Write)) + { + // Save the new document to the output stream + outputDocument.Save(outputFileStream); + } + } + } + } +} +``` + +You can download a complete working sample from [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Pages/Splitting-PDF-file-into-individual-pages/). + +To explore additional features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Redaction/Removing-sensitive-content-from-the-PDF-document/.NET/Removing-sensitive-content-from-the-PDF-document/README.md b/Redaction/Removing-sensitive-content-from-the-PDF-document/.NET/Removing-sensitive-content-from-the-PDF-document/README.md new file mode 100644 index 00000000..0303a344 --- /dev/null +++ b/Redaction/Removing-sensitive-content-from-the-PDF-document/.NET/Removing-sensitive-content-from-the-PDF-document/README.md @@ -0,0 +1,52 @@ +# Redacting PDF Files + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) allows users to create, read, and edit PDFs seamlessly. One of its key features is the ability to redact PDF content, enabling the permanent removal or hiding of sensitive information while maintaining the rest of the document's integrity. + +## Steps to Redact PDF Files + +1. **Create a new project**: Start by creating a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project via [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add these namespaces to your **Program.cs** file: + + ```csharp + using Syncfusion.Pdf.Parsing; + using Syncfusion.Pdf.Redaction; + using Syncfusion.Pdf; + using Syncfusion.Drawing; + ``` + +4. **Implement redaction**: Use the following code in **Program.cs** to perform PDF redaction: + + ```csharp + using (FileStream docStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read)) + { + // Load the PDF document from the input stream + using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream)) + { + // Access the first page of the document + PdfLoadedPage firstPage = loadedDocument.Pages[0] as PdfLoadedPage; + + // Define a redaction area + RectangleF redactionRectangle = new RectangleF(340, 120, 140, 20); + PdfRedaction redaction = new PdfRedaction(redactionRectangle); + + // Apply the redaction to the page + firstPage.AddRedaction(redaction); + + // Execute the redaction + loadedDocument.Redact(); + + // Save the redacted document + using (FileStream outputFileStream = new FileStream("Redact.pdf", FileMode.Create, FileAccess.ReadWrite)) + { + loadedDocument.Save(outputFileStream); + } + } + } + ``` + +You can download a complete working example from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Redaction/Removing-sensitive-content-from-the-PDF-document/). + +Discover more features of the Syncfusion PDF library [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Security/Protect-an-existing-PDF-document/.NET/Protect-an-existing-PDF-document/README.md b/Security/Protect-an-existing-PDF-document/.NET/Protect-an-existing-PDF-document/README.md new file mode 100644 index 00000000..63bd6c0c --- /dev/null +++ b/Security/Protect-an-existing-PDF-document/.NET/Protect-an-existing-PDF-document/README.md @@ -0,0 +1,51 @@ +# Protect PDF Files + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) provides tools for creating, reading, and editing PDF documents. It also allows you to protect your PDF files by applying encryption and setting password-based permissions. + +## Steps to Protect PDF Files + +1. **Create a new project**: Begin by setting up a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add these namespaces in your **Program.cs** file: + + ```csharp + using Syncfusion.Pdf.Security; + using Syncfusion.Pdf.Parsing; + ``` + +4. **Implement encryption**: Use the following code in **Program.cs** to secure your PDF file: + + ```csharp + // Load the PDF document from a file stream + using (FileStream inputFileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) + { + // Load the PDF document + PdfLoadedDocument document = new PdfLoadedDocument(inputFileStream); + + // Access the document's security settings + PdfSecurity security = document.Security; + + // Set key size and encryption algorithm + security.KeySize = PdfEncryptionKeySize.Key256Bit; + security.Algorithm = PdfEncryptionAlgorithm.AES; + + // Specify owner and user passwords + security.OwnerPassword = "owner123"; + security.UserPassword = "user123"; + + // Save the protected PDF document to a file stream + using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create)) + { + document.Save(outputFileStream); + } + + // Close the document + document.Close(true); + } + ``` + +You can download a complete working example from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Security/Protect-an-existing-PDF-document/). + +Explore more capabilities of the Syncfusion PDF library [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ 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 new file mode 100644 index 00000000..b7fd778d --- /dev/null +++ b/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/README.md @@ -0,0 +1,55 @@ +# PDF Tables + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) facilitates the creation, reading, and editing of PDF documents. It also provides features to create and customize tables within PDF files, allowing for efficient data organization and presentation. + +## Steps to Add a Table to a PDF Document + +1. **Create a new project**: Start by setting up a new C# Console Application project. + +2. **Install the NuGet package**: Reference the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package in your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add these namespaces to your **Program.cs** file: + + ```csharp + using Syncfusion.Pdf.Grid; + using Syncfusion.Pdf; + using Syncfusion.Drawing; + ``` + +4. **Add a table to the PDF**: Use the following code in **Program.cs** to insert a table into the PDF: + + ```csharp + // Create a new PDF document + using (PdfDocument document = new PdfDocument()) + { + // Add a page + PdfPage page = document.Pages.Add(); + + // Create a PdfGrid + 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 + pdfGrid.DataSource = data; + + // Draw the grid on the PDF page + pdfGrid.Draw(page, new PointF(10, 10)); + + using (FileStream outputStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) + { + // Save the document + document.Save(outputStream); + } + } + ``` + +A complete working example is available on [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET). + +Explore more features of the Syncfusion PDF library [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Tagged PDF/Add-tag-for-the-text-element-in-PDF-document/.NET/Add-tag-for-the-text-element-in-PDF-document/README.md b/Tagged PDF/Add-tag-for-the-text-element-in-PDF-document/.NET/Add-tag-for-the-text-element-in-PDF-document/README.md new file mode 100644 index 00000000..61f02030 --- /dev/null +++ b/Tagged PDF/Add-tag-for-the-text-element-in-PDF-document/.NET/Add-tag-for-the-text-element-in-PDF-document/README.md @@ -0,0 +1,63 @@ +# Accessible PDF Files + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) facilitates the creation, reading, and editing of PDF documents. It also offers features for generating accessible PDFs that adhere to accessibility standards, making content accessible to individuals with disabilities. + +## Steps to Create Accessible PDF Files + +1. **Create a new project**: Start by setting up a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add these namespaces in your **Program.cs** file: + + ```csharp + using Syncfusion.Drawing; + using Syncfusion.Pdf; + using Syncfusion.Pdf.Graphics; + ``` + +4. **Implement accessibility**: Use the following code in **Program.cs** to create an accessible PDF: + + ```csharp + // Create new PDF document + using (PdfDocument document = new PdfDocument()) + { + // Set the document title + document.DocumentInformation.Title = "PdfTextElement"; + + // Create a new page + PdfPage page = document.Pages.Add(); + + // Initialize the structure element with tag type paragraph + PdfStructureElement paragraphStructure = new PdfStructureElement(PdfTagType.Paragraph); + + // Represents the text that is the exact replacement for PdfTextElement + paragraphStructure.ActualText = "Simple paragraph element"; + + string paragraphText = "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European, and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base."; + + // Initialize the PDF text element + PdfTextElement textElement = new PdfTextElement(paragraphText); + + // Assign the tag to the text element + textElement.PdfTag = paragraphStructure; + + // Create font for the text element + textElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); + + textElement.Brush = new PdfSolidBrush(new PdfColor(89, 89, 93)); + + // Draw text element with tag + textElement.Draw(page, new RectangleF(0, 0, page.Graphics.ClientSize.Width, 200)); + + using (FileStream outputFile = new FileStream("TaggedPDF.pdf", FileMode.Create)) + { + // Save the document + document.Save(outputFile); + } + } + ``` + +You can download a complete working example from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Tagged%20PDF/Add-tag-for-the-text-element-in-PDF-document). + +Discover more features of the Syncfusion PDF library [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Text Extraction/Extract-text-from-the-entire-PDF-document/.NET/Extract-text-from-the-entire-PDF-document/README.md b/Text Extraction/Extract-text-from-the-entire-PDF-document/.NET/Extract-text-from-the-entire-PDF-document/README.md new file mode 100644 index 00000000..d983fd40 --- /dev/null +++ b/Text Extraction/Extract-text-from-the-entire-PDF-document/.NET/Extract-text-from-the-entire-PDF-document/README.md @@ -0,0 +1,44 @@ +# Extract Data from PDF + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) enables the creation, reading, and editing of PDF documents. Additionally, it provides capabilities to extract data from PDFs, such as text, images, and form field values. + +## Steps to Extract Data from PDF Files + +1. **Create a new project**: Begin by setting up a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Add these namespaces in your **Program.cs** file: + + ```csharp + using Syncfusion.Pdf; + using Syncfusion.Pdf.Parsing; + using System.IO; + ``` + +4. **Extract data from PDF**: Use the following code in **Program.cs** to extract data from a PDF: + + ```csharp + // Open an existing PDF document stream + using (FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) + { + // Load the PDF document + using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream)) + { + string extractedText = string.Empty; + + // Extract all text from the PDF document pages + foreach (PdfLoadedPage page in loadedDocument.Pages) + { + extractedText += page.ExtractText(); + } + + // Save the extracted text to a file + File.WriteAllText("Result.txt", extractedText); + } + } + ``` + +For a complete working example, download it from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Text%20Extraction/Extract-text-from-the-entire-PDF-document/). + +Explore more features of the Syncfusion PDF library [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file diff --git a/Watermark/Add-text-watermark-in-an-existing-PDF-document/.NET/Add-text-watermark-in-an-existing-PDF-document/README.md b/Watermark/Add-text-watermark-in-an-existing-PDF-document/.NET/Add-text-watermark-in-an-existing-PDF-document/README.md new file mode 100644 index 00000000..4cf49806 --- /dev/null +++ b/Watermark/Add-text-watermark-in-an-existing-PDF-document/.NET/Add-text-watermark-in-an-existing-PDF-document/README.md @@ -0,0 +1,63 @@ +# Edit PDF Files + +The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) provides tools for creating, reading, and editing PDF documents. It also supports modifying existing PDF files, including updating text, images, and other content. + +## Steps to Add a Watermark to a PDF File + +1. **Create a new project**: Begin by setting up a new C# Console Application project. + +2. **Install the NuGet package**: Add the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package to your project from [NuGet.org](https://www.nuget.org/). + +3. **Include necessary namespaces**: Include the following namespaces in your **Program.cs** file: + + ```csharp + using Syncfusion.Pdf.Graphics; + using Syncfusion.Pdf.Parsing; + using Syncfusion.Pdf; + using Syncfusion.Drawing; + ``` + +4. **Add a watermark to the PDF**: Use the following code snippet in **Program.cs** to apply a watermark to an existing PDF: + + ```csharp + // Create FileStream object to read the input PDF file + using (FileStream inputFileStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read)) + { + // Load the PDF document from the input stream + using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream)) + { + // Get the first page of the PDF document + PdfPageBase loadedPage = loadedDocument.Pages[0]; + + // Create a PDF font to add a watermark text + PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 32); + + // Measure the watermark text and get the size + string watermarkText = "Created using Syncfusion PDF library"; + SizeF watermarkTextSize = font.MeasureString(watermarkText); + + // Move the graphics to the center of the page + loadedPage.Graphics.Save(); + loadedPage.Graphics.TranslateTransform(loadedPage.Size.Width / 2, loadedPage.Size.Height / 2); + + // Rotate the graphics to 45 degrees + loadedPage.Graphics.RotateTransform(-45); + + // Draw the watermark text + loadedPage.Graphics.DrawString(watermarkText, font, PdfBrushes.Red, new PointF(-watermarkTextSize.Width / 2, -watermarkTextSize.Height / 2)); + + // Restore the graphics + loadedPage.Graphics.Restore(); + + using (FileStream outputStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) + { + // Save the document + loadedDocument.Save(outputStream); + } + } + } + ``` + +You can download a complete working example from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Watermark/Add-text-watermark-in-an-existing-PDF-document/.NET). + +Explore more features of the Syncfusion PDF library [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). \ No newline at end of file