-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
047b1cf
commit f332625
Showing
18 changed files
with
711 additions
and
683 deletions.
There are no files selected for viewing
106 changes: 56 additions & 50 deletions
106
...otation-in-a-PDF-document/.NET/Add-popup-annotation-in-a-PDF-document/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,58 @@ | ||
# PDF Annotations | ||
|
||
The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) is used to create, read, and edit PDF documents. This library also offers functionality to add, edit, and manage annotations in PDF files, enabling users to mark up and collaborate effectively. | ||
|
||
## Steps to add annotation to a PDF | ||
|
||
Step 1: Create a new C# Console Application project. | ||
|
||
Step 2: Install the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). | ||
|
||
Step 3: Include the following namespaces in the **Program.cs** file. | ||
|
||
``` | ||
using Syncfusion.Drawing; | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Graphics; | ||
using Syncfusion.Pdf.Interactive; | ||
using Syncfusion.Pdf.Parsing; | ||
``` | ||
|
||
Step 4: Include the below code snippet in **Program.cs** to add annotations to a PDF file.". | ||
``` | ||
//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 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 document | ||
using (FileStream outpuFileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) | ||
{ | ||
loadedDocument.Save(outpuFileStream); | ||
} | ||
} | ||
} | ||
``` | ||
|
||
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Annotation/Add-a-popup-annotation-to-an-existing-PDF-document/.NET). | ||
|
||
Click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core) to explore the rich set of Syncfusion PDF library features. | ||
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). |
113 changes: 59 additions & 54 deletions
113
...ing-PDF-document/.NET/Compress-the-images-in-an-existing-PDF-document/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,59 @@ | ||
# Compress PDF Files | ||
|
||
The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) enables users to create, read, and edit PDF documents effortlessly. In addition to these features, the library provides functionality for compressing PDF files, reducing their size without compromising quality, to optimize storage and enhance file sharing efficiency. | ||
|
||
## Steps to compress PDF files. | ||
|
||
Step 1: Create a new C# Console Application project. | ||
|
||
Step 2: Install the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). | ||
|
||
Step 3: Include the following namespaces in the **Program.cs** file. | ||
|
||
``` | ||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf; | ||
``` | ||
|
||
Step 4: Include the below code snippet in **Program.cs** to compress PDF files. | ||
``` | ||
// Open a file stream to read the input PDF file. | ||
using (FileStream fileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) | ||
{ | ||
// Create a new PdfLoadedDocument object from the file stream. | ||
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream)) | ||
{ | ||
// Create a new PdfCompressionOptions object. | ||
PdfCompressionOptions options = new PdfCompressionOptions(); | ||
// Enable image compression and set 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 [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Compression/Compress-the-images-in-an-existing-PDF-document). | ||
|
||
Click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core) to explore the rich set of Syncfusion PDF library features. | ||
# 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). |
96 changes: 48 additions & 48 deletions
96
...xisting-document/.NET/Add-a-digital-signature-to-an-existing-document/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
# Digital Signature | ||
|
||
The Syncfusion [.NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core/pdf-library) enables users to create, read, and edit PDF documents effortlessly. In addition to these features, the library provides robust functionality for applying digital signatures to PDF files, ensuring document authenticity, integrity, and security. | ||
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 | ||
## Steps to add a digital signature to PDF files | ||
|
||
Step 1: Create a new C# Console Application project. | ||
Follow these steps to digitally sign PDF files using the Syncfusion library: | ||
|
||
Step 2: Install the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). | ||
1. **Create a new project**: Start by creating a new C# Console Application project. | ||
|
||
Step 3: Include the following namespaces in the **Program.cs** file. | ||
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: | ||
|
||
``` | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Graphics; | ||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf.Security; | ||
using Syncfusion.Drawing; | ||
```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: | ||
|
||
Step 4: Include the below code snippet in **Program.cs** to add a digital signature to PDF files. | ||
``` | ||
//Open existing PDF document as stream | ||
using (FileStream inputStream = new FileStream(Path.GetFullPath("Input.pdf"), FileMode.Open, FileAccess.Read)) | ||
{ | ||
// Load the existing PDF document | ||
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream); | ||
```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); | ||
|
||
// Gets the first page of the document | ||
PdfPageBase page = loadedDocument.Pages[0]; | ||
// 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"); | ||
// 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"); | ||
// 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 = "[email protected]"; | ||
signature.LocationInfo = "Honolulu, Hawaii"; | ||
signature.Reason = "I am the author of this document."; | ||
// Set signature information | ||
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(200, 100)); | ||
signature.ContactInfo = "[email protected]"; | ||
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); | ||
// 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)); | ||
// 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); | ||
} | ||
// 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); | ||
} | ||
// 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/). | ||
|
||
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Digital%20Signature/Add-a-digital-signature-to-an-existing-document/). | ||
|
||
Click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core) to explore the rich set of Syncfusion PDF library features. | ||
To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core). |
Oops, something went wrong.