Skip to content

Commit f332625

Browse files
Reviewed content updated
1 parent 047b1cf commit f332625

File tree

18 files changed

+711
-683
lines changed
  • Annotation/Add-popup-annotation-in-a-PDF-document/.NET/Add-popup-annotation-in-a-PDF-document
  • Compression/Compress-the-images-in-an-existing-PDF-document/.NET/Compress-the-images-in-an-existing-PDF-document
  • Digital Signature/Add-a-digital-signature-to-an-existing-document/.NET/Add-a-digital-signature-to-an-existing-document
  • Forms/Add-a-textbox-field-to-a-new-PDF-document/.NET/Add-a-textbox-field-to-a-new-PDF-document
  • HTML to PDF/Blink/Convert-website-URL-to-PDF-document/.NET/Convert-website-URL-to-PDF-document
  • Images/Convert_Image_to_PDF/.NET/Convert_Image_to_PDF
  • Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream
  • OCR/.NET/Perform-OCR-for-the-entire-PDF-document/Perform-OCR-for-the-entire-PDF-document
  • PDF Conformance
    • Convert-PDF-to-PDFA-conformance-document/.NET/Convert-PDF-to-PDFA-conformance-document
    • Get-PDF-to-PDFA-conversion-progress/.NET/Get-PDF-to-PDFA-conversion-progress
  • Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages
  • Redaction/Removing-sensitive-content-from-the-PDF-document/.NET/Removing-sensitive-content-from-the-PDF-document
  • Security/Protect-an-existing-PDF-document/.NET/Protect-an-existing-PDF-document
  • Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF
  • Tagged PDF/Add-tag-for-the-text-element-in-PDF-document/.NET/Add-tag-for-the-text-element-in-PDF-document
  • Text Extraction/Extract-text-from-the-entire-PDF-document/.NET/Extract-text-from-the-entire-PDF-document
  • Watermark/Add-text-watermark-in-an-existing-PDF-document/.NET/Add-text-watermark-in-an-existing-PDF-document

18 files changed

+711
-683
lines changed
Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
11
# PDF Annotations
22

3-
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.
4-
5-
## Steps to add annotation to a PDF
6-
7-
Step 1: Create a new C# Console Application project.
8-
9-
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/).
10-
11-
Step 3: Include the following namespaces in the **Program.cs** file.
12-
13-
```
14-
using Syncfusion.Drawing;
15-
using Syncfusion.Pdf;
16-
using Syncfusion.Pdf.Graphics;
17-
using Syncfusion.Pdf.Interactive;
18-
using Syncfusion.Pdf.Parsing;
19-
20-
```
21-
22-
Step 4: Include the below code snippet in **Program.cs** to add annotations to a PDF file.".
23-
```
24-
//Create FileStream object to read the input PDF file
25-
using (FileStream inputFileStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read))
26-
{
27-
//Load the PDF document from the input stream
28-
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream))
29-
{
30-
//Get the first page of the PDF document
31-
PdfPageBase loadedPage = loadedDocument.Pages[0];
32-
//Create a new popup annotation
33-
PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation(new RectangleF(100, 100, 20, 20), "Comment");
34-
//Set the icon for the popup annotation
35-
popupAnnotation.Icon = PdfPopupIcon.Comment;
36-
//Set the color for the popup annotation
37-
popupAnnotation.Color = new PdfColor(Color.Yellow);
38-
//Add the annotation to the page
39-
loadedPage.Annotations.Add(popupAnnotation);
40-
//Save the document
41-
using (FileStream outpuFileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write))
42-
{
43-
loadedDocument.Save(outpuFileStream);
44-
}
45-
}
46-
}
47-
48-
```
49-
50-
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).
51-
52-
Click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core) to explore the rich set of Syncfusion PDF library features.
3+
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.
4+
5+
## Steps to add annotations to a PDF
6+
7+
Follow these steps to add a popup annotation to a PDF file using the Syncfusion library:
8+
9+
1. **Create a new project**: Set up a new C# Console Application project.
10+
11+
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/).
12+
13+
3. **Include necessary namespaces**: Add the following namespaces to your `Program.cs` file:
14+
15+
```csharp
16+
using Syncfusion.Drawing;
17+
using Syncfusion.Pdf;
18+
using Syncfusion.Pdf.Graphics;
19+
using Syncfusion.Pdf.Interactive;
20+
using Syncfusion.Pdf.Parsing;
21+
```
22+
23+
4. **Code to add annotations**: Use the following code snippet in `Program.cs` to insert annotations into a PDF file:
24+
25+
```csharp
26+
// Create a FileStream object to read the input PDF file
27+
using (FileStream inputFileStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read))
28+
{
29+
// Load the PDF document from the input stream
30+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream))
31+
{
32+
// Access the first page of the PDF document
33+
PdfPageBase loadedPage = loadedDocument.Pages[0];
34+
35+
// Create a new popup annotation
36+
PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation(new RectangleF(100, 100, 20, 20), "Comment");
37+
38+
// Set the icon for the popup annotation
39+
popupAnnotation.Icon = PdfPopupIcon.Comment;
40+
41+
// Set the color for the popup annotation
42+
popupAnnotation.Color = new PdfColor(Color.Yellow);
43+
44+
// Add the annotation to the page
45+
loadedPage.Annotations.Add(popupAnnotation);
46+
47+
// Save the updated document
48+
using (FileStream outputFileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write))
49+
{
50+
loadedDocument.Save(outputFileStream);
51+
}
52+
}
53+
}
54+
```
55+
56+
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).
57+
58+
To learn more about the extensive features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core).
Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,59 @@
1-
# Compress PDF Files
2-
3-
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.
4-
5-
## Steps to compress PDF files.
6-
7-
Step 1: Create a new C# Console Application project.
8-
9-
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/).
10-
11-
Step 3: Include the following namespaces in the **Program.cs** file.
12-
13-
```
14-
using Syncfusion.Pdf.Parsing;
15-
using Syncfusion.Pdf;
16-
17-
```
18-
19-
Step 4: Include the below code snippet in **Program.cs** to compress PDF files.
20-
```
21-
// Open a file stream to read the input PDF file.
22-
using (FileStream fileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
23-
{
24-
// Create a new PdfLoadedDocument object from the file stream.
25-
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
26-
{
27-
// Create a new PdfCompressionOptions object.
28-
PdfCompressionOptions options = new PdfCompressionOptions();
29-
// Enable image compression and set image quality.
30-
options.CompressImages = true;
31-
options.ImageQuality = 50;
32-
// Enable font optimization.
33-
options.OptimizeFont = true;
34-
35-
// Enable page content optimization.
36-
options.OptimizePageContents = true;
37-
// Remove metadata from the PDF.
38-
options.RemoveMetadata = true;
39-
// Compress the PDF document.
40-
loadedDocument.Compress(options);
41-
42-
// Save the document into a memory stream.
43-
using (MemoryStream outputStream = new MemoryStream())
44-
{
45-
loadedDocument.Save(outputStream);
46-
}
47-
}
48-
}
49-
50-
```
51-
52-
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).
53-
54-
Click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core) to explore the rich set of Syncfusion PDF library features.
1+
# Compressing PDF Files
2+
3+
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.
4+
5+
## Steps to compress PDF files
6+
7+
Follow these steps to compress PDF files using the Syncfusion library:
8+
9+
1. **Create a new project**: Set up a new C# Console Application project.
10+
11+
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/).
12+
13+
3. **Add required namespaces**: Include the following namespaces in your `Program.cs` file:
14+
15+
```csharp
16+
using Syncfusion.Pdf.Parsing;
17+
using Syncfusion.Pdf;
18+
```
19+
20+
4. **Implement PDF compression**: Use the following code snippet in `Program.cs` to compress PDF files:
21+
22+
```csharp
23+
// Open a file stream to read the input PDF file
24+
using (FileStream fileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
25+
{
26+
// Load the PDF document from the file stream
27+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
28+
{
29+
// Create a new PdfCompressionOptions object
30+
PdfCompressionOptions options = new PdfCompressionOptions();
31+
32+
// Enable image compression and set the image quality
33+
options.CompressImages = true;
34+
options.ImageQuality = 50;
35+
36+
// Enable font optimization
37+
options.OptimizeFont = true;
38+
39+
// Enable page content optimization
40+
options.OptimizePageContents = true;
41+
42+
// Remove metadata from the PDF
43+
options.RemoveMetadata = true;
44+
45+
// Compress the PDF document
46+
loadedDocument.Compress(options);
47+
48+
// Save the document into a memory stream
49+
using (MemoryStream outputStream = new MemoryStream())
50+
{
51+
loadedDocument.Save(outputStream);
52+
}
53+
}
54+
}
55+
```
56+
57+
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).
58+
59+
To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core).
Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
# Digital Signature
22

3-
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.
3+
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.
44

5-
## Steps to Add a Digital Signature to PDF Files
5+
## Steps to add a digital signature to PDF files
66

7-
Step 1: Create a new C# Console Application project.
7+
Follow these steps to digitally sign PDF files using the Syncfusion library:
88

9-
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/).
9+
1. **Create a new project**: Start by creating a new C# Console Application project.
1010

11-
Step 3: Include the following namespaces in the **Program.cs** file.
11+
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/).
1212

13+
3. **Include necessary namespaces**: Add the following namespaces in your `Program.cs` file:
1314

14-
```
15-
using Syncfusion.Pdf;
16-
using Syncfusion.Pdf.Graphics;
17-
using Syncfusion.Pdf.Parsing;
18-
using Syncfusion.Pdf.Security;
19-
using Syncfusion.Drawing;
15+
```csharp
16+
using Syncfusion.Pdf;
17+
using Syncfusion.Pdf.Graphics;
18+
using Syncfusion.Pdf.Parsing;
19+
using Syncfusion.Pdf.Security;
20+
using Syncfusion.Drawing;
21+
```
2022

21-
```
23+
4. **Add digital signature code**: Use the following code snippet in `Program.cs` to add a digital signature to a PDF file:
2224

23-
Step 4: Include the below code snippet in **Program.cs** to add a digital signature to PDF files.
24-
```
25-
//Open existing PDF document as stream
26-
using (FileStream inputStream = new FileStream(Path.GetFullPath("Input.pdf"), FileMode.Open, FileAccess.Read))
27-
{
28-
// Load the existing PDF document
29-
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream);
25+
```csharp
26+
// Open the existing PDF document as a stream
27+
using (FileStream inputStream = new FileStream(Path.GetFullPath("Input.pdf"), FileMode.Open, FileAccess.Read))
28+
{
29+
// Load the existing PDF document
30+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream);
3031

31-
// Gets the first page of the document
32-
PdfPageBase page = loadedDocument.Pages[0];
32+
// Get the first page of the document
33+
PdfPageBase page = loadedDocument.Pages[0];
3334

34-
// Load the certificate from a PFX file with a private key
35-
FileStream certificateStream = new FileStream(@"PDF.pfx", FileMode.Open, FileAccess.Read);
36-
PdfCertificate pdfCert = new PdfCertificate(certificateStream, "password123");
35+
// Load the certificate from a PFX file with a private key
36+
FileStream certificateStream = new FileStream(@"PDF.pfx", FileMode.Open, FileAccess.Read);
37+
PdfCertificate pdfCert = new PdfCertificate(certificateStream, "password123");
3738

38-
// Create a signature
39-
PdfSignature signature = new PdfSignature(loadedDocument, page, pdfCert, "Signature");
39+
// Create a signature
40+
PdfSignature signature = new PdfSignature(loadedDocument, page, pdfCert, "Signature");
4041

41-
// Set signature information
42-
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(200, 100));
43-
signature.ContactInfo = "[email protected]";
44-
signature.LocationInfo = "Honolulu, Hawaii";
45-
signature.Reason = "I am the author of this document.";
42+
// Set signature information
43+
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(200, 100));
44+
signature.ContactInfo = "[email protected]";
45+
signature.LocationInfo = "Honolulu, Hawaii";
46+
signature.Reason = "I am the author of this document.";
4647

47-
// Load the image for the signature field
48-
FileStream imageStream = new FileStream("signature.png", FileMode.Open, FileAccess.Read);
49-
PdfBitmap signatureImage = new PdfBitmap(imageStream);
48+
// Load the image for the signature field
49+
FileStream imageStream = new FileStream("signature.png", FileMode.Open, FileAccess.Read);
50+
PdfBitmap signatureImage = new PdfBitmap(imageStream);
5051

51-
// Draw the image on the signature field
52-
signature.Appearance.Normal.Graphics.DrawImage(signatureImage, new RectangleF(0, 0, signature.Bounds.Width, signature.Bounds.Height));
52+
// Draw the image on the signature field
53+
signature.Appearance.Normal.Graphics.DrawImage(signatureImage, new RectangleF(0, 0, signature.Bounds.Width, signature.Bounds.Height));
5354

54-
// Save the document to a file stream
55-
using (FileStream outputFileStream = new FileStream("signed.pdf", FileMode.Create, FileAccess.ReadWrite))
56-
{
57-
loadedDocument.Save(outputFileStream);
58-
}
55+
// Save the document to a file stream
56+
using (FileStream outputFileStream = new FileStream("signed.pdf", FileMode.Create, FileAccess.ReadWrite))
57+
{
58+
loadedDocument.Save(outputFileStream);
59+
}
5960

60-
//Close the document.
61-
loadedDocument.Close(true);
62-
}
61+
// Close the document
62+
loadedDocument.Close(true);
63+
}
64+
```
6365

64-
```
66+
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/).
6567

66-
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/).
67-
68-
Click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core) to explore the rich set of Syncfusion PDF library features.
68+
To explore more features of the Syncfusion PDF library, click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core).

0 commit comments

Comments
 (0)