From 5960d5b944280939db4a632f67cb258f3f43bbe5 Mon Sep 17 00:00:00 2001 From: jeyalakshmit Date: Tue, 19 May 2026 16:26:25 +0530 Subject: [PATCH 01/14] 10278790-Address this UG issues --- .../PDF-Library/NET/Assemblies-Required.md | 58 +++++++++++---- .../NET/NuGet-Packages-Required.md | 72 +++++++++---------- ...pen-and-Save-PDF-file-in-C-Sharp-VB-NET.md | 4 +- .../PDF/PDF-Library/NET/Overview.md | 4 +- 4 files changed, 86 insertions(+), 52 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Assemblies-Required.md b/Document-Processing/PDF/PDF-Library/NET/Assemblies-Required.md index e73b1ac640..38e757a6bc 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Assemblies-Required.md +++ b/Document-Processing/PDF/PDF-Library/NET/Assemblies-Required.md @@ -44,15 +44,6 @@ The following assemblies need to be referenced in your application based on the Syncfusion.Pdf.UWP - - - {{'[Xamarin](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/create-pdf-file-in-xamarin)'| markdownify }} - - - Syncfusion.Pdf.Portable
- Syncfusion.Compression.Portable - - {{'[Blazor](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/create-pdf-document-in-blazor)'| markdownify }}, @@ -140,6 +131,15 @@ The following assemblies need to be referenced in your application based on the Syncfusion.Compression.Base + + + {{'[Xamarin](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/create-pdf-file-in-xamarin)'| markdownify }} + + + Syncfusion.Pdf.Portable
+ Syncfusion.Compression.Portable + + @@ -254,7 +254,7 @@ For converting a Word document to PDF, the following assemblies need to be refer - ASP.NET Core, Xamarin and Blazor + ASP.NET Core and Blazor Syncfusion.DocIO.Portable
Syncfusion.Compression.Portable
@@ -305,6 +305,18 @@ For converting a Word document to PDF, the following assemblies need to be refer Syncfusion.DocToPdfConverter.Base + + Xamarin + + Syncfusion.DocIO.Portable
+ Syncfusion.Compression.Portable
+ Syncfusion.OfficeChart.Portable
+ Syncfusion.Pdf.Portable
+ Syncfusion.DocIORenderer.Portable
+ SkiaSharp.HarfBuzz
+ Syncfusion.SkiaSharpHelper.Portable + + @@ -344,7 +356,7 @@ For converting an Excel document to PDF, the following assemblies need to be ref - UWP, .NET Core, Xamarin, and Blazor (Server-Side) + UWP, .NET Core, and Blazor (Server-Side) Syncfusion.Compression.Portable
Syncfusion.XlsIO.Portable
@@ -387,6 +399,16 @@ For converting an Excel document to PDF, the following assemblies need to be ref Syncfusion.ExcelToPDFConverter.Base + + Xamarin + + Syncfusion.Compression.Portable
+ Syncfusion.XlsIO.Portable
+ Syncfusion.Pdf.Portable
+ Syncfusion.SkiaSharpHelper.Portable
+ Syncfusion.XlsIORenderer.Portable + + @@ -413,7 +435,7 @@ For converting a PowerPoint Presentation to PDF, the following assemblies needed - ASP.NET Core, Xamarin, and Blazor + ASP.NET Core, and Blazor Syncfusion.Presentation.Portable
Syncfusion.Compression.Portable
@@ -480,6 +502,18 @@ The following assemblies are required to be referred in addition to the above me Syncfusion.PresentationToPDFConverter.Base + + Xamarin + + Syncfusion.Presentation.Portable
+ Syncfusion.Compression.Portable
+ Syncfusion.OfficeChart.Portable
+ Syncfusion.Pdf.Portable
+ Syncfusion.PresentationRenderer.Portable
+ Syncfusion.SkiaSharpHelper.Portable
+ SkiaSharp + + diff --git a/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md b/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md index 893b11ba72..eaa1af8554 100644 --- a/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md +++ b/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md @@ -63,14 +63,6 @@ Blazor -Xamarin - - -{{'[Syncfusion.Xamarin.Pdf.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.Pdf/)'| markdownify }} - - - - Windows UI (WinUI)
.NET Multi-platform App UI (.NET MAUI) @@ -98,6 +90,14 @@ Windows UI (WinUI)
{{'[Syncfusion.Pdf.AspNet.nupkg]( https://www.nuget.org/packages/Syncfusion.Pdf.AspNet/)'| markdownify }} + + + Xamarin + + + {{'[Syncfusion.Xamarin.Pdf.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.Pdf/)'| markdownify }} + + @@ -199,7 +199,7 @@ N> The HTML to PDF converter library internally uses the Blink rendering engine -(.NET Core, .NET 5, .NET 6 and .NET 8) Windows +Windows (.NET Core, NET 8.0, NET 9.0 and NET 10.0) {{'[Syncfusion.HtmlToPdfConverter.Net.Windows.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows/)'| markdownify }} @@ -207,7 +207,7 @@ N> The HTML to PDF converter library internally uses the Blink rendering engine -(.NET Core, .NET 5, .NET 6 and .NET 8) Linux +Linux (.NET Core, NET 8.0, NET 9.0, NET 10.0) {{'[Syncfusion.HtmlToPdfConverter.Net.Linux.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Linux/)'| markdownify }} @@ -215,7 +215,7 @@ N> The HTML to PDF converter library internally uses the Blink rendering engine -(.NET Core, .NET 5, .NET 6 and .NET 8) Mac +Mac (.NET Core, NET 8.0, NET 9.0, NET 10.0) {{'[Syncfusion.HtmlToPdfConverter.Net.Mac.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Mac/)'| markdownify }} @@ -223,7 +223,7 @@ N> The HTML to PDF converter library internally uses the Blink rendering engine -(.NET Core, .NET 5, .NET 6 and .NET 8) Aws +Aws (.NET Core, NET 8.0, NET 9.0, NET 10.0) {{'[Syncfusion.HtmlToPdfConverter.Net.Aws.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Aws/)'| markdownify }} @@ -404,14 +404,6 @@ Blazor {{'[Syncfusion.DocIORenderer.Net.Core.nupkg](https://www.nuget.org/packages/Syncfusion.DocIORenderer.Net.Core/)'| markdownify }} - - -Xamarin - - -{{'[Syncfusion.Xamarin.DocIORenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.DocIORenderer/)'| markdownify }} - - ### RETIRED PRODUCTS @@ -432,6 +424,14 @@ Xamarin {{'[Syncfusion.DocToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.DocToPDFConverter.AspNet/)'| markdownify }} + + + Xamarin + + + {{'[Syncfusion.Xamarin.DocIORenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.DocIORenderer/)'| markdownify }} + + @@ -483,14 +483,6 @@ Console Application (Targeting .NET Core) -Xamarin - - -{{'[Syncfusion.Xamarin.XlsIORenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.XlsIORenderer/)'| markdownify }} - - - - Blazor (Server-App) @@ -517,6 +509,14 @@ Blazor (Server-App) {{'[Syncfusion.ExcelToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.ExcelToPdfConverter.AspNet/)'| markdownify }} + + + Xamarin + + + {{'[Syncfusion.Xamarin.XlsIORenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.XlsIORenderer/)'| markdownify }} + + @@ -566,14 +566,6 @@ Blazor {{'[Syncfusion.PresentationRenderer.Net.Core.nupkg](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.Net.Core/)'| markdownify }} - - -Xamarin - - -{{'[Syncfusion.Xamarin.PresentationRenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.PresentationRenderer/)'| markdownify }} - - ### RETIRED PRODUCTS @@ -594,6 +586,14 @@ Xamarin {{'[Syncfusion.PresentationToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.PresentationToPdfConverter.AspNet/)'| markdownify }} + + + Xamarin + + + {{'[Syncfusion.Xamarin.PresentationRenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.PresentationRenderer/)'| markdownify }} + + diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md b/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md index 4a6e11cae0..489c463dc6 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md @@ -392,13 +392,13 @@ You can also resave the manipulated PDF document to the same file using overload {% tabs %} -{% highlight c# tabtitle="ASP.NET Core" %} +{% highlight c# tabtitle="C# [Cross-platform]" %} //PDF doesn't supports saving a PDF document into the same file on the C#/.NET Cross platforms. {% endhighlight %} -{% highlight c# tabtitle="C#" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} //Load an existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); diff --git a/Document-Processing/PDF/PDF-Library/NET/Overview.md b/Document-Processing/PDF/PDF-Library/NET/Overview.md index 55d5c7bf6b..1c8236106b 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Overview.md +++ b/Document-Processing/PDF/PDF-Library/NET/Overview.md @@ -8,7 +8,7 @@ documentation: UG # Overview of PDF Framework -The PDF framework is a feature rich [.NET PDF class library](https://www.syncfusion.com/document-sdk/net-pdf-library) developed with 100% managed C# code that can be used to create, read and write PDF. The library can be used in [Windows Forms](https://www.syncfusion.com/document-sdk/net-pdf-library), [WPF](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET Web Forms](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET MVC](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET Core](https://www.syncfusion.com/document-sdk/net-pdf-library), [Blazor](https://www.syncfusion.com/document-sdk/net-pdf-library), [UWP](https://www.syncfusion.com/document-sdk/net-pdf-library), [Xamarin](https://www.syncfusion.com/document-sdk/net-pdf-library), [Flutter](https://www.syncfusion.com/document-sdk/flutter-pdf-library), [WinUI](https://www.syncfusion.com/document-sdk/net-pdf-library) and [.NET MAUI](https://www.syncfusion.com/document-sdk/net-pdf-library) applications and Unity platform without the dependency of Adobe Acrobat. The creation of PDF follows the most popular PDF 1.7 (ISO 32000-1) and latest PDF 2.0 (ISO 32000-2) specifications. +The PDF framework is a feature rich [.NET PDF class library](https://www.syncfusion.com/document-sdk/net-pdf-library) developed with 100% managed C# code that can be used to create, read and write PDF. The library can be used in [Windows Forms](https://www.syncfusion.com/document-sdk/net-pdf-library), [WPF](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET Web Forms](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET MVC](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET Core](https://www.syncfusion.com/document-sdk/net-pdf-library), [Blazor](https://www.syncfusion.com/document-sdk/net-pdf-library), [UWP](https://www.syncfusion.com/document-sdk/net-pdf-library), [Flutter](https://www.syncfusion.com/document-sdk/flutter-pdf-library), [WinUI](https://www.syncfusion.com/document-sdk/net-pdf-library) and [.NET MAUI](https://www.syncfusion.com/document-sdk/net-pdf-library) applications and Unity platform without the dependency of Adobe Acrobat. The creation of PDF follows the most popular PDF 1.7 (ISO 32000-1) and latest PDF 2.0 (ISO 32000-2) specifications. ## Key Features of Essential® PDF @@ -35,7 +35,7 @@ The following list shows the key features available in the Essential® Date: Tue, 19 May 2026 17:48:01 +0530 Subject: [PATCH 02/14] 1027879-alignment issue --- ...pen-and-Save-PDF-file-in-C-Sharp-VB-NET.md | 25 +-- .../NET/Open-pdf-files/From-AWS-S3.md | 42 ++-- .../Open-pdf-files/From-azure-blob-storage.md | 32 +-- .../From-dropbox-cloud-file-storage.md | 38 ++-- .../From-google-cloud-storage.md | 38 ++-- .../NET/Open-pdf-files/From-google-drive.md | 94 ++++----- .../PDF-Library/NET/Working-with-Document.md | 186 +++++++++--------- .../NET/Working-with-Watermarks.md | 116 +++++------ 8 files changed, 282 insertions(+), 289 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md b/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md index 489c463dc6..f4adec2e08 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md @@ -41,8 +41,7 @@ You can open an existing PDF document by using the [PdfLoadedDocument](https://h {% highlight c# tabtitle="C# [Cross-platform]" %} //Open an existing PDF document from stream through constructor of `PdfLoadedDocument` class. -FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf"); {% endhighlight %} @@ -129,9 +128,8 @@ You can open an existing encrypted PDF document from either the file system or t {% highlight c# tabtitle="C# [Cross-platform]" %} -//Open an encrypted PDF document from stream through constructor of `PdfLoadedDocument` class. -FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream, "password"); +//Open an encrypted PDF document from stream through constructor of `PdfLoadedDocument` class. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf", "password"); {% endhighlight %} @@ -210,9 +208,8 @@ You can open a corrupted PDF document from either the file system or the stream {% highlight c# tabtitle="C# [Cross-platform]" %} -//Open an existing corrupted PDF document from stream through constructor of `PdfLoadedDocument` class. -FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream, true); +//Open an existing corrupted PDF document from stream through constructor of `PdfLoadedDocument` class. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf", true); {% endhighlight %} @@ -295,8 +292,7 @@ You can save the manipulated PDF document to file system using [Save](https://he {% highlight c# tabtitle="C# [Cross-platform]" %} //Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //To-Do some manipulation //To-Do some manipulation //Save the PDF document into stream. @@ -463,8 +459,7 @@ After the document manipulation and save operation are completed, you should clo {% highlight c# tabtitle="C# [Cross-platform]" %} //Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //To-Do some manipulation //To-Do some manipulation //Save the document into stream. @@ -515,12 +510,11 @@ You can catch the secured document exception by opening an existing encrypted PD {% highlight c# tabtitle="C# [Cross-platform]" %} //Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); PdfLoadedDocument document = null; try { //Open an existing PDF document from a stream. - document = new PdfLoadedDocument(docStream, "password"); + document = new PdfLoadedDocument("Input.pdf", "password"); } catch (Syncfusion.Pdf.PdfInvalidPasswordException exception) { @@ -590,12 +584,11 @@ II. Please find some of the possible offset error messages that may be repairab {% highlight c# tabtitle="C# [Cross-platform]" %} //Load a PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); PdfLoadedDocument document = null; try { //Open an existing PDF document from the stream. - document = new PdfLoadedDocument(docStream, true); + document = new PdfLoadedDocument("Input.pdf", true); } catch (PdfException exception) { diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md index c13f680755..cbf749d735 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md @@ -25,9 +25,9 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Amazon; - using Amazon.S3; - using Amazon.S3.Transfer; +using Amazon; +using Amazon.S3; +using Amazon.S3.Transfer; {% endhighlight %} @@ -40,25 +40,25 @@ Step 5: Add the below code example to load a PDF from AWS S3. {% highlight c# tabtitle="C# [Cross-platform]" %} - // Set your AWS credentials and region - string accessKey = "YOUR_ACCESS_KEY"; - string secretKey = "YOUR_SECRET_KEY"; - RegionEndpoint region = RegionEndpoint.YOUR_REGION; // Change to your desired region - - // Specify the bucket name and object key - string bucketName = "YOUR_BUCKET_NAME"; - string objectKey = "YOUR_OBJECT_KEY"; - - string localFilePath = "Output.pdf"; - // Download the PDF from S3 - //MemoryStream pdfStream = DownloadFromS3(accessKey, secretKey, region, bucketName, objectKey); - using (var s3Client = new AmazonS3Client(accessKey, secretKey, region)) - { - using (var transferUtility = new TransferUtility(s3Client)) - { - transferUtility.Download(localFilePath, bucketName, objectKey); - } +// Set your AWS credentials and region +string accessKey = "YOUR_ACCESS_KEY"; +string secretKey = "YOUR_SECRET_KEY"; +RegionEndpoint region = RegionEndpoint.YOUR_REGION; // Change to your desired region + +// Specify the bucket name and object key +string bucketName = "YOUR_BUCKET_NAME"; +string objectKey = "YOUR_OBJECT_KEY"; + +string localFilePath = "Output.pdf"; +// Download the PDF from S3 +//MemoryStream pdfStream = DownloadFromS3(accessKey, secretKey, region, bucketName, objectKey); +using (var s3Client = new AmazonS3Client(accessKey, secretKey, region)) +{ + using (var transferUtility = new TransferUtility(s3Client)) + { + transferUtility.Download(localFilePath, bucketName, objectKey); } +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md index cdcf6c0daf..fa0d0e3348 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md @@ -25,8 +25,8 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Microsoft.Azure.Storage; - using Microsoft.Azure.Storage.Blob; +using Microsoft.Azure.Storage; +using Microsoft.Azure.Storage.Blob; {% endhighlight %} @@ -39,24 +39,24 @@ Step 5: Add the below code example to load a PDF from Azure blob storage. {% highlight c# tabtitle="C# [Cross-platform]" %} - // Parse the connection string to your Azure Storage Account. - CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); +// Parse the connection string to your Azure Storage Account. +CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); - // Create a client to interact with Blob storage. - CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); +// Create a client to interact with Blob storage. +CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); - // Get a reference to the container name. - CloudBlobContainer container = blobClient.GetContainerReference(containerName); +// Get a reference to the container name. +CloudBlobContainer container = blobClient.GetContainerReference(containerName); - // Get a reference to the block blob name. - CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName); +// Get a reference to the block blob name. +CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName); - // Open a file stream to save the downloaded blob content. - using (var fileStream = File.OpenWrite("sample.pdf")) - { - // Download the blob's content to the file stream. - blockBlob.DownloadToStream(fileStream); - } +// Open a file stream to save the downloaded blob content. +using (var fileStream = File.OpenWrite("sample.pdf")) +{ + // Download the blob's content to the file stream. + blockBlob.DownloadToStream(fileStream); +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md index 4fe84327c9..1b4bcf9f9a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md @@ -29,7 +29,7 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Dropbox.Api; +using Dropbox.Api; {% endhighlight %} @@ -42,29 +42,29 @@ Step 5: Add the below code example to load a PDF ifrom Dropbox cloud file storag {% highlight c# tabtitle="C# [Cross-platform]" %} - // Define the access token for authentication with the Dropbox API - var accessToken = "YOUR_ACCESS_TOKEN";// Replace with your actual access token +// Define the access token for authentication with the Dropbox API +var accessToken = "YOUR_ACCESS_TOKEN";// Replace with your actual access token - // Define the file path in Dropbox where the PDF file is located - var filePathInDropbox = "/path/to/save/Sample.pdf"; // Replace with the actual file path in Dropbox - // Create a new DropboxClient instance using the provided access token - using (var dbx = new DropboxClient(accessToken)) +// Define the file path in Dropbox where the PDF file is located +var filePathInDropbox = "/path/to/save/Sample.pdf"; // Replace with the actual file path in Dropbox +// Create a new DropboxClient instance using the provided access token +using (var dbx = new DropboxClient(accessToken)) +{ + // Start a download request for the specified file in Dropbox + using (var response = await dbx.Files.DownloadAsync(filePathInDropbox)) { - // Start a download request for the specified file in Dropbox - using (var response = await dbx.Files.DownloadAsync(filePathInDropbox)) + // Get the content of the downloaded file as a stream + var content = await response.GetContentAsStreamAsync(); + // Create a new file stream to save the downloaded content locally + using (var fileStream = File.Create("Output.pdf")) { - // Get the content of the downloaded file as a stream - var content = await response.GetContentAsStreamAsync(); - // Create a new file stream to save the downloaded content locally - using (var fileStream = File.Create("Output.pdf")) - { - // Copy the content stream to the file stream - content.CopyTo(fileStream); - // Close the file stream once the content is copied - fileStream.Close(); - } + // Copy the content stream to the file stream + content.CopyTo(fileStream); + // Close the file stream once the content is copied + fileStream.Close(); } } +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-cloud-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-cloud-storage.md index 9c93ae3720..3ee760331d 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-cloud-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-cloud-storage.md @@ -25,8 +25,8 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Google.Cloud.Storage.V1; - using Google.Apis.Auth.OAuth2; +using Google.Cloud.Storage.V1; +using Google.Apis.Auth.OAuth2; {% endhighlight %} @@ -39,23 +39,23 @@ Step 5: Add the below code example to create a simple PDF and save in Google clo {% highlight c# tabtitle="C# [Cross-platform]" %} - // Create a byte array - byte[] pdfBytes; - // Load the credentials file - GoogleCredential credential = GoogleCredential.FromFile("credentials.json"); - // Create a storage client - StorageClient storage = StorageClient.Create(credential); - // Download the PDF from Google Cloud Storage - using (MemoryStream stream = new MemoryStream()) - { - storage.DownloadObject("bucket50247", "Sample.pdf", stream); - pdfBytes = stream.ToArray(); - } - - string filePath = "Sample.pdf"; - - // Write the byte array to a PDF file - File.WriteAllBytes(filePath, pdfBytes); +// Create a byte array +byte[] pdfBytes; +// Load the credentials file +GoogleCredential credential = GoogleCredential.FromFile("credentials.json"); +// Create a storage client +StorageClient storage = StorageClient.Create(credential); +// Download the PDF from Google Cloud Storage +using (MemoryStream stream = new MemoryStream()) +{ + storage.DownloadObject("bucket50247", "Sample.pdf", stream); + pdfBytes = stream.ToArray(); +} + +string filePath = "Sample.pdf"; + +// Write the byte array to a PDF file +File.WriteAllBytes(filePath, pdfBytes); {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-drive.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-drive.md index c41da91251..1c1ca7b0f4 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-drive.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-drive.md @@ -28,10 +28,10 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Google.Apis.Auth.OAuth2; - using Google.Apis.Drive.v3; - using Google.Apis.Services; - using Google.Apis.Util.Store; +using Google.Apis.Auth.OAuth2; +using Google.Apis.Drive.v3; +using Google.Apis.Services; +using Google.Apis.Util.Store; {% endhighlight %} @@ -44,49 +44,49 @@ Step 5: Add the below code example to open a PDF from google drive. {% highlight c# tabtitle="C# [Cross-platform]" %} - UserCredential credential; - string[] Scopes = { DriveService.Scope.DriveReadonly }; - string ApplicationName = "YourAppName"; - - using (var stream1 = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) - { - string credPath = "token.json"; - credential = GoogleWebAuthorizationBroker.AuthorizeAsync( - GoogleClientSecrets.Load(stream1).Secrets, - Scopes, - "user", - CancellationToken.None, - new FileDataStore(credPath, true)).Result; - } - - // Step 2: Create Drive API service - var service = new DriveService(new BaseClientService.Initializer() - { - HttpClientInitializer = credential, - ApplicationName = ApplicationName, - }); - - // Step 3: Specify the file ID of the PDF you want to open - string fileId = "YOUR_FILE_ID"; // Replace with the actual file ID YOUR_FILE_ID - - // Step 4: Download the PDF file from Google Drive - var request = service.Files.Get(fileId); - var stream = new MemoryStream(); - request.Download(stream); - - // Step 5: Open the PDF with Syncfusion - //PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream); - - // Use the loadedDocument for further processing (e.g., extracting text or images) - - // Remember to dispose of the loadedDocument when you're done - //loadedDocument.Close(true); - - // Step 5: Save the PDF locally - using (FileStream fileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) - { - stream.WriteTo(fileStream); - } +UserCredential credential; +string[] Scopes = { DriveService.Scope.DriveReadonly }; +string ApplicationName = "YourAppName"; + +using (var stream1 = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) +{ + string credPath = "token.json"; + credential = GoogleWebAuthorizationBroker.AuthorizeAsync( + GoogleClientSecrets.Load(stream1).Secrets, + Scopes, + "user", + CancellationToken.None, + new FileDataStore(credPath, true)).Result; +} + +// Step 2: Create Drive API service +var service = new DriveService(new BaseClientService.Initializer() +{ + HttpClientInitializer = credential, + ApplicationName = ApplicationName, +}); + +// Step 3: Specify the file ID of the PDF you want to open +string fileId = "YOUR_FILE_ID"; // Replace with the actual file ID YOUR_FILE_ID + +// Step 4: Download the PDF file from Google Drive +var request = service.Files.Get(fileId); +var stream = new MemoryStream(); +request.Download(stream); + +// Step 5: Open the PDF with Syncfusion +//PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream); + +// Use the loadedDocument for further processing (e.g., extracting text or images) + +// Remember to dispose of the loadedDocument when you're done +//loadedDocument.Close(true); + +// Step 5: Save the PDF locally +using (FileStream fileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) +{ + stream.WriteTo(fileStream); +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Document.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Document.md index 75759e9e75..fd52cca7e7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Document.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Document.md @@ -1657,118 +1657,118 @@ Essential® PDF enables you to track the save progress through the {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/PDF%20Document/Create-a-PDF-document-with-save-progress/.NET/PDF-document-with-save-progress/Program.cs" %} - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf; - using Syncfusion.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using Syncfusion.Drawing; - // Create a new PDF document. - PdfDocument document = new PdfDocument(); +// Create a new PDF document. +PdfDocument document = new PdfDocument(); - // Add multiple pages to the document. - for (int i = 0; i < 10; i++) - { - // Add a new page. - PdfPage page = document.Pages.Add(); +// Add multiple pages to the document. +for (int i = 0; i < 10; i++) +{ + // Add a new page. + PdfPage page = document.Pages.Add(); - // Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; + // Create PDF graphics for the page. + PdfGraphics graphics = page.Graphics; - // Set the font to Helvetica with size 20. - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); + // Set the font to Helvetica with size 20. + PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); - // Draw text on the page. - graphics.DrawString($"This is page {i + 1}", font, PdfBrushes.Black, new PointF(0, 0)); - } + // Draw text on the page. + graphics.DrawString($"This is page {i + 1}", font, PdfBrushes.Black, new PointF(0, 0)); +} - // Subscribe to the SaveProgress event. - document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress); +// Subscribe to the SaveProgress event. +document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress); - //Save the document. - document.Save("Output.pdf"); - // Close the document. - document.Close(true); +//Save the document. +document.Save("Output.pdf"); +// Close the document. +document.Close(true); - // Event handler for the SaveProgress event. - void document_SaveProgress(object sender, ProgressEventArgs arguments) - { - // Output the current progress of the save operation. - Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)); - } +// Event handler for the SaveProgress event. +void document_SaveProgress(object sender, ProgressEventArgs arguments) +{ + // Output the current progress of the save operation. + Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)); +} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf; - using System.Drawing; - - // Create a new PDF document. - PdfDocument document = new PdfDocument(); - // Add multiple pages to the document. - for (int i = 0; i < 10; i++) - { - // Add a new page. - PdfPage page = document.Pages.Add(); - // Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; - // Set the font to Helvetica with size 20. - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); - // Draw text on the page. - graphics.DrawString($"This is page {i + 1}", font, PdfBrushes.Black, new PointF(0, 0)); - } - // Subscribe to the SaveProgress event. - document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress); - //Save the document. - document.Save("Output.pdf"); - // Close the document. - document.Close(true); - - // Event handler for the SaveProgress event. - void document_SaveProgress(object sender, ProgressEventArgs arguments) - { - // Output the current progress of the save operation. - Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)); - } +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using System.Drawing; + +// Create a new PDF document. +PdfDocument document = new PdfDocument(); +// Add multiple pages to the document. +for (int i = 0; i < 10; i++) +{ + // Add a new page. + PdfPage page = document.Pages.Add(); + // Create PDF graphics for the page. + PdfGraphics graphics = page.Graphics; + // Set the font to Helvetica with size 20. + PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); + // Draw text on the page. + graphics.DrawString($"This is page {i + 1}", font, PdfBrushes.Black, new PointF(0, 0)); +} +// Subscribe to the SaveProgress event. +document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress); +//Save the document. +document.Save("Output.pdf"); +// Close the document. +document.Close(true); + +// Event handler for the SaveProgress event. +void document_SaveProgress(object sender, ProgressEventArgs arguments) +{ + // Output the current progress of the save operation. + Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} - Imports Syncfusion.Pdf.Graphics - Imports Syncfusion.Pdf - Imports Syncfusion.Drawing - - Module Program - Sub Main() - ' Create a new PDF document. - Dim document As New PdfDocument() - ' Add multiple pages to the document. - For i As Integer = 0 To 9 - ' Add a new page. - Dim page As PdfPage = document.Pages.Add() - ' Create PDF graphics for the page. - Dim graphics As PdfGraphics = page.Graphics - ' Set the font to Helvetica with size 20. - Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20) - ' Draw text on the page. - graphics.DrawString(String.Format("This is page {0}", i + 1), font, PdfBrushes.Black, New PointF(0, 0)) - Next - ' Subscribe to the SaveProgress event. - AddHandler document.SaveProgress, AddressOf document_SaveProgress - ' Save the document. - document.Save("Output.pdf") - ' Close the document. - document.Close(True) - End Sub - - ' Event handler for the SaveProgress event. - Private Sub document_SaveProgress(ByVal sender As Object, ByVal arguments As ProgressEventArgs) - ' Output the current progress of the save operation. - Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)) - End Sub - End Module +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf +Imports Syncfusion.Drawing + +Module Program + Sub Main() + ' Create a new PDF document. + Dim document As New PdfDocument() + ' Add multiple pages to the document. + For i As Integer = 0 To 9 + ' Add a new page. + Dim page As PdfPage = document.Pages.Add() + ' Create PDF graphics for the page. + Dim graphics As PdfGraphics = page.Graphics + ' Set the font to Helvetica with size 20. + Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20) + ' Draw text on the page. + graphics.DrawString(String.Format("This is page {0}", i + 1), font, PdfBrushes.Black, New PointF(0, 0)) + Next + ' Subscribe to the SaveProgress event. + AddHandler document.SaveProgress, AddressOf document_SaveProgress + ' Save the document. + document.Save("Output.pdf") + ' Close the document. + document.Close(True) + End Sub + + ' Event handler for the SaveProgress event. + Private Sub document_SaveProgress(ByVal sender As Object, ByVal arguments As ProgressEventArgs) + ' Output the current progress of the save operation. + Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)) + End Sub +End Module {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Watermarks.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Watermarks.md index f88bc1253c..cabf5d42e5 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Watermarks.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Watermarks.md @@ -492,84 +492,84 @@ You can remove the Watermark annotation from the annotation collection, represen {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Watermark/Removing-watermark-annotation-in-PDF-document/.NET/Remove-watermark-annotation-in-the-PDF-document/Program.cs" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf.Parsing; - - //Load the PDF document - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); - // Iterate through the annotations collection and remove PdfLoadedWatermark annotations - foreach (PdfPageBase page in loadedDocument.Pages) +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + +//Load the PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +//Iterate through the annotations collection and remove PdfLoadedWatermark annotations +foreach (PdfPageBase page in loadedDocument.Pages) +{ + for (int i = page.Annotations.Count - 1; i >= 0; i--) { - for (int i = page.Annotations.Count - 1; i >= 0; i--) + // Check if the annotation is a PdfLoadedWatermarkAnnotation + if (page.Annotations[i] is PdfLoadedWatermarkAnnotation) { - // Check if the annotation is a PdfLoadedWatermarkAnnotation - if (page.Annotations[i] is PdfLoadedWatermarkAnnotation) - { - // Remove the PdfLoadedWatermarkAnnotation - page.Annotations.RemoveAt(i); - } + // Remove the PdfLoadedWatermarkAnnotation + page.Annotations.RemoveAt(i); } } +} - //Saves the document to disk. - loadedDocument.Save("WatermarkAnnotation.pdf"); - loadedDocument.Close(true); +//Saves the document to disk. +loadedDocument.Save("WatermarkAnnotation.pdf"); +loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; - //Load the existing PDF document - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); - // Iterate through the annotations collection and remove PdfLoadedWatermark annotations - foreach (PdfPageBase page in loadedDocument.Pages) +//Load the existing PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); +// Iterate through the annotations collection and remove PdfLoadedWatermark annotations +foreach (PdfPageBase page in loadedDocument.Pages) +{ + for (int i = page.Annotations.Count - 1; i >= 0; i--) { - for (int i = page.Annotations.Count - 1; i >= 0; i--) + // Check if the annotation is a PdfLoadedWatermarkAnnotation + if (page.Annotations[i] is PdfLoadedWatermarkAnnotation) { - // Check if the annotation is a PdfLoadedWatermarkAnnotation - if (page.Annotations[i] is PdfLoadedWatermarkAnnotation) - { - // Remove the PdfLoadedWatermarkAnnotation - page.Annotations.RemoveAt(i); - } + // Remove the PdfLoadedWatermarkAnnotation + page.Annotations.RemoveAt(i); } - } + } +} - //Saves the document to disk. - loadedDocument.Save("WatermarkAnnotation.pdf"); - loadedDocument.Close(true); +//Saves the document to disk. +loadedDocument.Save("WatermarkAnnotation.pdf"); +loadedDocument.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} - Imports Syncfusion.Pdf - Imports Syncfusion.Pdf.Graphics - Imports Syncfusion.Pdf.Parsing - - 'Load the existing PDF document - Dim loadedDocument As New PdfLoadedDocument("input.pdf") - ' Iterate through the annotations collection and remove PdfLoadedWatermark annotations - For Each page As PdfPageBase In loadedDocument.Pages - Dim i As Integer = page.Annotations.Count - 1 - While i >= 0 - ' Check if the annotation is a PdfLoadedWatermarkAnnotation - If TypeOf page.Annotations(i) Is PdfLoadedWatermarkAnnotation Then - ' Remove the PdfLoadedWatermarkAnnotation - page.Annotations.RemoveAt(i) - End If - i -= 1 - End While - Next - - 'Saves the document to disk. - loadedDocument.Save("WatermarkAnnotation.pdf") - loadedDocument.Close(True) +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + +'Load the existing PDF document +Dim loadedDocument As New PdfLoadedDocument("input.pdf") +'Iterate through the annotations collection and remove PdfLoadedWatermark annotations +For Each page As PdfPageBase In loadedDocument.Pages + Dim i As Integer = page.Annotations.Count - 1 + While i >= 0 + 'Check if the annotation is a PdfLoadedWatermarkAnnotation + If TypeOf page.Annotations(i) Is PdfLoadedWatermarkAnnotation Then + 'Remove the PdfLoadedWatermarkAnnotation + page.Annotations.RemoveAt(i) + End If + i -= 1 + End While +Next + +'Saves the document to disk. +loadedDocument.Save("WatermarkAnnotation.pdf") +loadedDocument.Close(True) {% endhighlight %} From ed2cbc781335120c6a365b4cc346569ed179a421 Mon Sep 17 00:00:00 2001 From: jeyalakshmit Date: Wed, 20 May 2026 18:51:09 +0530 Subject: [PATCH 03/14] 1027879-ug modification --- .../Data-Extraction/OCR/NET/overview.md | 2 +- .../HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 2 +- .../PDF/Conversions/HTML-To-PDF/overview.md | 2 +- .../PDF-Library/NET/Converting-XPS-to-PDF.md | 10 +- .../NET/Create-PDF-file-in-ASP-NET-Core.md | 4 +- .../PDF/PDF-Library/NET/Merge-Documents.md | 61 +++---- .../PDF/PDF-Library/NET/PdfLightTable.md | 74 +++----- .../NET/Working-with-Attachments.md | 168 ++++++++---------- .../PDF-Library/NET/Working-with-Bookmarks.md | 52 +++--- .../PDF-Library/NET/Working-with-Brushes.md | 36 ++-- .../NET/Working-with-Compression.md | 70 ++------ 11 files changed, 176 insertions(+), 305 deletions(-) diff --git a/Document-Processing/Data-Extraction/OCR/NET/overview.md b/Document-Processing/Data-Extraction/OCR/NET/overview.md index fa050f0c11..bf3739533d 100644 --- a/Document-Processing/Data-Extraction/OCR/NET/overview.md +++ b/Document-Processing/Data-Extraction/OCR/NET/overview.md @@ -43,5 +43,5 @@ N> Starting with v20.1.0.x, if you reference Syncfusion® OCR proc * Image into searchable PDF or PDF/A. * Improved accessibility. * Post-processing. -* Compatible with .NET Framework 4.5 and above. +* Compatible with .NET Framework 4.6.2 and above. * Compatible with .NET Core 2.0 and above. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md index b07c9fa654..8df6da9415 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md @@ -7,7 +7,7 @@ documentation: UG --- # Converting HTML to PDF -The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. +The [HTML to PDF converter](https://www.syncfusion.com/document-sdk/net-pdf-library/html-to-pdf) is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. Syncfusion® HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md index 5381b8a25b..fe4838fbf1 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md @@ -7,7 +7,7 @@ documentation: UG --- # Converting HTML to PDF -The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. +The [HTML to PDF converter](https://www.syncfusion.com/document-sdk/net-pdf-library/html-to-pdf) is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. Syncfusion® HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS. diff --git a/Document-Processing/PDF/PDF-Library/NET/Converting-XPS-to-PDF.md b/Document-Processing/PDF/PDF-Library/NET/Converting-XPS-to-PDF.md index bf10f7888a..eda70131f9 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Converting-XPS-to-PDF.md +++ b/Document-Processing/PDF/PDF-Library/NET/Converting-XPS-to-PDF.md @@ -17,15 +17,11 @@ The following code example illustrates how to converting XPS document to PDF usi //Initialize XPS to PDF converter. XPSToPdfConverter converter = new XPSToPdfConverter(); -//Open the XPS file as stream. -FileStream fileStream = new FileStream("Input.xps", FileMode.Open, FileAccess.ReadWrite); //Convert the XPS to PDF. -PdfDocument document = converter.Convert(fileStream); +PdfDocument document = converter.Convert("Input.xps"); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the documents. document.Close(true); diff --git a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-ASP-NET-Core.md b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-ASP-NET-Core.md index 5c9759f729..0ac065ccc5 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-ASP-NET-Core.md +++ b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-ASP-NET-Core.md @@ -9,9 +9,9 @@ keywords: .net core create pdf, edit pdf, merge, pdf form, fill form, digital si # Create or Generate PDF file in ASP.NET Core -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 merge, split, stamp, forms, and secure PDF files. +The Syncfusion® [.NET PDF library](https://www.syncfusion.com/document-sdk/net-pdf-library) is a powerful and versatile solution for creating, reading, and editing PDF documents in .NET applications. It also provides advanced features such as merging and splitting PDFs, adding stamps, working with form fields, and securing PDF files with encryption and permissions. -To include the .NET Core PDF library into your ASP.NET Core application, please refer to the [NuGet Package Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/nuget-packages-required) or [Assemblies Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/assemblies-required) documentation. +To integrate the .NET PDF library into your ASP.NET Core application, refer to the official documentation sections on [NuGet Package Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/nuget-packages-required) or [Assemblies Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/assemblies-required) for step-by-step guidance. N> Beginning with our Volume 2, 2023 release, we have eliminated the dependency on the System.Drawing.Common package from our Syncfusion.Pdf.Imaging.Net.Core package. Instead, we have introduced SkiaSharp as the alternative library. diff --git a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md index b9b62d8608..10d2ea3ef7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md +++ b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md @@ -29,9 +29,8 @@ string[] source = { "file1.pdf", "file2.pdf" }; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); @@ -85,9 +84,8 @@ Stream[] streams = { stream1, stream2 }; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, streams); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); //Disposes the streams. @@ -147,17 +145,14 @@ Essential® PDF provides support for importing the pages from one {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Importing-pages-from-one-document-another-document/.NET/Importing-pages-from-one-document-another-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Create a new document. PdfDocument document = new PdfDocument(); //Imports the page at 1 from the lDoc. document.ImportPage(lDoc, 1); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); lDoc.Close(true); @@ -208,17 +203,14 @@ You can import multiple pages from an existing document by using [ImportPageRang {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Import-multiple-pages-from-an-existing-PDF/.NET/Import-multiple-pages-from-an-existing-PDF/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Create a new document. PdfDocument document = new PdfDocument(); //Imports the page at 1 from the lDoc. document.ImportPageRange(lDoc, 0, lDoc.Pages.Count - 1); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); lDoc.Close(true); @@ -269,22 +261,17 @@ You can also import pages from multiple documents and arrange the pages by using {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Import-pages-from-multiple-documents-and-arrange-pages/.NET/Import-pages-from-multiple-documents-and-arrange-pages/Program.cs" %} //Load the PDF document. -FileStream docStream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream1); -//Load the PDF document. -FileStream docStream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); +PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Load the PDF document. -PdfLoadedDocument lDoc2 = new PdfLoadedDocument(docStream2); +PdfLoadedDocument lDoc2 = new PdfLoadedDocument("file2.pdf"); //Create the new document. PdfDocument document = new PdfDocument(); //Imports and arranges the pages. document.ImportPage(lDoc, 1); document.ImportPage(lDoc2, 0); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the documents. document.Close(true); lDoc.Close(true); @@ -392,9 +379,8 @@ string[] source = { "file1.pdf", "file2.pdf" }; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); @@ -454,9 +440,8 @@ mergeOptions.OptimizeResources = true; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, mergeOptions, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("output.pdf"); //Close the document. finalDoc.Close(true); @@ -529,9 +514,8 @@ mergeOptions.ExtendMargin = true; //Merge PDFDocument. PdfDocumentBase.Merge(finalDoc, mergeOptions, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); @@ -609,9 +593,8 @@ PdfMergeOptions mergeOptions = new PdfMergeOptions(); mergeOptions.MergeAccessibilityTags = true; //Merge PDFDocument. PdfDocumentBase.Merge(finalDoc, mergeOptions, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); diff --git a/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md b/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md index f3f4f628bf..2f5cd0f043 100644 --- a/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md +++ b/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md @@ -42,10 +42,8 @@ pdfLightTable.DataSource = table; //Draw PdfLightTable. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(0, 0)); -//Create the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -144,10 +142,8 @@ pdfLightTable.Rows.Add(new object[] { "111", "Maxim", "III" }); //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -225,10 +221,8 @@ Create a table using the [PdfLightTable](https://help.syncfusion.com/cr/document {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Creating-the-table-in-an-existing-PDF-document/.NET/Creating-the-table-in-an-existing-PDF-document/Program.cs" %} -//Get stream from an existing PDF document. -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); //Load the PDF document. -PdfLoadedDocument doc = new PdfLoadedDocument(docStream); +PdfLoadedDocument doc = new PdfLoadedDocument("input.pdf"); //Get the first page from the document PdfLoadedPage page = doc.Pages[0] as PdfLoadedPage; //Create PDF graphics for the page @@ -248,10 +242,8 @@ pdfLightTable.DataSource = table; //Draw PdfLightTable. pdfLightTable.Draw(graphics, new Syncfusion.Drawing.PointF(0, 0)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -365,10 +357,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -498,10 +488,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -657,10 +645,8 @@ pdfLightTable.EndRowLayout += pdfLightTable_EndRowLayout; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Create the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to the stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -847,10 +833,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to the stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -983,10 +967,8 @@ pdfLightTable.Style = lightTableStyle; //Draw PdfLightTable. pdfLightTable.Draw(page, new PointF(0, 0)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the document. document.Close(true); {% endhighlight %} @@ -1125,10 +1107,8 @@ pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable4Accent2); //Draw the grid to the page of a PDF document. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -doc.Save(stream); +//Save the document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -1243,10 +1223,8 @@ layoutFormat.Layout = PdfLayoutType.Paginate; //Draw PdfLightTable. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(0, 0), layoutFormat); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the document. document.Close(true); {% endhighlight %} @@ -1369,9 +1347,8 @@ for (int i = 0; i < lightTable.Columns.Count; i++) //Draw the PdfLightTable on the page. lightTable.Draw(page, new PointF(10, 10)); -//Save a PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save a PDF document. +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} @@ -1500,9 +1477,8 @@ lightTable.Columns[1].StringFormat = stringFormat; //Draw the PdfLightTable on the page. lightTable.Draw(page, new PointF(10, 10)); -//Save the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md index 1b44bac45a..170f6c783e 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md @@ -31,9 +31,8 @@ attachment.MimeType = "application/txt"; //Adds the attachment to the document document.Attachments.Add(attachment); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -86,8 +85,7 @@ Essential® PDF also provides support for adding the attachments t {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Adding-the-attachments-to-an-existing-PDF-document/.NET/Adding-the-attachments-to-an-existing-PDF-document/Program.cs" %} //Load the PDF document -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Creates an attachment Stream fileStream = new FileStream("Input.txt", FileMode.Open, FileAccess.Read); PdfAttachment attachment = new PdfAttachment("Input.txt", fileStream); @@ -99,9 +97,8 @@ if (loadedDocument.Attachments == null) //Add the attachment to the document loadedDocument.Attachments.Add(attachment); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document loadedDocument.Close(true); @@ -162,16 +159,14 @@ Essential® PDF allows you to remove the attachments from the exis {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Remove-attachment-from-an-existing-PDF-document/.NET/Remove-attachment-from-an-existing-PDF-document/Program.cs" %} //Load the PDF document -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Removes an attachment PdfAttachment attachment = document.Attachments[0]; //document.Attachments.Remove(attachment); document.Attachments.RemoveAt(0); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -220,8 +215,7 @@ Essential® PDF provides support for extracting the attachments an {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Extract-and-saving-an-attachment-to-the-disk/.NET/Extract-and-saving-an-attachment-to-the-disk/Program.cs" %} //Load the PDF document -FileStream docStream = new FileStream("Output.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("input.pdf"); //Iterates the attachments foreach (PdfAttachment attachment in document.Attachments) { @@ -231,9 +225,8 @@ foreach (PdfAttachment attachment in document.Attachments) s.Dispose(); } -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -292,105 +285,98 @@ You can achieve this functionality by using JavaScript actions within Syncfusion {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Adding-PDF-Attachments-with-Interactive-Launch-Buttons/.NET/Adding-PDF-Attachments-with-Interactive-Launch-Buttons/Program.cs" %} -//Create FileStream object to read the input PDF file -using (FileStream inputFileStream = new FileStream(@"Data/Input.pdf", FileMode.Open, FileAccess.Read)) -{ - // Load the existing PDF file - PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream); - // Get the first page of the PDF - PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; +// Load the existing PDF file +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Data/Input.pdf"); - // Create a PDF attachment - PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); - attachment.Description = "Attachment"; +// Get the first page of the PDF +PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; - // Create attachments section if it doesn't exist - if (loadedDocument.Attachments == null) - loadedDocument.CreateAttachment(); +// Create a PDF attachment +PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); +attachment.Description = "Attachment"; - // Add the attachment to the document - loadedDocument.Attachments.Add(attachment); +// Create attachments section if it doesn't exist +if (loadedDocument.Attachments == null) + loadedDocument.CreateAttachment(); - // Create a button field on the page - PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); - buttonField.Bounds = new RectangleF(100, 100, 100, 20); - buttonField.BorderColor = new PdfColor(Color.Black); - buttonField.BackColor = new PdfColor(Color.LightGray); - buttonField.Text = "Click Me"; - buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); +// Add the attachment to the document +loadedDocument.Attachments.Add(attachment); - // Add JavaScript action to open the attachment - buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); +// Create a button field on the page +PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); +buttonField.Bounds = new RectangleF(100, 100, 100, 20); +buttonField.BorderColor = new PdfColor(Color.Black); +buttonField.BackColor = new PdfColor(Color.LightGray); +buttonField.Text = "Click Me"; +buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); - // Create a form if it doesn't exist - if (loadedDocument.Form == null) - loadedDocument.CreateForm(); +// Add JavaScript action to open the attachment +buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); - // Add the button field to the form - loadedDocument.Form.Fields.Add(buttonField); +// Create a form if it doesn't exist +if (loadedDocument.Form == null) + loadedDocument.CreateForm(); - // Set default appearance for form fields - loadedDocument.Form.SetDefaultAppearance(false); +// Add the button field to the form +loadedDocument.Form.Fields.Add(buttonField); - //Create file stream. - using (FileStream outputFileStream = new FileStream(@"Output/Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - loadedDocument.Save(outputFileStream); - } +// Set default appearance for form fields +loadedDocument.Form.SetDefaultAppearance(false); + +//Save the PDF document. +loadedDocument.Save("Output.pdf"); - //Close the document. - loadedDocument.Close(true); -} +//Close the document. +loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - // Load the existing PDF file - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +// Load the existing PDF file +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); - // Get the first page of the PDF - PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; +// Get the first page of the PDF +PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; - // Create a PDF attachment - PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); - attachment.Description = "Attachment"; +// Create a PDF attachment +PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); +attachment.Description = "Attachment"; - // Create attachments section if it doesn't exist - if (loadedDocument.Attachments == null) - loadedDocument.CreateAttachment(); +// Create attachments section if it doesn't exist +if (loadedDocument.Attachments == null) + loadedDocument.CreateAttachment(); - // Add the attachment to the document - loadedDocument.Attachments.Add(attachment); +// Add the attachment to the document +loadedDocument.Attachments.Add(attachment); - // Create a button field on the page - PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); - buttonField.Bounds = new RectangleF(100, 100, 100, 20); - buttonField.BorderColor = new PdfColor(Color.Black); - buttonField.BackColor = new PdfColor(Color.LightGray); - buttonField.Text = "Click Me"; - buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); +// Create a button field on the page +PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); +buttonField.Bounds = new RectangleF(100, 100, 100, 20); +buttonField.BorderColor = new PdfColor(Color.Black); +buttonField.BackColor = new PdfColor(Color.LightGray); +buttonField.Text = "Click Me"; +buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); - // Add JavaScript action to open the attachment - buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); +// Add JavaScript action to open the attachment +buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); - // Create a form if it doesn't exist - if (loadedDocument.Form == null) - loadedDocument.CreateForm(); +// Create a form if it doesn't exist +if (loadedDocument.Form == null) + loadedDocument.CreateForm(); - // Add the button field to the form - loadedDocument.Form.Fields.Add(buttonField); +// Add the button field to the form +loadedDocument.Form.Fields.Add(buttonField); - // Set default appearance for form fields - loadedDocument.Form.SetDefaultAppearance(false); +// Set default appearance for form fields +loadedDocument.Form.SetDefaultAppearance(false); - //Save the PDF document to file stream. - loadedDocument.Save("Output.pdf"); +//Save the PDF document. +loadedDocument.Save("Output.pdf"); - //Close the document. - loadedDocument.Close(true); +//Close the document. +loadedDocument.Close(true); {% endhighlight %} @@ -436,7 +422,7 @@ loadedDocument.Form.Fields.Add(buttonField) ' Set default appearance for form fields loadedDocument.Form.SetDefaultAppearance(False) -' Save the PDF document to file stream +' Save the PDF document loadedDocument.Save("Output.pdf") ' Close the document diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md index b9bf37b567..948a308dcc 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md @@ -34,10 +34,9 @@ bookmark.Destination.Location = new PointF(20, 20); bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Color = Syncfusion.Drawing.Color.Red; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); -//Closes the document +//Save the document. +document.Save("Output.pdf"); +//Closes the document. document.Close(true); {% endhighlight %} @@ -99,8 +98,7 @@ To add bookmarks to an existing PDF document, use the following code example. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Adding-bookmarks-in-an-existing-PDF-document/.NET/Adding-bookmarks-in-an-existing-PDF-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Creates document bookmarks. PdfBookmark bookmark = document.Bookmarks.Add("Page 1"); //Sets the destination page. @@ -111,9 +109,8 @@ bookmark.Color = Color.Red; //Sets the destination location. bookmark.Destination.Location = new PointF(20, 20); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -190,9 +187,8 @@ childBookmark.Destination.Zoom = 2F; bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Color = Syncfusion.Drawing.Color.Red; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -267,17 +263,15 @@ Each loaded bookmark is represented by the [PdfLoadedBookmark](https://help.sync {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Inserting-bookmarks-in-an-existing-PDF/.NET/Inserting-bookmarks-in-an-existing-PDF/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Inserts a new bookmark in the existing bookmark collection. PdfBookmark bookmark = document.Bookmarks.Insert(1, "New Page 2"); //Sets the destination page and location. bookmark.Destination = new PdfDestination(document.Pages[1]); bookmark.Destination.Location = new PointF(0, 300); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -326,8 +320,7 @@ You can also remove bookmarks from the existing PDF document by using [Remove](h {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Remove-bookmarks-from-an-existing-PDF-document/.NET/Remove-bookmarks-from-an-existing-PDF-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmarks = document.Bookmarks; //Removes bookmark by bookmark name. @@ -335,9 +328,8 @@ bookmarks.Remove("Page 1"); //Removes bookmark by index. bookmarks.RemoveAt(1); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("output.pdf"); //Closes the document. document.Close(true); @@ -397,8 +389,7 @@ The following code example shows how to modify the [Destination](https://help.sy {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Modify-the-bookmarks-in-an-existing-PDF-document/.NET/Modify-the-bookmarks-in-an-existing-PDF-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmarks = document.Bookmarks; //Gets the first bookmark and changes the properties of the bookmark. @@ -408,9 +399,8 @@ bookmark.Color = Syncfusion.Drawing.Color.Green; bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Title = "Changed title"; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("output.pdf"); //Closes the document. document.Close(true); @@ -468,16 +458,14 @@ You can get bookmark page index from the existing PDF document using [PageIndex] {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Get-bookmark-page-index-from-the-existing-PDF-document/.NET/Get-bookmark-page-index-from-the-existing-PDF-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmark = loadedDocument.Bookmarks; //Get the bookmark page index. int index = bookmark[0].Destination.PageIndex; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("output.pdf"); //Close the document. loadedDocument.Close(true); diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md index 1e171afea3..a617e63ea7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md @@ -36,9 +36,8 @@ PdfSolidBrush brush = new PdfSolidBrush(Color.Red); //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} @@ -105,9 +104,8 @@ PdfLinearGradientBrush brush = new PdfLinearGradientBrush(new PointF(0, 0), new //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} @@ -204,12 +202,9 @@ using (PdfDocument document = new PdfDocument()) // Draw a rectangle filled with the gradient graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100)); - //Create file stream. - using (FileStream outputFileStream = new FileStream(@"Output/Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document to file stream. + document.Save("Output.pdf"); + } {% endhighlight %} @@ -317,9 +312,8 @@ PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100)); -//Save the PDF document stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} @@ -388,9 +382,8 @@ brush.Graphics.DrawEllipse(PdfPens.Red, new RectangleF(0, 0, 10, 10)); //Draw ellipse graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} @@ -464,11 +457,10 @@ PdfHatchBrush pdfHatchBrush = new PdfHatchBrush(PdfHatchStyle.Plaid, new PdfColo //Draw rectangle on the page graphics.DrawRectangle(PdfPens.Black, pdfHatchBrush, new Rectangle(100, 100, 300, 200)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document -doc.Close(true); +doc.Close(true); {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md index fc73b17e20..006d037426 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md @@ -56,20 +56,10 @@ options.ImageQuality = 50; //Assign the compression option to the document. loadedDocument.Compress(options); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("Output.pdf"); //Close the documents. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} @@ -144,20 +134,10 @@ options.OptimizeFont = true; //Assign the compression option to the document. loadedDocument.Compress(options); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("Output.pdf"); //Close the documents. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} @@ -230,20 +210,10 @@ options.OptimizePageContents = true; //Assign the compression option to the document. loadedDocument.Compress(options); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("Output.pdf"); //Close the documents. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} @@ -314,20 +284,10 @@ options.RemoveMetadata = true; //Assign the compression option to the document. loadedDocument.Compress(options); -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("Output.pdf"); //Close the documents. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} @@ -409,20 +369,10 @@ for (int i = 0; i < 1000; i++) result = textElement.Draw(result.Page, new RectangleF(0, result.Bounds.Bottom + 10, font.MeasureString(text).Width, page.GetClientSize().Height)); } -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the documents. document.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} From 6e1a4fa5c816198c05e5d693ed90a3315d3a1520 Mon Sep 17 00:00:00 2001 From: Chinnu M <65020530+chinnumuniyappan@users.noreply.github.com> Date: Thu, 21 May 2026 13:30:45 +0530 Subject: [PATCH 04/14] Resolved few feedback --- .../PDF-Library/NET/Working-with-Shapes.md | 2 +- .../NET/Working-with-Text-Extraction.md | 47 +++++++++++++++++-- .../PDF/PDF-Library/NET/Working-with-XFA.MD | 8 ++-- .../PDF/PDF-Library/NET/Working-with-forms.md | 2 +- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md index eb9d8891e8..39f5bc9111 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md @@ -969,7 +969,7 @@ document.Close(true); {% endhighlight %} -{% highlight c# tabtitle="C#" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using System.Drawing; using Syncfusion.Pdf; diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md index a4c7aa40cb..5c21987113 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md @@ -438,6 +438,44 @@ Color glyphColor = textGlyph.TextColor; {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; +using System.Drawing; + +// Load the existing PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +// Get the first page of the loaded PDF document +PdfPageBase page = loadedDocument.Pages[0]; +TextLines lineCollection = new TextLines(); + +// Extract text from the first page +string extractedText = page.ExtractText(out lineCollection); +// Get a specific line from the collection +TextLine line = lineCollection[0]; +// Get the collection of words in the line +List textWordCollection = line.WordCollection; +// Get a word from the collection using an index +TextWord textWord = textWordCollection[0]; +// Get Glyph details of the word +List textGlyphCollection = textWord.Glyphs; + +// Get a character from the word +TextGlyph textGlyph = textGlyphCollection[0]; +// Get bounds of the character +RectangleF glyphBounds = textGlyph.Bounds; +// Get font name of the character +string glyphFontName = textGlyph.FontName; +// Get font size of the character +float glyphFontSize = textGlyph.FontSize; +// Get font style of the character +FontStyle glyphFontStyle = textGlyph.FontStyle; +// Get the character in the word +char glyphText = textGlyph.Text; +// Get the color of the character +Color glyphColor = textGlyph.TextColor; + +{% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -446,16 +484,16 @@ Imports Syncfusion.Pdf.Parsing Imports System.Drawing ' Load the existing PDF document -Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") +Dim loadedDocument As New PdfLoadedDocument("Input.pdf") ' Get the first page of the loaded PDF document Dim page As PdfPageBase = loadedDocument.Pages(0) -Dim lineCollection As New TextLineCollection() +Dim lineCollection As New TextLines() ' Extract text from the first page Dim extractedText As String = page.ExtractText(lineCollection) ' Get a specific line from the collection -Dim line As TextLine = lineCollection.TextLine(0) -' Get a collection of words in the line +Dim line As TextLine = lineCollection(0) +' Get the collection of words in the line Dim textWordCollection As List(Of TextWord) = line.WordCollection ' Get a word from the collection using an index Dim textWord As TextWord = textWordCollection(0) @@ -476,6 +514,7 @@ Dim glyphFontStyle As FontStyle = textGlyph.FontStyle Dim glyphText As Char = textGlyph.Text ' Get the color of the character Dim glyphColor As Color = textGlyph.TextColor + {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-XFA.MD b/Document-Processing/PDF/PDF-Library/NET/Working-with-XFA.MD index ccf81610ad..b14811e000 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-XFA.MD +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-XFA.MD @@ -1729,7 +1729,7 @@ loadedDocument.Close(); {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Drawing; using Syncfusion.Pdf.Xfa; @@ -3491,13 +3491,13 @@ mainForm.Fields.Add(numericField); document.XfaForm = mainForm; //Save the document. -document.Save("XfaForm.pdf",PdfXfaType.Dynamic); +document.Save("XfaForm.pdf", PdfXfaType.Dynamic); //Close the document. document.Close(); {% endhighlight %} -{% highlight c# tabtitle="C#" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Drawing; using Syncfusion.Pdf.Xfa; @@ -3527,7 +3527,7 @@ document.Close(); {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET" %} +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Create a new PDF XFA document Dim document As New PdfXfaDocument() diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md index b93b096d90..9d600ba71c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md @@ -3748,7 +3748,7 @@ loadedDocument.Close(true); {% endhighlight %} -{% highlight c# tabtitle="C#" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Pdf; using Syncfusion.Pdf.Interactive; From 334619da1370d147d673e22dbb89084cc4502e00 Mon Sep 17 00:00:00 2001 From: Chinnu M <65020530+chinnumuniyappan@users.noreply.github.com> Date: Thu, 21 May 2026 14:54:17 +0530 Subject: [PATCH 05/14] CI failures resolved --- .../PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md | 2 +- .../PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md | 2 +- .../NET/Open-pdf-files/From-dropbox-cloud-file-storage.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md index cbf749d735..99be4acbaa 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md @@ -1,6 +1,6 @@ --- title: Open PDF file from AWS S3 | Syncfusion -description: This page describes how to Open PDF file from file AWS S3 in C# using Syncfusion .NET PDF library. +description: This page explains how to open and load a PDF document stored in an AWS S3 bucket using C# with the Syncfusion .NET PDF library. platform: document-processing control: PDF documentation: UG diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md index fa0d0e3348..f58534e921 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md @@ -1,5 +1,5 @@ --- -title: Open PDF file from Azure blob storage | Syncfusion +title: Open PDF document from Azure Blob Storage | Syncfusion description: This page describes how to Open PDF file from file azure blob storage in C# using Syncfusion .NET PDF library. platform: document-processing control: PDF diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md index 1b4bcf9f9a..6d9ceae2d2 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md @@ -36,7 +36,7 @@ using Dropbox.Api; {% endtabs %} -Step 5: Add the below code example to load a PDF ifrom Dropbox cloud file storage. +Step 5: Add the below code example to load a PDF from Dropbox cloud file storage. {% tabs %} From 41db14f78044c0d1e8b5c3b8ccf07bfad68097e4 Mon Sep 17 00:00:00 2001 From: Chinnu M <65020530+chinnumuniyappan@users.noreply.github.com> Date: Thu, 21 May 2026 15:10:16 +0530 Subject: [PATCH 06/14] Feedback addressed --- .../HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 29 ----- .../HTML-To-PDF/NET/troubleshooting.md | 103 +++++------------- .../PDF/Conversions/HTML-To-PDF/overview.md | 4 - 3 files changed, 30 insertions(+), 106 deletions(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md index 8df6da9415..2eae3784de 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md @@ -200,8 +200,6 @@ using Syncfusion.HtmlConverter; Step 4: Use the following code sample to convert the URL to PDF in the program.cs. -{% tabs %} - {% highlight c# tabtitle="C#" %} //Initialize HTML to PDF converter. @@ -221,8 +219,6 @@ document.Close(true); {% endhighlight %} -{% endtabs %} - By executing the program, you will get the PDF document as follows. htmltopdfoutput @@ -271,8 +267,6 @@ By default, the PDF document generated with the IE rendering engine comes with t IEWarning Please refer to the below code snippet to use the DisableIEWarning API to remove the default IE warning from the PDF document. -{% tabs %} - {% highlight c# tabtitle="C#" %} //Initialize the HTML to PDF converter @@ -291,27 +285,4 @@ document.Close(true); {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET" %} -'Initialize the HTML to PDF converter -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.IE) -Dim settings As New IEConverterSettings() -'Disable Default IE Warning Message -settings.DisableIEWarning = true -'Assign IE settings to HTML converter -htmlConverter.ConverterSettings = settings -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} -//Currently, IE rendering engine does not support conversion in .NET Core platform -{% endhighlight %} - -{% endtabs %} - N>Please try our [Blink](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/net-core) engine to improve the quality and accuracy of the HTML to PDF conversion. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md index 534d7a9eb0..3a19f8fbd8 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md @@ -34,7 +34,7 @@ You can set the runtimes folder path explicitly in BlinkPath property in BlinkCo

Ex path: C:\HtmlConversion\HTMl-to-PDF\HTMl-to-PDF\bin\Debug\net7.0\runtimes\win-x64\native\

-{% tabs %} + {% highlight C# %} //Initialize the HTML to PDF converter. @@ -52,7 +52,7 @@ document.Save("Output.pdf"); document.Close(true); {% endhighlight %} -{% endtabs %} + @@ -138,7 +138,7 @@ Also, please add the following command line arguments in our converter setting.
-{% tabs %} + {% highlight C# tabtitle="C#" %} //Set command line arguments to run without sandbox. @@ -146,7 +146,7 @@ blinkConverterSettings.CommandLineArguments.Add("--no-sandbox"); blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox"); {% endhighlight %} -{% endtabs %} +
@@ -260,7 +260,7 @@ Step 2: To resolve this issue, we recommend copying the runtimes folder i Step 3: If manually copying the files doesn't meet your requirements, we recommend applying the following code changes in the .csproj file and updating the publish profile. This will ensure the necessary files are copied automatically during the publishing process.
Add the following code snippet to the .pubxml file to apply the necessary configuration.
-{% tabs %} + {% highlight C# tabtitle="C#" %} @@ -270,10 +270,9 @@ Add the following code snippet to the .pubxml file to apply the necessary {% endhighlight %} -{% endtabs %} Add the following code to the .csproj file to ensure the locale folder is copied to the publish directory during the build process.
-{% tabs %} + {% highlight C# tabtitle="C#" %} @@ -287,7 +286,7 @@ Add the following code to the .csproj file to ensure the locale fo {% endhighlight %} -{% endtabs %} + @@ -338,14 +337,14 @@ Add the following code to the .csproj file to ensure the locale fo To overcome the exception, you can add read, write, and execute permissions for the temporary folder. Refer to the following code sample to set the temp folder.

-{% tabs %} + {% highlight C# tabtitle="C#" %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.TempPath = "D://MyProject//bin"; {% endhighlight %} -{% endtabs %} + @@ -423,14 +422,14 @@ Check the HTML file or URL is rendered properly in Chrome browser's print previe

ExcludeAssets

-{% tabs %} + {% highlight C# tabtitle="C#" %} RUN chmod +x /app/runtimes/linux/native/chrome && \ chmod +x /app/runtimes/linux/native/chrome-wrapper {% endhighlight %} -{% endtabs %} + @@ -454,14 +453,14 @@ RUN chmod +x /app/runtimes/linux/native/chrome && \ To overcome this issue, add suitable delay for the conversion using the AdditionalDelay property of the HTMLConverter.

-{% tabs %} + {% highlight C# tabtitle="C#" %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.AdditionalDelay = 4000; {% endhighlight %} -{% endtabs %} + @@ -560,14 +559,14 @@ These plans provide the necessary environment and permissions to support Chromiu You can able to bypass the invalid SSL certificate errors using the command line arguments property of Blink converter settings.

-{% tabs %} + {% highlight C# tabtitle="C#" %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.CommandLineArguments.Add("--ignore-certificate-errors"); {% endhighlight %} -{% endtabs %} + @@ -597,7 +596,7 @@ settings.CommandLineArguments.Add("--ignore-certificate-errors"); Use system-installed Chromium instead of bundled binaries:

Step 1: Configure Blink Path -{% tabs %} + {% highlight C# tabtitle="C#" %} HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -615,7 +614,6 @@ document.Save("Output.pdf"); document.Close(true); {% endhighlight %} -{% endtabs %} Step 2: Verify Installation
Ensure Chrome exists at the specified path (standard locations): `C:\Program Files\Google\Chrome\Application` @@ -644,7 +642,7 @@ Ensure Chrome exists at the specified path (standard locations): `C:\Program Fil We can resolve this permission related failure in the Blink rendering engine using below command line arguments in our converter settings.

-{% tabs %} + {% highlight C# tabtitle="C#" %} //Set command line arguments to run without sandbox. @@ -652,7 +650,7 @@ blinkConverterSettings.CommandLineArguments.Add("--no-sandbox"); blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox"); {% endhighlight %} -{% endtabs %} + @@ -799,7 +797,6 @@ Refer to the following package reference: To resolve this issue, we can install the chromium using the docker file and set the Blink Path to the location where chromium is installed.

Docker File:

-{% tabs %} {% highlight C# tabtitle="C#" %} @@ -825,10 +822,7 @@ To resolve this issue, we can install the chromium using the docker file and set {% endhighlight %} -{% endtabs %} - Code example: -{% tabs %} {% highlight C# tabtitle="C#" %} @@ -840,8 +834,6 @@ To resolve this issue, we can install the chromium using the docker file and set {% endhighlight %} -{% endtabs %} - @@ -868,8 +860,6 @@ To resolve this issue, we can install the chromium using the docker file and set To resolve this issue, we can add inline styles in element. However, we have attached the sample and output documents for your reference.

-{% tabs %} - {% highlight C# tabtitle="C#" %} HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -896,8 +886,6 @@ document.Close(true); {% endhighlight %} -{% endtabs %} - You can downloaded a complete working sample from GitHub. @@ -908,8 +896,6 @@ You can downloaded a complete working sample from @@ -940,14 +924,11 @@ settings.CommandLineArguments.Add("--single-process"); To overcome this issue by installing the Linux dependencies package in SSH window. Please refer the below commands and screenshot, -{% tabs %} - {% highlight C# %} apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -{% endtabs %}

Please refer to the below screenshot,

@@ -962,7 +943,7 @@ We can install the required dependencies using the dependencies vis shell script

Code example:

-{% tabs %} + {% highlight C# %} private static void InstallLinuxPackages(FileInfo functionAppDirectory) @@ -1005,7 +986,7 @@ We can install the required dependencies using the dependencies vis shell script } {% endhighlight %} -{% endtabs %} + @@ -1061,7 +1042,7 @@ Blink binaries (Version 109.0.5414.75), We can resolve the reported issue by using the FileStream within the "using" block. -{% tabs %} + {% highlight C# %} using (FileStream fs = new FileStream("path_to_file", FileMode.Open)) @@ -1070,12 +1051,12 @@ using (FileStream fs = new FileStream("path_to_file", FileMode.Open)) } // File stream is automatically closed and disposed {% endhighlight %} -{% endtabs %} + Or Dispose of the FileStream at the end of the process and ensure that the file or document is not already open in another application. -{% tabs %} + {% highlight C# %} PdfDocument document = htmlConverter.Convert("); @@ -1088,7 +1069,7 @@ document.Dispose(); fileStream.Dispose(); {% endhighlight %} -{% endtabs %} + @@ -1140,7 +1121,6 @@ The exception may occur while performing HTML to PDF conversion with docker and To overcome the exception by making the root files as executable. For making the root files as executable, you can find the code snippet below which will be added to your docker file. -{% tabs %} {% highlight C# %} USER root @@ -1148,7 +1128,7 @@ RUN chmod +x /app/runtimes/linux/native/chrome && \ chmod +x /app/runtimes/linux/native/chrome-wrapper {% endhighlight %} -{% endtabs %} +

Please refer to the below screenshot,

@@ -1180,13 +1160,12 @@ The issue occurs within Chromium specifically for Alpine. We can resolve this issue by adding command-line arguments to the Blink converter settings. Please refer to the code snippet below. -{% tabs %} {% highlight C# %} blinkConverterSettings.CommandLineArguments.Add("--disable-gpu"); {% endhighlight %} -{% endtabs %} + @@ -1214,7 +1193,6 @@ You can try the below solution steps to overcome the reported issue 'Failed to Step 1: Kindly try the below docker file changes in your sample to resolve the chrome_crashpad_handler issue.
-{% tabs %} {% highlight C# %} FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine @@ -1256,7 +1234,6 @@ USER guest ENTRYPOINT ["dotnet", "Ops.PDFSearch.Web.dll"] {% endhighlight %} -{% endtabs %} We have attached the modified docker file for your reference
Docker file.
@@ -1264,18 +1241,15 @@ Step 2: From chromium version 128.x.x.x.x -database flag required for chrome Cra Add below commands in Docker file:
-{% tabs %} {% highlight C# %} RUN mkdir -p /var/www/.config/google-chrome/Crashpad RUN chown -R www-data:www-data /var/www/.config {% endhighlight %} -{% endtabs %} Add below command-line arguments in conversion code
-{% tabs %} {% highlight C# %} if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) @@ -1290,7 +1264,6 @@ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) } {% endhighlight %} -{% endtabs %} Please refer the Chromium forum link. for more information about the reported issue @@ -1357,38 +1330,32 @@ To resolve the issue and ensure successful HTML to PDF conversion in Azure App S Provide read, write, and execute permissions for the chrome and chrome-wrapper files located in the runtimes/linux/native directory. Use the following commands: -{% tabs %} {% highlight C# %} chmod +rwx chrome-wrapper chmod +rwx chrome {% endhighlight %} -{% endtabs %} 2: Verify Chrome Dependency Packages
Check if the necessary dependencies for Chromium are installed by running the following command in the runtimes/linux/native directory: -{% tabs %} {% highlight C# %} ldd chrome {% endhighlight %} -{% endtabs %} 3: Install Required Dependencies
We can also perform HTML to PDF conversion in Azure App Service (Linux) by installing the required dependencies directly through SSH terminal. Use the following command: -{% tabs %} {% highlight C# %} apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -{% endtabs %} For more details to install the dependencies through SSH terminal window, refer to the documentation: Convert HTML to PDF in Azure App Service on Linux| Syncfusion @@ -1427,13 +1394,13 @@ Publish your application to the Azure App Service.
3.Configure Startup Command
After deployment, go to the Azure portal configuration for your app service.
In the Startup Command section, add:
-{% tabs %} + {% highlight C# %} /home/site/wwwroot/dependenciesInstall.sh && dotnet YourApplicationName.dll {% endhighlight %} -{% endtabs %} +
Runtime folder
@@ -1472,7 +1439,6 @@ After the service restarts, try the conversion or operation again to ensure the Update the dependency installation script to use t64 packages and omit libgconf-2-4. The following command installs the supported libraries on Ubuntu 24.04: -{% tabs %} {% highlight C# %} Run apt-get update && apt-get install -yq --no-install-recommends \ @@ -1483,7 +1449,6 @@ Run apt-get update && apt-get install -yq --no-install-recommends \ libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -{% endtabs %} After applying this change, all required dependencies are installed successfully. @@ -1513,7 +1478,7 @@ After applying this change, all required dependencies are installed successfully To ensure that the correct localized or culture-specific content appears in the generated PDF:
Set the required culture cookie explicitly using the Cookies property in BlinkConverterSettings before starting conversion.
Example for setting German culture:
-{% tabs %} + {% highlight C# %} HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1524,7 +1489,7 @@ htmlConverter.ConverterSettings = settings; PdfDocument doc = htmlConverter.Convert(url); {% endhighlight %} -{% endtabs %} + @@ -1536,17 +1501,14 @@ The problem is limited to Azure Functions with premium plans in Net 8.0 version. Prerequisites dependencies: -{% tabs %} {% highlight C# %} apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -{% endtabs %} N> We have option to exclude the default Blink binaries from the installation package. This will reduce the size of your deployment package in azure. Please refer to the code example below. -{% tabs %} {% highlight C# %} @@ -1556,7 +1518,6 @@ N> We have option to exclude the default Blink binaries from the installation pa {% endhighlight %} -{% endtabs %} ## How to Exclude BlinkBinaries or Runtime Files in Build or Deployment @@ -1569,7 +1530,6 @@ You can prevent runtime files from being included by restricting the package to Refer to the following package reference: -{% tabs %} {% highlight C# %} @@ -1579,7 +1539,6 @@ Refer to the following package reference: {% endhighlight %} -{% endtabs %} By using IncludeAssets="compile", only the required compile-time metadata is included, and all runtime dependencies (BlinkBinaries) are excluded from the final build or publish output. @@ -1590,13 +1549,11 @@ N> If you exclude runtime files, you must manually place BlinkBinaries on the se For .NET Framework applications, Blink runtime files are included through a .targets file referenced in the project. To exclude BlinkBinaries, simply remove this import entry. -{% tabs %} {% highlight C# %} {% endhighlight %} -{% endtabs %} Removing this line prevents the Syncfusion® build targets from copying BlinkBinaries and other runtime files into your bin folder during build or publish. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md index fe4838fbf1..7c0b7de60c 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md @@ -201,8 +201,6 @@ using Syncfusion.HtmlConverter; Step 4: Use the following code sample to convert the URL to PDF in the program.cs. -{% tabs %} - {% highlight c# tabtitle="C#" %} //Initialize HTML to PDF converter. @@ -222,8 +220,6 @@ document.Close(true); {% endhighlight %} -{% endtabs %} - By executing the program, you will get the PDF document as follows. htmltopdfoutput From fc9128932c9d122aa660fd5f2188e5c06389764c Mon Sep 17 00:00:00 2001 From: jeyalakshmit Date: Tue, 19 May 2026 16:26:25 +0530 Subject: [PATCH 07/14] 10278790-Address this UG issues --- .../PDF-Library/NET/Assemblies-Required.md | 58 +++++++++++---- .../NET/NuGet-Packages-Required.md | 72 +++++++++---------- ...pen-and-Save-PDF-file-in-C-Sharp-VB-NET.md | 4 +- .../PDF/PDF-Library/NET/Overview.md | 4 +- 4 files changed, 86 insertions(+), 52 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Assemblies-Required.md b/Document-Processing/PDF/PDF-Library/NET/Assemblies-Required.md index e73b1ac640..38e757a6bc 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Assemblies-Required.md +++ b/Document-Processing/PDF/PDF-Library/NET/Assemblies-Required.md @@ -44,15 +44,6 @@ The following assemblies need to be referenced in your application based on the Syncfusion.Pdf.UWP - - - {{'[Xamarin](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/create-pdf-file-in-xamarin)'| markdownify }} - - - Syncfusion.Pdf.Portable
- Syncfusion.Compression.Portable - - {{'[Blazor](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/create-pdf-document-in-blazor)'| markdownify }}, @@ -140,6 +131,15 @@ The following assemblies need to be referenced in your application based on the Syncfusion.Compression.Base + + + {{'[Xamarin](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/create-pdf-file-in-xamarin)'| markdownify }} + + + Syncfusion.Pdf.Portable
+ Syncfusion.Compression.Portable + + @@ -254,7 +254,7 @@ For converting a Word document to PDF, the following assemblies need to be refer - ASP.NET Core, Xamarin and Blazor + ASP.NET Core and Blazor Syncfusion.DocIO.Portable
Syncfusion.Compression.Portable
@@ -305,6 +305,18 @@ For converting a Word document to PDF, the following assemblies need to be refer Syncfusion.DocToPdfConverter.Base + + Xamarin + + Syncfusion.DocIO.Portable
+ Syncfusion.Compression.Portable
+ Syncfusion.OfficeChart.Portable
+ Syncfusion.Pdf.Portable
+ Syncfusion.DocIORenderer.Portable
+ SkiaSharp.HarfBuzz
+ Syncfusion.SkiaSharpHelper.Portable + + @@ -344,7 +356,7 @@ For converting an Excel document to PDF, the following assemblies need to be ref - UWP, .NET Core, Xamarin, and Blazor (Server-Side) + UWP, .NET Core, and Blazor (Server-Side) Syncfusion.Compression.Portable
Syncfusion.XlsIO.Portable
@@ -387,6 +399,16 @@ For converting an Excel document to PDF, the following assemblies need to be ref Syncfusion.ExcelToPDFConverter.Base + + Xamarin + + Syncfusion.Compression.Portable
+ Syncfusion.XlsIO.Portable
+ Syncfusion.Pdf.Portable
+ Syncfusion.SkiaSharpHelper.Portable
+ Syncfusion.XlsIORenderer.Portable + + @@ -413,7 +435,7 @@ For converting a PowerPoint Presentation to PDF, the following assemblies needed - ASP.NET Core, Xamarin, and Blazor + ASP.NET Core, and Blazor Syncfusion.Presentation.Portable
Syncfusion.Compression.Portable
@@ -480,6 +502,18 @@ The following assemblies are required to be referred in addition to the above me Syncfusion.PresentationToPDFConverter.Base + + Xamarin + + Syncfusion.Presentation.Portable
+ Syncfusion.Compression.Portable
+ Syncfusion.OfficeChart.Portable
+ Syncfusion.Pdf.Portable
+ Syncfusion.PresentationRenderer.Portable
+ Syncfusion.SkiaSharpHelper.Portable
+ SkiaSharp + + diff --git a/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md b/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md index 893b11ba72..eaa1af8554 100644 --- a/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md +++ b/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md @@ -63,14 +63,6 @@ Blazor -Xamarin - - -{{'[Syncfusion.Xamarin.Pdf.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.Pdf/)'| markdownify }} - - - - Windows UI (WinUI)
.NET Multi-platform App UI (.NET MAUI) @@ -98,6 +90,14 @@ Windows UI (WinUI)
{{'[Syncfusion.Pdf.AspNet.nupkg]( https://www.nuget.org/packages/Syncfusion.Pdf.AspNet/)'| markdownify }} + + + Xamarin + + + {{'[Syncfusion.Xamarin.Pdf.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.Pdf/)'| markdownify }} + + @@ -199,7 +199,7 @@ N> The HTML to PDF converter library internally uses the Blink rendering engine -(.NET Core, .NET 5, .NET 6 and .NET 8) Windows +Windows (.NET Core, NET 8.0, NET 9.0 and NET 10.0) {{'[Syncfusion.HtmlToPdfConverter.Net.Windows.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows/)'| markdownify }} @@ -207,7 +207,7 @@ N> The HTML to PDF converter library internally uses the Blink rendering engine -(.NET Core, .NET 5, .NET 6 and .NET 8) Linux +Linux (.NET Core, NET 8.0, NET 9.0, NET 10.0) {{'[Syncfusion.HtmlToPdfConverter.Net.Linux.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Linux/)'| markdownify }} @@ -215,7 +215,7 @@ N> The HTML to PDF converter library internally uses the Blink rendering engine -(.NET Core, .NET 5, .NET 6 and .NET 8) Mac +Mac (.NET Core, NET 8.0, NET 9.0, NET 10.0) {{'[Syncfusion.HtmlToPdfConverter.Net.Mac.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Mac/)'| markdownify }} @@ -223,7 +223,7 @@ N> The HTML to PDF converter library internally uses the Blink rendering engine -(.NET Core, .NET 5, .NET 6 and .NET 8) Aws +Aws (.NET Core, NET 8.0, NET 9.0, NET 10.0) {{'[Syncfusion.HtmlToPdfConverter.Net.Aws.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Aws/)'| markdownify }} @@ -404,14 +404,6 @@ Blazor {{'[Syncfusion.DocIORenderer.Net.Core.nupkg](https://www.nuget.org/packages/Syncfusion.DocIORenderer.Net.Core/)'| markdownify }} - - -Xamarin - - -{{'[Syncfusion.Xamarin.DocIORenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.DocIORenderer/)'| markdownify }} - - ### RETIRED PRODUCTS @@ -432,6 +424,14 @@ Xamarin {{'[Syncfusion.DocToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.DocToPDFConverter.AspNet/)'| markdownify }} + + + Xamarin + + + {{'[Syncfusion.Xamarin.DocIORenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.DocIORenderer/)'| markdownify }} + + @@ -483,14 +483,6 @@ Console Application (Targeting .NET Core) -Xamarin - - -{{'[Syncfusion.Xamarin.XlsIORenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.XlsIORenderer/)'| markdownify }} - - - - Blazor (Server-App) @@ -517,6 +509,14 @@ Blazor (Server-App) {{'[Syncfusion.ExcelToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.ExcelToPdfConverter.AspNet/)'| markdownify }} + + + Xamarin + + + {{'[Syncfusion.Xamarin.XlsIORenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.XlsIORenderer/)'| markdownify }} + + @@ -566,14 +566,6 @@ Blazor {{'[Syncfusion.PresentationRenderer.Net.Core.nupkg](https://www.nuget.org/packages/Syncfusion.PresentationRenderer.Net.Core/)'| markdownify }} - - -Xamarin - - -{{'[Syncfusion.Xamarin.PresentationRenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.PresentationRenderer/)'| markdownify }} - - ### RETIRED PRODUCTS @@ -594,6 +586,14 @@ Xamarin {{'[Syncfusion.PresentationToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.PresentationToPdfConverter.AspNet/)'| markdownify }} + + + Xamarin + + + {{'[Syncfusion.Xamarin.PresentationRenderer.nupkg](https://www.nuget.org/packages/Syncfusion.Xamarin.PresentationRenderer/)'| markdownify }} + + diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md b/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md index 4a6e11cae0..489c463dc6 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md @@ -392,13 +392,13 @@ You can also resave the manipulated PDF document to the same file using overload {% tabs %} -{% highlight c# tabtitle="ASP.NET Core" %} +{% highlight c# tabtitle="C# [Cross-platform]" %} //PDF doesn't supports saving a PDF document into the same file on the C#/.NET Cross platforms. {% endhighlight %} -{% highlight c# tabtitle="C#" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} //Load an existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); diff --git a/Document-Processing/PDF/PDF-Library/NET/Overview.md b/Document-Processing/PDF/PDF-Library/NET/Overview.md index 55d5c7bf6b..1c8236106b 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Overview.md +++ b/Document-Processing/PDF/PDF-Library/NET/Overview.md @@ -8,7 +8,7 @@ documentation: UG # Overview of PDF Framework -The PDF framework is a feature rich [.NET PDF class library](https://www.syncfusion.com/document-sdk/net-pdf-library) developed with 100% managed C# code that can be used to create, read and write PDF. The library can be used in [Windows Forms](https://www.syncfusion.com/document-sdk/net-pdf-library), [WPF](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET Web Forms](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET MVC](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET Core](https://www.syncfusion.com/document-sdk/net-pdf-library), [Blazor](https://www.syncfusion.com/document-sdk/net-pdf-library), [UWP](https://www.syncfusion.com/document-sdk/net-pdf-library), [Xamarin](https://www.syncfusion.com/document-sdk/net-pdf-library), [Flutter](https://www.syncfusion.com/document-sdk/flutter-pdf-library), [WinUI](https://www.syncfusion.com/document-sdk/net-pdf-library) and [.NET MAUI](https://www.syncfusion.com/document-sdk/net-pdf-library) applications and Unity platform without the dependency of Adobe Acrobat. The creation of PDF follows the most popular PDF 1.7 (ISO 32000-1) and latest PDF 2.0 (ISO 32000-2) specifications. +The PDF framework is a feature rich [.NET PDF class library](https://www.syncfusion.com/document-sdk/net-pdf-library) developed with 100% managed C# code that can be used to create, read and write PDF. The library can be used in [Windows Forms](https://www.syncfusion.com/document-sdk/net-pdf-library), [WPF](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET Web Forms](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET MVC](https://www.syncfusion.com/document-sdk/net-pdf-library), [ASP.NET Core](https://www.syncfusion.com/document-sdk/net-pdf-library), [Blazor](https://www.syncfusion.com/document-sdk/net-pdf-library), [UWP](https://www.syncfusion.com/document-sdk/net-pdf-library), [Flutter](https://www.syncfusion.com/document-sdk/flutter-pdf-library), [WinUI](https://www.syncfusion.com/document-sdk/net-pdf-library) and [.NET MAUI](https://www.syncfusion.com/document-sdk/net-pdf-library) applications and Unity platform without the dependency of Adobe Acrobat. The creation of PDF follows the most popular PDF 1.7 (ISO 32000-1) and latest PDF 2.0 (ISO 32000-2) specifications. ## Key Features of Essential® PDF @@ -35,7 +35,7 @@ The following list shows the key features available in the Essential® Date: Tue, 19 May 2026 17:48:01 +0530 Subject: [PATCH 08/14] 1027879-alignment issue --- ...pen-and-Save-PDF-file-in-C-Sharp-VB-NET.md | 25 +-- .../NET/Open-pdf-files/From-AWS-S3.md | 42 ++-- .../Open-pdf-files/From-azure-blob-storage.md | 32 +-- .../From-dropbox-cloud-file-storage.md | 38 ++-- .../From-google-cloud-storage.md | 38 ++-- .../NET/Open-pdf-files/From-google-drive.md | 94 ++++----- .../PDF-Library/NET/Working-with-Document.md | 186 +++++++++--------- .../NET/Working-with-Watermarks.md | 116 +++++------ 8 files changed, 282 insertions(+), 289 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md b/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md index 489c463dc6..f4adec2e08 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-and-Save-PDF-file-in-C-Sharp-VB-NET.md @@ -41,8 +41,7 @@ You can open an existing PDF document by using the [PdfLoadedDocument](https://h {% highlight c# tabtitle="C# [Cross-platform]" %} //Open an existing PDF document from stream through constructor of `PdfLoadedDocument` class. -FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf"); {% endhighlight %} @@ -129,9 +128,8 @@ You can open an existing encrypted PDF document from either the file system or t {% highlight c# tabtitle="C# [Cross-platform]" %} -//Open an encrypted PDF document from stream through constructor of `PdfLoadedDocument` class. -FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream, "password"); +//Open an encrypted PDF document from stream through constructor of `PdfLoadedDocument` class. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf", "password"); {% endhighlight %} @@ -210,9 +208,8 @@ You can open a corrupted PDF document from either the file system or the stream {% highlight c# tabtitle="C# [Cross-platform]" %} -//Open an existing corrupted PDF document from stream through constructor of `PdfLoadedDocument` class. -FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream, true); +//Open an existing corrupted PDF document from stream through constructor of `PdfLoadedDocument` class. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf", true); {% endhighlight %} @@ -295,8 +292,7 @@ You can save the manipulated PDF document to file system using [Save](https://he {% highlight c# tabtitle="C# [Cross-platform]" %} //Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //To-Do some manipulation //To-Do some manipulation //Save the PDF document into stream. @@ -463,8 +459,7 @@ After the document manipulation and save operation are completed, you should clo {% highlight c# tabtitle="C# [Cross-platform]" %} //Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //To-Do some manipulation //To-Do some manipulation //Save the document into stream. @@ -515,12 +510,11 @@ You can catch the secured document exception by opening an existing encrypted PD {% highlight c# tabtitle="C# [Cross-platform]" %} //Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); PdfLoadedDocument document = null; try { //Open an existing PDF document from a stream. - document = new PdfLoadedDocument(docStream, "password"); + document = new PdfLoadedDocument("Input.pdf", "password"); } catch (Syncfusion.Pdf.PdfInvalidPasswordException exception) { @@ -590,12 +584,11 @@ II. Please find some of the possible offset error messages that may be repairab {% highlight c# tabtitle="C# [Cross-platform]" %} //Load a PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); PdfLoadedDocument document = null; try { //Open an existing PDF document from the stream. - document = new PdfLoadedDocument(docStream, true); + document = new PdfLoadedDocument("Input.pdf", true); } catch (PdfException exception) { diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md index c13f680755..cbf749d735 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md @@ -25,9 +25,9 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Amazon; - using Amazon.S3; - using Amazon.S3.Transfer; +using Amazon; +using Amazon.S3; +using Amazon.S3.Transfer; {% endhighlight %} @@ -40,25 +40,25 @@ Step 5: Add the below code example to load a PDF from AWS S3. {% highlight c# tabtitle="C# [Cross-platform]" %} - // Set your AWS credentials and region - string accessKey = "YOUR_ACCESS_KEY"; - string secretKey = "YOUR_SECRET_KEY"; - RegionEndpoint region = RegionEndpoint.YOUR_REGION; // Change to your desired region - - // Specify the bucket name and object key - string bucketName = "YOUR_BUCKET_NAME"; - string objectKey = "YOUR_OBJECT_KEY"; - - string localFilePath = "Output.pdf"; - // Download the PDF from S3 - //MemoryStream pdfStream = DownloadFromS3(accessKey, secretKey, region, bucketName, objectKey); - using (var s3Client = new AmazonS3Client(accessKey, secretKey, region)) - { - using (var transferUtility = new TransferUtility(s3Client)) - { - transferUtility.Download(localFilePath, bucketName, objectKey); - } +// Set your AWS credentials and region +string accessKey = "YOUR_ACCESS_KEY"; +string secretKey = "YOUR_SECRET_KEY"; +RegionEndpoint region = RegionEndpoint.YOUR_REGION; // Change to your desired region + +// Specify the bucket name and object key +string bucketName = "YOUR_BUCKET_NAME"; +string objectKey = "YOUR_OBJECT_KEY"; + +string localFilePath = "Output.pdf"; +// Download the PDF from S3 +//MemoryStream pdfStream = DownloadFromS3(accessKey, secretKey, region, bucketName, objectKey); +using (var s3Client = new AmazonS3Client(accessKey, secretKey, region)) +{ + using (var transferUtility = new TransferUtility(s3Client)) + { + transferUtility.Download(localFilePath, bucketName, objectKey); } +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md index cdcf6c0daf..fa0d0e3348 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md @@ -25,8 +25,8 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Microsoft.Azure.Storage; - using Microsoft.Azure.Storage.Blob; +using Microsoft.Azure.Storage; +using Microsoft.Azure.Storage.Blob; {% endhighlight %} @@ -39,24 +39,24 @@ Step 5: Add the below code example to load a PDF from Azure blob storage. {% highlight c# tabtitle="C# [Cross-platform]" %} - // Parse the connection string to your Azure Storage Account. - CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); +// Parse the connection string to your Azure Storage Account. +CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); - // Create a client to interact with Blob storage. - CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); +// Create a client to interact with Blob storage. +CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); - // Get a reference to the container name. - CloudBlobContainer container = blobClient.GetContainerReference(containerName); +// Get a reference to the container name. +CloudBlobContainer container = blobClient.GetContainerReference(containerName); - // Get a reference to the block blob name. - CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName); +// Get a reference to the block blob name. +CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName); - // Open a file stream to save the downloaded blob content. - using (var fileStream = File.OpenWrite("sample.pdf")) - { - // Download the blob's content to the file stream. - blockBlob.DownloadToStream(fileStream); - } +// Open a file stream to save the downloaded blob content. +using (var fileStream = File.OpenWrite("sample.pdf")) +{ + // Download the blob's content to the file stream. + blockBlob.DownloadToStream(fileStream); +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md index 4fe84327c9..1b4bcf9f9a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md @@ -29,7 +29,7 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Dropbox.Api; +using Dropbox.Api; {% endhighlight %} @@ -42,29 +42,29 @@ Step 5: Add the below code example to load a PDF ifrom Dropbox cloud file storag {% highlight c# tabtitle="C# [Cross-platform]" %} - // Define the access token for authentication with the Dropbox API - var accessToken = "YOUR_ACCESS_TOKEN";// Replace with your actual access token +// Define the access token for authentication with the Dropbox API +var accessToken = "YOUR_ACCESS_TOKEN";// Replace with your actual access token - // Define the file path in Dropbox where the PDF file is located - var filePathInDropbox = "/path/to/save/Sample.pdf"; // Replace with the actual file path in Dropbox - // Create a new DropboxClient instance using the provided access token - using (var dbx = new DropboxClient(accessToken)) +// Define the file path in Dropbox where the PDF file is located +var filePathInDropbox = "/path/to/save/Sample.pdf"; // Replace with the actual file path in Dropbox +// Create a new DropboxClient instance using the provided access token +using (var dbx = new DropboxClient(accessToken)) +{ + // Start a download request for the specified file in Dropbox + using (var response = await dbx.Files.DownloadAsync(filePathInDropbox)) { - // Start a download request for the specified file in Dropbox - using (var response = await dbx.Files.DownloadAsync(filePathInDropbox)) + // Get the content of the downloaded file as a stream + var content = await response.GetContentAsStreamAsync(); + // Create a new file stream to save the downloaded content locally + using (var fileStream = File.Create("Output.pdf")) { - // Get the content of the downloaded file as a stream - var content = await response.GetContentAsStreamAsync(); - // Create a new file stream to save the downloaded content locally - using (var fileStream = File.Create("Output.pdf")) - { - // Copy the content stream to the file stream - content.CopyTo(fileStream); - // Close the file stream once the content is copied - fileStream.Close(); - } + // Copy the content stream to the file stream + content.CopyTo(fileStream); + // Close the file stream once the content is copied + fileStream.Close(); } } +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-cloud-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-cloud-storage.md index 9c93ae3720..3ee760331d 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-cloud-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-cloud-storage.md @@ -25,8 +25,8 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Google.Cloud.Storage.V1; - using Google.Apis.Auth.OAuth2; +using Google.Cloud.Storage.V1; +using Google.Apis.Auth.OAuth2; {% endhighlight %} @@ -39,23 +39,23 @@ Step 5: Add the below code example to create a simple PDF and save in Google clo {% highlight c# tabtitle="C# [Cross-platform]" %} - // Create a byte array - byte[] pdfBytes; - // Load the credentials file - GoogleCredential credential = GoogleCredential.FromFile("credentials.json"); - // Create a storage client - StorageClient storage = StorageClient.Create(credential); - // Download the PDF from Google Cloud Storage - using (MemoryStream stream = new MemoryStream()) - { - storage.DownloadObject("bucket50247", "Sample.pdf", stream); - pdfBytes = stream.ToArray(); - } - - string filePath = "Sample.pdf"; - - // Write the byte array to a PDF file - File.WriteAllBytes(filePath, pdfBytes); +// Create a byte array +byte[] pdfBytes; +// Load the credentials file +GoogleCredential credential = GoogleCredential.FromFile("credentials.json"); +// Create a storage client +StorageClient storage = StorageClient.Create(credential); +// Download the PDF from Google Cloud Storage +using (MemoryStream stream = new MemoryStream()) +{ + storage.DownloadObject("bucket50247", "Sample.pdf", stream); + pdfBytes = stream.ToArray(); +} + +string filePath = "Sample.pdf"; + +// Write the byte array to a PDF file +File.WriteAllBytes(filePath, pdfBytes); {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-drive.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-drive.md index c41da91251..1c1ca7b0f4 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-drive.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-google-drive.md @@ -28,10 +28,10 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Google.Apis.Auth.OAuth2; - using Google.Apis.Drive.v3; - using Google.Apis.Services; - using Google.Apis.Util.Store; +using Google.Apis.Auth.OAuth2; +using Google.Apis.Drive.v3; +using Google.Apis.Services; +using Google.Apis.Util.Store; {% endhighlight %} @@ -44,49 +44,49 @@ Step 5: Add the below code example to open a PDF from google drive. {% highlight c# tabtitle="C# [Cross-platform]" %} - UserCredential credential; - string[] Scopes = { DriveService.Scope.DriveReadonly }; - string ApplicationName = "YourAppName"; - - using (var stream1 = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) - { - string credPath = "token.json"; - credential = GoogleWebAuthorizationBroker.AuthorizeAsync( - GoogleClientSecrets.Load(stream1).Secrets, - Scopes, - "user", - CancellationToken.None, - new FileDataStore(credPath, true)).Result; - } - - // Step 2: Create Drive API service - var service = new DriveService(new BaseClientService.Initializer() - { - HttpClientInitializer = credential, - ApplicationName = ApplicationName, - }); - - // Step 3: Specify the file ID of the PDF you want to open - string fileId = "YOUR_FILE_ID"; // Replace with the actual file ID YOUR_FILE_ID - - // Step 4: Download the PDF file from Google Drive - var request = service.Files.Get(fileId); - var stream = new MemoryStream(); - request.Download(stream); - - // Step 5: Open the PDF with Syncfusion - //PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream); - - // Use the loadedDocument for further processing (e.g., extracting text or images) - - // Remember to dispose of the loadedDocument when you're done - //loadedDocument.Close(true); - - // Step 5: Save the PDF locally - using (FileStream fileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) - { - stream.WriteTo(fileStream); - } +UserCredential credential; +string[] Scopes = { DriveService.Scope.DriveReadonly }; +string ApplicationName = "YourAppName"; + +using (var stream1 = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) +{ + string credPath = "token.json"; + credential = GoogleWebAuthorizationBroker.AuthorizeAsync( + GoogleClientSecrets.Load(stream1).Secrets, + Scopes, + "user", + CancellationToken.None, + new FileDataStore(credPath, true)).Result; +} + +// Step 2: Create Drive API service +var service = new DriveService(new BaseClientService.Initializer() +{ + HttpClientInitializer = credential, + ApplicationName = ApplicationName, +}); + +// Step 3: Specify the file ID of the PDF you want to open +string fileId = "YOUR_FILE_ID"; // Replace with the actual file ID YOUR_FILE_ID + +// Step 4: Download the PDF file from Google Drive +var request = service.Files.Get(fileId); +var stream = new MemoryStream(); +request.Download(stream); + +// Step 5: Open the PDF with Syncfusion +//PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream); + +// Use the loadedDocument for further processing (e.g., extracting text or images) + +// Remember to dispose of the loadedDocument when you're done +//loadedDocument.Close(true); + +// Step 5: Save the PDF locally +using (FileStream fileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) +{ + stream.WriteTo(fileStream); +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Document.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Document.md index 75759e9e75..fd52cca7e7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Document.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Document.md @@ -1657,118 +1657,118 @@ Essential® PDF enables you to track the save progress through the {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/PDF%20Document/Create-a-PDF-document-with-save-progress/.NET/PDF-document-with-save-progress/Program.cs" %} - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf; - using Syncfusion.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using Syncfusion.Drawing; - // Create a new PDF document. - PdfDocument document = new PdfDocument(); +// Create a new PDF document. +PdfDocument document = new PdfDocument(); - // Add multiple pages to the document. - for (int i = 0; i < 10; i++) - { - // Add a new page. - PdfPage page = document.Pages.Add(); +// Add multiple pages to the document. +for (int i = 0; i < 10; i++) +{ + // Add a new page. + PdfPage page = document.Pages.Add(); - // Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; + // Create PDF graphics for the page. + PdfGraphics graphics = page.Graphics; - // Set the font to Helvetica with size 20. - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); + // Set the font to Helvetica with size 20. + PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); - // Draw text on the page. - graphics.DrawString($"This is page {i + 1}", font, PdfBrushes.Black, new PointF(0, 0)); - } + // Draw text on the page. + graphics.DrawString($"This is page {i + 1}", font, PdfBrushes.Black, new PointF(0, 0)); +} - // Subscribe to the SaveProgress event. - document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress); +// Subscribe to the SaveProgress event. +document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress); - //Save the document. - document.Save("Output.pdf"); - // Close the document. - document.Close(true); +//Save the document. +document.Save("Output.pdf"); +// Close the document. +document.Close(true); - // Event handler for the SaveProgress event. - void document_SaveProgress(object sender, ProgressEventArgs arguments) - { - // Output the current progress of the save operation. - Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)); - } +// Event handler for the SaveProgress event. +void document_SaveProgress(object sender, ProgressEventArgs arguments) +{ + // Output the current progress of the save operation. + Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)); +} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf; - using System.Drawing; - - // Create a new PDF document. - PdfDocument document = new PdfDocument(); - // Add multiple pages to the document. - for (int i = 0; i < 10; i++) - { - // Add a new page. - PdfPage page = document.Pages.Add(); - // Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; - // Set the font to Helvetica with size 20. - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); - // Draw text on the page. - graphics.DrawString($"This is page {i + 1}", font, PdfBrushes.Black, new PointF(0, 0)); - } - // Subscribe to the SaveProgress event. - document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress); - //Save the document. - document.Save("Output.pdf"); - // Close the document. - document.Close(true); - - // Event handler for the SaveProgress event. - void document_SaveProgress(object sender, ProgressEventArgs arguments) - { - // Output the current progress of the save operation. - Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)); - } +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using System.Drawing; + +// Create a new PDF document. +PdfDocument document = new PdfDocument(); +// Add multiple pages to the document. +for (int i = 0; i < 10; i++) +{ + // Add a new page. + PdfPage page = document.Pages.Add(); + // Create PDF graphics for the page. + PdfGraphics graphics = page.Graphics; + // Set the font to Helvetica with size 20. + PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); + // Draw text on the page. + graphics.DrawString($"This is page {i + 1}", font, PdfBrushes.Black, new PointF(0, 0)); +} +// Subscribe to the SaveProgress event. +document.SaveProgress += new PdfDocument.ProgressEventHandler(document_SaveProgress); +//Save the document. +document.Save("Output.pdf"); +// Close the document. +document.Close(true); + +// Event handler for the SaveProgress event. +void document_SaveProgress(object sender, ProgressEventArgs arguments) +{ + // Output the current progress of the save operation. + Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} - Imports Syncfusion.Pdf.Graphics - Imports Syncfusion.Pdf - Imports Syncfusion.Drawing - - Module Program - Sub Main() - ' Create a new PDF document. - Dim document As New PdfDocument() - ' Add multiple pages to the document. - For i As Integer = 0 To 9 - ' Add a new page. - Dim page As PdfPage = document.Pages.Add() - ' Create PDF graphics for the page. - Dim graphics As PdfGraphics = page.Graphics - ' Set the font to Helvetica with size 20. - Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20) - ' Draw text on the page. - graphics.DrawString(String.Format("This is page {0}", i + 1), font, PdfBrushes.Black, New PointF(0, 0)) - Next - ' Subscribe to the SaveProgress event. - AddHandler document.SaveProgress, AddressOf document_SaveProgress - ' Save the document. - document.Save("Output.pdf") - ' Close the document. - document.Close(True) - End Sub - - ' Event handler for the SaveProgress event. - Private Sub document_SaveProgress(ByVal sender As Object, ByVal arguments As ProgressEventArgs) - ' Output the current progress of the save operation. - Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)) - End Sub - End Module +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf +Imports Syncfusion.Drawing + +Module Program + Sub Main() + ' Create a new PDF document. + Dim document As New PdfDocument() + ' Add multiple pages to the document. + For i As Integer = 0 To 9 + ' Add a new page. + Dim page As PdfPage = document.Pages.Add() + ' Create PDF graphics for the page. + Dim graphics As PdfGraphics = page.Graphics + ' Set the font to Helvetica with size 20. + Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20) + ' Draw text on the page. + graphics.DrawString(String.Format("This is page {0}", i + 1), font, PdfBrushes.Black, New PointF(0, 0)) + Next + ' Subscribe to the SaveProgress event. + AddHandler document.SaveProgress, AddressOf document_SaveProgress + ' Save the document. + document.Save("Output.pdf") + ' Close the document. + document.Close(True) + End Sub + + ' Event handler for the SaveProgress event. + Private Sub document_SaveProgress(ByVal sender As Object, ByVal arguments As ProgressEventArgs) + ' Output the current progress of the save operation. + Console.WriteLine(String.Format("Current: {0}, Progress: {1}, Total: {2}", arguments.Current, arguments.Progress, arguments.Total)) + End Sub +End Module {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Watermarks.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Watermarks.md index f88bc1253c..cabf5d42e5 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Watermarks.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Watermarks.md @@ -492,84 +492,84 @@ You can remove the Watermark annotation from the annotation collection, represen {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Watermark/Removing-watermark-annotation-in-PDF-document/.NET/Remove-watermark-annotation-in-the-PDF-document/Program.cs" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf.Parsing; - - //Load the PDF document - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); - // Iterate through the annotations collection and remove PdfLoadedWatermark annotations - foreach (PdfPageBase page in loadedDocument.Pages) +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + +//Load the PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +//Iterate through the annotations collection and remove PdfLoadedWatermark annotations +foreach (PdfPageBase page in loadedDocument.Pages) +{ + for (int i = page.Annotations.Count - 1; i >= 0; i--) { - for (int i = page.Annotations.Count - 1; i >= 0; i--) + // Check if the annotation is a PdfLoadedWatermarkAnnotation + if (page.Annotations[i] is PdfLoadedWatermarkAnnotation) { - // Check if the annotation is a PdfLoadedWatermarkAnnotation - if (page.Annotations[i] is PdfLoadedWatermarkAnnotation) - { - // Remove the PdfLoadedWatermarkAnnotation - page.Annotations.RemoveAt(i); - } + // Remove the PdfLoadedWatermarkAnnotation + page.Annotations.RemoveAt(i); } } +} - //Saves the document to disk. - loadedDocument.Save("WatermarkAnnotation.pdf"); - loadedDocument.Close(true); +//Saves the document to disk. +loadedDocument.Save("WatermarkAnnotation.pdf"); +loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; - //Load the existing PDF document - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); - // Iterate through the annotations collection and remove PdfLoadedWatermark annotations - foreach (PdfPageBase page in loadedDocument.Pages) +//Load the existing PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); +// Iterate through the annotations collection and remove PdfLoadedWatermark annotations +foreach (PdfPageBase page in loadedDocument.Pages) +{ + for (int i = page.Annotations.Count - 1; i >= 0; i--) { - for (int i = page.Annotations.Count - 1; i >= 0; i--) + // Check if the annotation is a PdfLoadedWatermarkAnnotation + if (page.Annotations[i] is PdfLoadedWatermarkAnnotation) { - // Check if the annotation is a PdfLoadedWatermarkAnnotation - if (page.Annotations[i] is PdfLoadedWatermarkAnnotation) - { - // Remove the PdfLoadedWatermarkAnnotation - page.Annotations.RemoveAt(i); - } + // Remove the PdfLoadedWatermarkAnnotation + page.Annotations.RemoveAt(i); } - } + } +} - //Saves the document to disk. - loadedDocument.Save("WatermarkAnnotation.pdf"); - loadedDocument.Close(true); +//Saves the document to disk. +loadedDocument.Save("WatermarkAnnotation.pdf"); +loadedDocument.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} - Imports Syncfusion.Pdf - Imports Syncfusion.Pdf.Graphics - Imports Syncfusion.Pdf.Parsing - - 'Load the existing PDF document - Dim loadedDocument As New PdfLoadedDocument("input.pdf") - ' Iterate through the annotations collection and remove PdfLoadedWatermark annotations - For Each page As PdfPageBase In loadedDocument.Pages - Dim i As Integer = page.Annotations.Count - 1 - While i >= 0 - ' Check if the annotation is a PdfLoadedWatermarkAnnotation - If TypeOf page.Annotations(i) Is PdfLoadedWatermarkAnnotation Then - ' Remove the PdfLoadedWatermarkAnnotation - page.Annotations.RemoveAt(i) - End If - i -= 1 - End While - Next - - 'Saves the document to disk. - loadedDocument.Save("WatermarkAnnotation.pdf") - loadedDocument.Close(True) +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + +'Load the existing PDF document +Dim loadedDocument As New PdfLoadedDocument("input.pdf") +'Iterate through the annotations collection and remove PdfLoadedWatermark annotations +For Each page As PdfPageBase In loadedDocument.Pages + Dim i As Integer = page.Annotations.Count - 1 + While i >= 0 + 'Check if the annotation is a PdfLoadedWatermarkAnnotation + If TypeOf page.Annotations(i) Is PdfLoadedWatermarkAnnotation Then + 'Remove the PdfLoadedWatermarkAnnotation + page.Annotations.RemoveAt(i) + End If + i -= 1 + End While +Next + +'Saves the document to disk. +loadedDocument.Save("WatermarkAnnotation.pdf") +loadedDocument.Close(True) {% endhighlight %} From dfbdcb9fb6c1bcdcefea6184e9dee2b743d3e300 Mon Sep 17 00:00:00 2001 From: jeyalakshmit Date: Wed, 20 May 2026 18:51:09 +0530 Subject: [PATCH 09/14] 1027879-ug modification --- .../Data-Extraction/OCR/NET/overview.md | 2 +- .../HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 2 +- .../PDF/Conversions/HTML-To-PDF/overview.md | 2 +- .../PDF-Library/NET/Converting-XPS-to-PDF.md | 10 +- .../NET/Create-PDF-file-in-ASP-NET-Core.md | 4 +- .../PDF/PDF-Library/NET/Merge-Documents.md | 61 +++---- .../PDF/PDF-Library/NET/PdfLightTable.md | 74 +++----- .../NET/Working-with-Attachments.md | 168 ++++++++---------- .../PDF-Library/NET/Working-with-Bookmarks.md | 52 +++--- .../PDF-Library/NET/Working-with-Brushes.md | 36 ++-- .../NET/Working-with-Compression.md | 70 ++------ 11 files changed, 176 insertions(+), 305 deletions(-) diff --git a/Document-Processing/Data-Extraction/OCR/NET/overview.md b/Document-Processing/Data-Extraction/OCR/NET/overview.md index fa050f0c11..bf3739533d 100644 --- a/Document-Processing/Data-Extraction/OCR/NET/overview.md +++ b/Document-Processing/Data-Extraction/OCR/NET/overview.md @@ -43,5 +43,5 @@ N> Starting with v20.1.0.x, if you reference Syncfusion® OCR proc * Image into searchable PDF or PDF/A. * Improved accessibility. * Post-processing. -* Compatible with .NET Framework 4.5 and above. +* Compatible with .NET Framework 4.6.2 and above. * Compatible with .NET Core 2.0 and above. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md index b07c9fa654..8df6da9415 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md @@ -7,7 +7,7 @@ documentation: UG --- # Converting HTML to PDF -The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. +The [HTML to PDF converter](https://www.syncfusion.com/document-sdk/net-pdf-library/html-to-pdf) is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. Syncfusion® HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md index 5381b8a25b..fe4838fbf1 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md @@ -7,7 +7,7 @@ documentation: UG --- # Converting HTML to PDF -The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. +The [HTML to PDF converter](https://www.syncfusion.com/document-sdk/net-pdf-library/html-to-pdf) is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. Syncfusion® HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS. diff --git a/Document-Processing/PDF/PDF-Library/NET/Converting-XPS-to-PDF.md b/Document-Processing/PDF/PDF-Library/NET/Converting-XPS-to-PDF.md index bf10f7888a..eda70131f9 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Converting-XPS-to-PDF.md +++ b/Document-Processing/PDF/PDF-Library/NET/Converting-XPS-to-PDF.md @@ -17,15 +17,11 @@ The following code example illustrates how to converting XPS document to PDF usi //Initialize XPS to PDF converter. XPSToPdfConverter converter = new XPSToPdfConverter(); -//Open the XPS file as stream. -FileStream fileStream = new FileStream("Input.xps", FileMode.Open, FileAccess.ReadWrite); //Convert the XPS to PDF. -PdfDocument document = converter.Convert(fileStream); +PdfDocument document = converter.Convert("Input.xps"); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the documents. document.Close(true); diff --git a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-ASP-NET-Core.md b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-ASP-NET-Core.md index 5c9759f729..0ac065ccc5 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-ASP-NET-Core.md +++ b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-ASP-NET-Core.md @@ -9,9 +9,9 @@ keywords: .net core create pdf, edit pdf, merge, pdf form, fill form, digital si # Create or Generate PDF file in ASP.NET Core -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 merge, split, stamp, forms, and secure PDF files. +The Syncfusion® [.NET PDF library](https://www.syncfusion.com/document-sdk/net-pdf-library) is a powerful and versatile solution for creating, reading, and editing PDF documents in .NET applications. It also provides advanced features such as merging and splitting PDFs, adding stamps, working with form fields, and securing PDF files with encryption and permissions. -To include the .NET Core PDF library into your ASP.NET Core application, please refer to the [NuGet Package Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/nuget-packages-required) or [Assemblies Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/assemblies-required) documentation. +To integrate the .NET PDF library into your ASP.NET Core application, refer to the official documentation sections on [NuGet Package Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/nuget-packages-required) or [Assemblies Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/assemblies-required) for step-by-step guidance. N> Beginning with our Volume 2, 2023 release, we have eliminated the dependency on the System.Drawing.Common package from our Syncfusion.Pdf.Imaging.Net.Core package. Instead, we have introduced SkiaSharp as the alternative library. diff --git a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md index b9b62d8608..10d2ea3ef7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md +++ b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md @@ -29,9 +29,8 @@ string[] source = { "file1.pdf", "file2.pdf" }; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); @@ -85,9 +84,8 @@ Stream[] streams = { stream1, stream2 }; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, streams); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); //Disposes the streams. @@ -147,17 +145,14 @@ Essential® PDF provides support for importing the pages from one {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Importing-pages-from-one-document-another-document/.NET/Importing-pages-from-one-document-another-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Create a new document. PdfDocument document = new PdfDocument(); //Imports the page at 1 from the lDoc. document.ImportPage(lDoc, 1); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); lDoc.Close(true); @@ -208,17 +203,14 @@ You can import multiple pages from an existing document by using [ImportPageRang {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Import-multiple-pages-from-an-existing-PDF/.NET/Import-multiple-pages-from-an-existing-PDF/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Create a new document. PdfDocument document = new PdfDocument(); //Imports the page at 1 from the lDoc. document.ImportPageRange(lDoc, 0, lDoc.Pages.Count - 1); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); lDoc.Close(true); @@ -269,22 +261,17 @@ You can also import pages from multiple documents and arrange the pages by using {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Import-pages-from-multiple-documents-and-arrange-pages/.NET/Import-pages-from-multiple-documents-and-arrange-pages/Program.cs" %} //Load the PDF document. -FileStream docStream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream1); -//Load the PDF document. -FileStream docStream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); +PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Load the PDF document. -PdfLoadedDocument lDoc2 = new PdfLoadedDocument(docStream2); +PdfLoadedDocument lDoc2 = new PdfLoadedDocument("file2.pdf"); //Create the new document. PdfDocument document = new PdfDocument(); //Imports and arranges the pages. document.ImportPage(lDoc, 1); document.ImportPage(lDoc2, 0); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the documents. document.Close(true); lDoc.Close(true); @@ -392,9 +379,8 @@ string[] source = { "file1.pdf", "file2.pdf" }; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); @@ -454,9 +440,8 @@ mergeOptions.OptimizeResources = true; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, mergeOptions, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("output.pdf"); //Close the document. finalDoc.Close(true); @@ -529,9 +514,8 @@ mergeOptions.ExtendMargin = true; //Merge PDFDocument. PdfDocumentBase.Merge(finalDoc, mergeOptions, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); @@ -609,9 +593,8 @@ PdfMergeOptions mergeOptions = new PdfMergeOptions(); mergeOptions.MergeAccessibilityTags = true; //Merge PDFDocument. PdfDocumentBase.Merge(finalDoc, mergeOptions, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the document. +finalDoc.Save("Output.pdf"); //Close the document. finalDoc.Close(true); diff --git a/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md b/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md index f3f4f628bf..2f5cd0f043 100644 --- a/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md +++ b/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md @@ -42,10 +42,8 @@ pdfLightTable.DataSource = table; //Draw PdfLightTable. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(0, 0)); -//Create the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -144,10 +142,8 @@ pdfLightTable.Rows.Add(new object[] { "111", "Maxim", "III" }); //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -225,10 +221,8 @@ Create a table using the [PdfLightTable](https://help.syncfusion.com/cr/document {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Creating-the-table-in-an-existing-PDF-document/.NET/Creating-the-table-in-an-existing-PDF-document/Program.cs" %} -//Get stream from an existing PDF document. -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); //Load the PDF document. -PdfLoadedDocument doc = new PdfLoadedDocument(docStream); +PdfLoadedDocument doc = new PdfLoadedDocument("input.pdf"); //Get the first page from the document PdfLoadedPage page = doc.Pages[0] as PdfLoadedPage; //Create PDF graphics for the page @@ -248,10 +242,8 @@ pdfLightTable.DataSource = table; //Draw PdfLightTable. pdfLightTable.Draw(graphics, new Syncfusion.Drawing.PointF(0, 0)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -365,10 +357,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -498,10 +488,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -657,10 +645,8 @@ pdfLightTable.EndRowLayout += pdfLightTable_EndRowLayout; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Create the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to the stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -847,10 +833,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to the stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -983,10 +967,8 @@ pdfLightTable.Style = lightTableStyle; //Draw PdfLightTable. pdfLightTable.Draw(page, new PointF(0, 0)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the document. document.Close(true); {% endhighlight %} @@ -1125,10 +1107,8 @@ pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable4Accent2); //Draw the grid to the page of a PDF document. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -doc.Save(stream); +//Save the document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -1243,10 +1223,8 @@ layoutFormat.Layout = PdfLayoutType.Paginate; //Draw PdfLightTable. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(0, 0), layoutFormat); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the document. document.Close(true); {% endhighlight %} @@ -1369,9 +1347,8 @@ for (int i = 0; i < lightTable.Columns.Count; i++) //Draw the PdfLightTable on the page. lightTable.Draw(page, new PointF(10, 10)); -//Save a PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save a PDF document. +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} @@ -1500,9 +1477,8 @@ lightTable.Columns[1].StringFormat = stringFormat; //Draw the PdfLightTable on the page. lightTable.Draw(page, new PointF(10, 10)); -//Save the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md index 1b44bac45a..170f6c783e 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md @@ -31,9 +31,8 @@ attachment.MimeType = "application/txt"; //Adds the attachment to the document document.Attachments.Add(attachment); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -86,8 +85,7 @@ Essential® PDF also provides support for adding the attachments t {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Adding-the-attachments-to-an-existing-PDF-document/.NET/Adding-the-attachments-to-an-existing-PDF-document/Program.cs" %} //Load the PDF document -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Creates an attachment Stream fileStream = new FileStream("Input.txt", FileMode.Open, FileAccess.Read); PdfAttachment attachment = new PdfAttachment("Input.txt", fileStream); @@ -99,9 +97,8 @@ if (loadedDocument.Attachments == null) //Add the attachment to the document loadedDocument.Attachments.Add(attachment); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document loadedDocument.Close(true); @@ -162,16 +159,14 @@ Essential® PDF allows you to remove the attachments from the exis {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Remove-attachment-from-an-existing-PDF-document/.NET/Remove-attachment-from-an-existing-PDF-document/Program.cs" %} //Load the PDF document -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Removes an attachment PdfAttachment attachment = document.Attachments[0]; //document.Attachments.Remove(attachment); document.Attachments.RemoveAt(0); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -220,8 +215,7 @@ Essential® PDF provides support for extracting the attachments an {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Extract-and-saving-an-attachment-to-the-disk/.NET/Extract-and-saving-an-attachment-to-the-disk/Program.cs" %} //Load the PDF document -FileStream docStream = new FileStream("Output.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("input.pdf"); //Iterates the attachments foreach (PdfAttachment attachment in document.Attachments) { @@ -231,9 +225,8 @@ foreach (PdfAttachment attachment in document.Attachments) s.Dispose(); } -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -292,105 +285,98 @@ You can achieve this functionality by using JavaScript actions within Syncfusion {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Adding-PDF-Attachments-with-Interactive-Launch-Buttons/.NET/Adding-PDF-Attachments-with-Interactive-Launch-Buttons/Program.cs" %} -//Create FileStream object to read the input PDF file -using (FileStream inputFileStream = new FileStream(@"Data/Input.pdf", FileMode.Open, FileAccess.Read)) -{ - // Load the existing PDF file - PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream); - // Get the first page of the PDF - PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; +// Load the existing PDF file +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Data/Input.pdf"); - // Create a PDF attachment - PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); - attachment.Description = "Attachment"; +// Get the first page of the PDF +PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; - // Create attachments section if it doesn't exist - if (loadedDocument.Attachments == null) - loadedDocument.CreateAttachment(); +// Create a PDF attachment +PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); +attachment.Description = "Attachment"; - // Add the attachment to the document - loadedDocument.Attachments.Add(attachment); +// Create attachments section if it doesn't exist +if (loadedDocument.Attachments == null) + loadedDocument.CreateAttachment(); - // Create a button field on the page - PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); - buttonField.Bounds = new RectangleF(100, 100, 100, 20); - buttonField.BorderColor = new PdfColor(Color.Black); - buttonField.BackColor = new PdfColor(Color.LightGray); - buttonField.Text = "Click Me"; - buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); +// Add the attachment to the document +loadedDocument.Attachments.Add(attachment); - // Add JavaScript action to open the attachment - buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); +// Create a button field on the page +PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); +buttonField.Bounds = new RectangleF(100, 100, 100, 20); +buttonField.BorderColor = new PdfColor(Color.Black); +buttonField.BackColor = new PdfColor(Color.LightGray); +buttonField.Text = "Click Me"; +buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); - // Create a form if it doesn't exist - if (loadedDocument.Form == null) - loadedDocument.CreateForm(); +// Add JavaScript action to open the attachment +buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); - // Add the button field to the form - loadedDocument.Form.Fields.Add(buttonField); +// Create a form if it doesn't exist +if (loadedDocument.Form == null) + loadedDocument.CreateForm(); - // Set default appearance for form fields - loadedDocument.Form.SetDefaultAppearance(false); +// Add the button field to the form +loadedDocument.Form.Fields.Add(buttonField); - //Create file stream. - using (FileStream outputFileStream = new FileStream(@"Output/Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - loadedDocument.Save(outputFileStream); - } +// Set default appearance for form fields +loadedDocument.Form.SetDefaultAppearance(false); + +//Save the PDF document. +loadedDocument.Save("Output.pdf"); - //Close the document. - loadedDocument.Close(true); -} +//Close the document. +loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - // Load the existing PDF file - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +// Load the existing PDF file +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); - // Get the first page of the PDF - PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; +// Get the first page of the PDF +PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; - // Create a PDF attachment - PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); - attachment.Description = "Attachment"; +// Create a PDF attachment +PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); +attachment.Description = "Attachment"; - // Create attachments section if it doesn't exist - if (loadedDocument.Attachments == null) - loadedDocument.CreateAttachment(); +// Create attachments section if it doesn't exist +if (loadedDocument.Attachments == null) + loadedDocument.CreateAttachment(); - // Add the attachment to the document - loadedDocument.Attachments.Add(attachment); +// Add the attachment to the document +loadedDocument.Attachments.Add(attachment); - // Create a button field on the page - PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); - buttonField.Bounds = new RectangleF(100, 100, 100, 20); - buttonField.BorderColor = new PdfColor(Color.Black); - buttonField.BackColor = new PdfColor(Color.LightGray); - buttonField.Text = "Click Me"; - buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); +// Create a button field on the page +PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); +buttonField.Bounds = new RectangleF(100, 100, 100, 20); +buttonField.BorderColor = new PdfColor(Color.Black); +buttonField.BackColor = new PdfColor(Color.LightGray); +buttonField.Text = "Click Me"; +buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); - // Add JavaScript action to open the attachment - buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); +// Add JavaScript action to open the attachment +buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); - // Create a form if it doesn't exist - if (loadedDocument.Form == null) - loadedDocument.CreateForm(); +// Create a form if it doesn't exist +if (loadedDocument.Form == null) + loadedDocument.CreateForm(); - // Add the button field to the form - loadedDocument.Form.Fields.Add(buttonField); +// Add the button field to the form +loadedDocument.Form.Fields.Add(buttonField); - // Set default appearance for form fields - loadedDocument.Form.SetDefaultAppearance(false); +// Set default appearance for form fields +loadedDocument.Form.SetDefaultAppearance(false); - //Save the PDF document to file stream. - loadedDocument.Save("Output.pdf"); +//Save the PDF document. +loadedDocument.Save("Output.pdf"); - //Close the document. - loadedDocument.Close(true); +//Close the document. +loadedDocument.Close(true); {% endhighlight %} @@ -436,7 +422,7 @@ loadedDocument.Form.Fields.Add(buttonField) ' Set default appearance for form fields loadedDocument.Form.SetDefaultAppearance(False) -' Save the PDF document to file stream +' Save the PDF document loadedDocument.Save("Output.pdf") ' Close the document diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md index b9bf37b567..948a308dcc 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md @@ -34,10 +34,9 @@ bookmark.Destination.Location = new PointF(20, 20); bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Color = Syncfusion.Drawing.Color.Red; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); -//Closes the document +//Save the document. +document.Save("Output.pdf"); +//Closes the document. document.Close(true); {% endhighlight %} @@ -99,8 +98,7 @@ To add bookmarks to an existing PDF document, use the following code example. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Adding-bookmarks-in-an-existing-PDF-document/.NET/Adding-bookmarks-in-an-existing-PDF-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Creates document bookmarks. PdfBookmark bookmark = document.Bookmarks.Add("Page 1"); //Sets the destination page. @@ -111,9 +109,8 @@ bookmark.Color = Color.Red; //Sets the destination location. bookmark.Destination.Location = new PointF(20, 20); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -190,9 +187,8 @@ childBookmark.Destination.Zoom = 2F; bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Color = Syncfusion.Drawing.Color.Red; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -267,17 +263,15 @@ Each loaded bookmark is represented by the [PdfLoadedBookmark](https://help.sync {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Inserting-bookmarks-in-an-existing-PDF/.NET/Inserting-bookmarks-in-an-existing-PDF/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Inserts a new bookmark in the existing bookmark collection. PdfBookmark bookmark = document.Bookmarks.Insert(1, "New Page 2"); //Sets the destination page and location. bookmark.Destination = new PdfDestination(document.Pages[1]); bookmark.Destination.Location = new PointF(0, 300); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -326,8 +320,7 @@ You can also remove bookmarks from the existing PDF document by using [Remove](h {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Remove-bookmarks-from-an-existing-PDF-document/.NET/Remove-bookmarks-from-an-existing-PDF-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmarks = document.Bookmarks; //Removes bookmark by bookmark name. @@ -335,9 +328,8 @@ bookmarks.Remove("Page 1"); //Removes bookmark by index. bookmarks.RemoveAt(1); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("output.pdf"); //Closes the document. document.Close(true); @@ -397,8 +389,7 @@ The following code example shows how to modify the [Destination](https://help.sy {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Modify-the-bookmarks-in-an-existing-PDF-document/.NET/Modify-the-bookmarks-in-an-existing-PDF-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmarks = document.Bookmarks; //Gets the first bookmark and changes the properties of the bookmark. @@ -408,9 +399,8 @@ bookmark.Color = Syncfusion.Drawing.Color.Green; bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Title = "Changed title"; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document. +document.Save("output.pdf"); //Closes the document. document.Close(true); @@ -468,16 +458,14 @@ You can get bookmark page index from the existing PDF document using [PageIndex] {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Get-bookmark-page-index-from-the-existing-PDF-document/.NET/Get-bookmark-page-index-from-the-existing-PDF-document/Program.cs" %} //Load the PDF document. -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmark = loadedDocument.Bookmarks; //Get the bookmark page index. int index = bookmark[0].Destination.PageIndex; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("output.pdf"); //Close the document. loadedDocument.Close(true); diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md index 1e171afea3..a617e63ea7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md @@ -36,9 +36,8 @@ PdfSolidBrush brush = new PdfSolidBrush(Color.Red); //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} @@ -105,9 +104,8 @@ PdfLinearGradientBrush brush = new PdfLinearGradientBrush(new PointF(0, 0), new //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} @@ -204,12 +202,9 @@ using (PdfDocument document = new PdfDocument()) // Draw a rectangle filled with the gradient graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100)); - //Create file stream. - using (FileStream outputFileStream = new FileStream(@"Output/Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document to file stream. + document.Save("Output.pdf"); + } {% endhighlight %} @@ -317,9 +312,8 @@ PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100)); -//Save the PDF document stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} @@ -388,9 +382,8 @@ brush.Graphics.DrawEllipse(PdfPens.Red, new RectangleF(0, 0, 10, 10)); //Draw ellipse graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} @@ -464,11 +457,10 @@ PdfHatchBrush pdfHatchBrush = new PdfHatchBrush(PdfHatchStyle.Plaid, new PdfColo //Draw rectangle on the page graphics.DrawRectangle(PdfPens.Black, pdfHatchBrush, new Rectangle(100, 100, 300, 200)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document -doc.Close(true); +doc.Close(true); {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md index fc73b17e20..006d037426 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md @@ -56,20 +56,10 @@ options.ImageQuality = 50; //Assign the compression option to the document. loadedDocument.Compress(options); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("Output.pdf"); //Close the documents. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} @@ -144,20 +134,10 @@ options.OptimizeFont = true; //Assign the compression option to the document. loadedDocument.Compress(options); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("Output.pdf"); //Close the documents. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} @@ -230,20 +210,10 @@ options.OptimizePageContents = true; //Assign the compression option to the document. loadedDocument.Compress(options); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("Output.pdf"); //Close the documents. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} @@ -314,20 +284,10 @@ options.RemoveMetadata = true; //Assign the compression option to the document. loadedDocument.Compress(options); -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); +//Save the document. +loadedDocument.Save("Output.pdf"); //Close the documents. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} @@ -409,20 +369,10 @@ for (int i = 0; i < 1000; i++) result = textElement.Draw(result.Page, new RectangleF(0, result.Bounds.Bottom + 10, font.MeasureString(text).Width, page.GetClientSize().Height)); } -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the documents. document.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} From a5b2ce32d37d381a2d487915bf0dcfe43c683648 Mon Sep 17 00:00:00 2001 From: Chinnu M <65020530+chinnumuniyappan@users.noreply.github.com> Date: Thu, 21 May 2026 13:30:45 +0530 Subject: [PATCH 10/14] Resolved few feedback --- .../PDF-Library/NET/Working-with-Shapes.md | 2 +- .../NET/Working-with-Text-Extraction.md | 47 +++++++++++++++++-- .../PDF/PDF-Library/NET/Working-with-XFA.MD | 8 ++-- .../PDF/PDF-Library/NET/Working-with-forms.md | 2 +- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md index eb9d8891e8..39f5bc9111 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Shapes.md @@ -969,7 +969,7 @@ document.Close(true); {% endhighlight %} -{% highlight c# tabtitle="C#" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using System.Drawing; using Syncfusion.Pdf; diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md index a4c7aa40cb..5c21987113 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Text-Extraction.md @@ -438,6 +438,44 @@ Color glyphColor = textGlyph.TextColor; {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; +using System.Drawing; + +// Load the existing PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +// Get the first page of the loaded PDF document +PdfPageBase page = loadedDocument.Pages[0]; +TextLines lineCollection = new TextLines(); + +// Extract text from the first page +string extractedText = page.ExtractText(out lineCollection); +// Get a specific line from the collection +TextLine line = lineCollection[0]; +// Get the collection of words in the line +List textWordCollection = line.WordCollection; +// Get a word from the collection using an index +TextWord textWord = textWordCollection[0]; +// Get Glyph details of the word +List textGlyphCollection = textWord.Glyphs; + +// Get a character from the word +TextGlyph textGlyph = textGlyphCollection[0]; +// Get bounds of the character +RectangleF glyphBounds = textGlyph.Bounds; +// Get font name of the character +string glyphFontName = textGlyph.FontName; +// Get font size of the character +float glyphFontSize = textGlyph.FontSize; +// Get font style of the character +FontStyle glyphFontStyle = textGlyph.FontStyle; +// Get the character in the word +char glyphText = textGlyph.Text; +// Get the color of the character +Color glyphColor = textGlyph.TextColor; + +{% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -446,16 +484,16 @@ Imports Syncfusion.Pdf.Parsing Imports System.Drawing ' Load the existing PDF document -Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") +Dim loadedDocument As New PdfLoadedDocument("Input.pdf") ' Get the first page of the loaded PDF document Dim page As PdfPageBase = loadedDocument.Pages(0) -Dim lineCollection As New TextLineCollection() +Dim lineCollection As New TextLines() ' Extract text from the first page Dim extractedText As String = page.ExtractText(lineCollection) ' Get a specific line from the collection -Dim line As TextLine = lineCollection.TextLine(0) -' Get a collection of words in the line +Dim line As TextLine = lineCollection(0) +' Get the collection of words in the line Dim textWordCollection As List(Of TextWord) = line.WordCollection ' Get a word from the collection using an index Dim textWord As TextWord = textWordCollection(0) @@ -476,6 +514,7 @@ Dim glyphFontStyle As FontStyle = textGlyph.FontStyle Dim glyphText As Char = textGlyph.Text ' Get the color of the character Dim glyphColor As Color = textGlyph.TextColor + {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-XFA.MD b/Document-Processing/PDF/PDF-Library/NET/Working-with-XFA.MD index ccf81610ad..b14811e000 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-XFA.MD +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-XFA.MD @@ -1729,7 +1729,7 @@ loadedDocument.Close(); {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Drawing; using Syncfusion.Pdf.Xfa; @@ -3491,13 +3491,13 @@ mainForm.Fields.Add(numericField); document.XfaForm = mainForm; //Save the document. -document.Save("XfaForm.pdf",PdfXfaType.Dynamic); +document.Save("XfaForm.pdf", PdfXfaType.Dynamic); //Close the document. document.Close(); {% endhighlight %} -{% highlight c# tabtitle="C#" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Drawing; using Syncfusion.Pdf.Xfa; @@ -3527,7 +3527,7 @@ document.Close(); {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET" %} +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Create a new PDF XFA document Dim document As New PdfXfaDocument() diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md index b93b096d90..9d600ba71c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md @@ -3748,7 +3748,7 @@ loadedDocument.Close(true); {% endhighlight %} -{% highlight c# tabtitle="C#" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Pdf; using Syncfusion.Pdf.Interactive; From 9fc69ec3ee558eee94553255bcbaf9e9e6b82634 Mon Sep 17 00:00:00 2001 From: Chinnu M <65020530+chinnumuniyappan@users.noreply.github.com> Date: Thu, 21 May 2026 14:54:17 +0530 Subject: [PATCH 11/14] CI failures resolved --- .../PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md | 2 +- .../PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md | 2 +- .../NET/Open-pdf-files/From-dropbox-cloud-file-storage.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md index cbf749d735..99be4acbaa 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-AWS-S3.md @@ -1,6 +1,6 @@ --- title: Open PDF file from AWS S3 | Syncfusion -description: This page describes how to Open PDF file from file AWS S3 in C# using Syncfusion .NET PDF library. +description: This page explains how to open and load a PDF document stored in an AWS S3 bucket using C# with the Syncfusion .NET PDF library. platform: document-processing control: PDF documentation: UG diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md index fa0d0e3348..f58534e921 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md @@ -1,5 +1,5 @@ --- -title: Open PDF file from Azure blob storage | Syncfusion +title: Open PDF document from Azure Blob Storage | Syncfusion description: This page describes how to Open PDF file from file azure blob storage in C# using Syncfusion .NET PDF library. platform: document-processing control: PDF diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md index 1b4bcf9f9a..6d9ceae2d2 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-dropbox-cloud-file-storage.md @@ -36,7 +36,7 @@ using Dropbox.Api; {% endtabs %} -Step 5: Add the below code example to load a PDF ifrom Dropbox cloud file storage. +Step 5: Add the below code example to load a PDF from Dropbox cloud file storage. {% tabs %} From 3f00c63f9d2cb840a728bcf75c24cb7d03f107c5 Mon Sep 17 00:00:00 2001 From: Chinnu M <65020530+chinnumuniyappan@users.noreply.github.com> Date: Thu, 21 May 2026 15:10:16 +0530 Subject: [PATCH 12/14] Feedback addressed --- .../HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 29 ----- .../HTML-To-PDF/NET/troubleshooting.md | 103 +++++------------- .../PDF/Conversions/HTML-To-PDF/overview.md | 4 - 3 files changed, 30 insertions(+), 106 deletions(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md index 8df6da9415..2eae3784de 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/Converting-HTML-to-PDF.md @@ -200,8 +200,6 @@ using Syncfusion.HtmlConverter; Step 4: Use the following code sample to convert the URL to PDF in the program.cs. -{% tabs %} - {% highlight c# tabtitle="C#" %} //Initialize HTML to PDF converter. @@ -221,8 +219,6 @@ document.Close(true); {% endhighlight %} -{% endtabs %} - By executing the program, you will get the PDF document as follows. htmltopdfoutput @@ -271,8 +267,6 @@ By default, the PDF document generated with the IE rendering engine comes with t IEWarning Please refer to the below code snippet to use the DisableIEWarning API to remove the default IE warning from the PDF document. -{% tabs %} - {% highlight c# tabtitle="C#" %} //Initialize the HTML to PDF converter @@ -291,27 +285,4 @@ document.Close(true); {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET" %} -'Initialize the HTML to PDF converter -Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.IE) -Dim settings As New IEConverterSettings() -'Disable Default IE Warning Message -settings.DisableIEWarning = true -'Assign IE settings to HTML converter -htmlConverter.ConverterSettings = settings -'Convert URL to PDF -Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") - -'Save and close the PDF document -document.Save("Output.pdf") -document.Close(True) - -{% endhighlight %} - -{% highlight c# tabtitle="ASP.NET Core" %} -//Currently, IE rendering engine does not support conversion in .NET Core platform -{% endhighlight %} - -{% endtabs %} - N>Please try our [Blink](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/net-core) engine to improve the quality and accuracy of the HTML to PDF conversion. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md index 534d7a9eb0..3a19f8fbd8 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md @@ -34,7 +34,7 @@ You can set the runtimes folder path explicitly in BlinkPath property in BlinkCo

Ex path: C:\HtmlConversion\HTMl-to-PDF\HTMl-to-PDF\bin\Debug\net7.0\runtimes\win-x64\native\

-{% tabs %} + {% highlight C# %} //Initialize the HTML to PDF converter. @@ -52,7 +52,7 @@ document.Save("Output.pdf"); document.Close(true); {% endhighlight %} -{% endtabs %} + @@ -138,7 +138,7 @@ Also, please add the following command line arguments in our converter setting.
-{% tabs %} + {% highlight C# tabtitle="C#" %} //Set command line arguments to run without sandbox. @@ -146,7 +146,7 @@ blinkConverterSettings.CommandLineArguments.Add("--no-sandbox"); blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox"); {% endhighlight %} -{% endtabs %} +
@@ -260,7 +260,7 @@ Step 2: To resolve this issue, we recommend copying the runtimes folder i Step 3: If manually copying the files doesn't meet your requirements, we recommend applying the following code changes in the .csproj file and updating the publish profile. This will ensure the necessary files are copied automatically during the publishing process.
Add the following code snippet to the .pubxml file to apply the necessary configuration.
-{% tabs %} + {% highlight C# tabtitle="C#" %} @@ -270,10 +270,9 @@ Add the following code snippet to the .pubxml file to apply the necessary {% endhighlight %} -{% endtabs %} Add the following code to the .csproj file to ensure the locale folder is copied to the publish directory during the build process.
-{% tabs %} + {% highlight C# tabtitle="C#" %} @@ -287,7 +286,7 @@ Add the following code to the .csproj file to ensure the locale fo {% endhighlight %} -{% endtabs %} + @@ -338,14 +337,14 @@ Add the following code to the .csproj file to ensure the locale fo To overcome the exception, you can add read, write, and execute permissions for the temporary folder. Refer to the following code sample to set the temp folder.

-{% tabs %} + {% highlight C# tabtitle="C#" %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.TempPath = "D://MyProject//bin"; {% endhighlight %} -{% endtabs %} + @@ -423,14 +422,14 @@ Check the HTML file or URL is rendered properly in Chrome browser's print previe

ExcludeAssets

-{% tabs %} + {% highlight C# tabtitle="C#" %} RUN chmod +x /app/runtimes/linux/native/chrome && \ chmod +x /app/runtimes/linux/native/chrome-wrapper {% endhighlight %} -{% endtabs %} + @@ -454,14 +453,14 @@ RUN chmod +x /app/runtimes/linux/native/chrome && \ To overcome this issue, add suitable delay for the conversion using the AdditionalDelay property of the HTMLConverter.

-{% tabs %} + {% highlight C# tabtitle="C#" %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.AdditionalDelay = 4000; {% endhighlight %} -{% endtabs %} + @@ -560,14 +559,14 @@ These plans provide the necessary environment and permissions to support Chromiu You can able to bypass the invalid SSL certificate errors using the command line arguments property of Blink converter settings.

-{% tabs %} + {% highlight C# tabtitle="C#" %} BlinkConverterSettings settings = new BlinkConverterSettings(); settings.CommandLineArguments.Add("--ignore-certificate-errors"); {% endhighlight %} -{% endtabs %} + @@ -597,7 +596,7 @@ settings.CommandLineArguments.Add("--ignore-certificate-errors"); Use system-installed Chromium instead of bundled binaries:

Step 1: Configure Blink Path -{% tabs %} + {% highlight C# tabtitle="C#" %} HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -615,7 +614,6 @@ document.Save("Output.pdf"); document.Close(true); {% endhighlight %} -{% endtabs %} Step 2: Verify Installation
Ensure Chrome exists at the specified path (standard locations): `C:\Program Files\Google\Chrome\Application` @@ -644,7 +642,7 @@ Ensure Chrome exists at the specified path (standard locations): `C:\Program Fil We can resolve this permission related failure in the Blink rendering engine using below command line arguments in our converter settings.

-{% tabs %} + {% highlight C# tabtitle="C#" %} //Set command line arguments to run without sandbox. @@ -652,7 +650,7 @@ blinkConverterSettings.CommandLineArguments.Add("--no-sandbox"); blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox"); {% endhighlight %} -{% endtabs %} + @@ -799,7 +797,6 @@ Refer to the following package reference: To resolve this issue, we can install the chromium using the docker file and set the Blink Path to the location where chromium is installed.

Docker File:

-{% tabs %} {% highlight C# tabtitle="C#" %} @@ -825,10 +822,7 @@ To resolve this issue, we can install the chromium using the docker file and set {% endhighlight %} -{% endtabs %} - Code example: -{% tabs %} {% highlight C# tabtitle="C#" %} @@ -840,8 +834,6 @@ To resolve this issue, we can install the chromium using the docker file and set {% endhighlight %} -{% endtabs %} - @@ -868,8 +860,6 @@ To resolve this issue, we can install the chromium using the docker file and set To resolve this issue, we can add inline styles in element. However, we have attached the sample and output documents for your reference.

-{% tabs %} - {% highlight C# tabtitle="C#" %} HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -896,8 +886,6 @@ document.Close(true); {% endhighlight %} -{% endtabs %} - You can downloaded a complete working sample from GitHub. @@ -908,8 +896,6 @@ You can downloaded a complete working sample from @@ -940,14 +924,11 @@ settings.CommandLineArguments.Add("--single-process"); To overcome this issue by installing the Linux dependencies package in SSH window. Please refer the below commands and screenshot, -{% tabs %} - {% highlight C# %} apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -{% endtabs %}

Please refer to the below screenshot,

@@ -962,7 +943,7 @@ We can install the required dependencies using the dependencies vis shell script

Code example:

-{% tabs %} + {% highlight C# %} private static void InstallLinuxPackages(FileInfo functionAppDirectory) @@ -1005,7 +986,7 @@ We can install the required dependencies using the dependencies vis shell script } {% endhighlight %} -{% endtabs %} + @@ -1061,7 +1042,7 @@ Blink binaries (Version 109.0.5414.75), We can resolve the reported issue by using the FileStream within the "using" block. -{% tabs %} + {% highlight C# %} using (FileStream fs = new FileStream("path_to_file", FileMode.Open)) @@ -1070,12 +1051,12 @@ using (FileStream fs = new FileStream("path_to_file", FileMode.Open)) } // File stream is automatically closed and disposed {% endhighlight %} -{% endtabs %} + Or Dispose of the FileStream at the end of the process and ensure that the file or document is not already open in another application. -{% tabs %} + {% highlight C# %} PdfDocument document = htmlConverter.Convert("); @@ -1088,7 +1069,7 @@ document.Dispose(); fileStream.Dispose(); {% endhighlight %} -{% endtabs %} + @@ -1140,7 +1121,6 @@ The exception may occur while performing HTML to PDF conversion with docker and To overcome the exception by making the root files as executable. For making the root files as executable, you can find the code snippet below which will be added to your docker file. -{% tabs %} {% highlight C# %} USER root @@ -1148,7 +1128,7 @@ RUN chmod +x /app/runtimes/linux/native/chrome && \ chmod +x /app/runtimes/linux/native/chrome-wrapper {% endhighlight %} -{% endtabs %} +

Please refer to the below screenshot,

@@ -1180,13 +1160,12 @@ The issue occurs within Chromium specifically for Alpine. We can resolve this issue by adding command-line arguments to the Blink converter settings. Please refer to the code snippet below. -{% tabs %} {% highlight C# %} blinkConverterSettings.CommandLineArguments.Add("--disable-gpu"); {% endhighlight %} -{% endtabs %} + @@ -1214,7 +1193,6 @@ You can try the below solution steps to overcome the reported issue 'Failed to Step 1: Kindly try the below docker file changes in your sample to resolve the chrome_crashpad_handler issue.
-{% tabs %} {% highlight C# %} FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine @@ -1256,7 +1234,6 @@ USER guest ENTRYPOINT ["dotnet", "Ops.PDFSearch.Web.dll"] {% endhighlight %} -{% endtabs %} We have attached the modified docker file for your reference
Docker file.
@@ -1264,18 +1241,15 @@ Step 2: From chromium version 128.x.x.x.x -database flag required for chrome Cra Add below commands in Docker file:
-{% tabs %} {% highlight C# %} RUN mkdir -p /var/www/.config/google-chrome/Crashpad RUN chown -R www-data:www-data /var/www/.config {% endhighlight %} -{% endtabs %} Add below command-line arguments in conversion code
-{% tabs %} {% highlight C# %} if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) @@ -1290,7 +1264,6 @@ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) } {% endhighlight %} -{% endtabs %} Please refer the Chromium forum link. for more information about the reported issue @@ -1357,38 +1330,32 @@ To resolve the issue and ensure successful HTML to PDF conversion in Azure App S Provide read, write, and execute permissions for the chrome and chrome-wrapper files located in the runtimes/linux/native directory. Use the following commands: -{% tabs %} {% highlight C# %} chmod +rwx chrome-wrapper chmod +rwx chrome {% endhighlight %} -{% endtabs %} 2: Verify Chrome Dependency Packages
Check if the necessary dependencies for Chromium are installed by running the following command in the runtimes/linux/native directory: -{% tabs %} {% highlight C# %} ldd chrome {% endhighlight %} -{% endtabs %} 3: Install Required Dependencies
We can also perform HTML to PDF conversion in Azure App Service (Linux) by installing the required dependencies directly through SSH terminal. Use the following command: -{% tabs %} {% highlight C# %} apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -{% endtabs %} For more details to install the dependencies through SSH terminal window, refer to the documentation: Convert HTML to PDF in Azure App Service on Linux| Syncfusion @@ -1427,13 +1394,13 @@ Publish your application to the Azure App Service.
3.Configure Startup Command
After deployment, go to the Azure portal configuration for your app service.
In the Startup Command section, add:
-{% tabs %} + {% highlight C# %} /home/site/wwwroot/dependenciesInstall.sh && dotnet YourApplicationName.dll {% endhighlight %} -{% endtabs %} +
Runtime folder
@@ -1472,7 +1439,6 @@ After the service restarts, try the conversion or operation again to ensure the Update the dependency installation script to use t64 packages and omit libgconf-2-4. The following command installs the supported libraries on Ubuntu 24.04: -{% tabs %} {% highlight C# %} Run apt-get update && apt-get install -yq --no-install-recommends \ @@ -1483,7 +1449,6 @@ Run apt-get update && apt-get install -yq --no-install-recommends \ libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -{% endtabs %} After applying this change, all required dependencies are installed successfully. @@ -1513,7 +1478,7 @@ After applying this change, all required dependencies are installed successfully To ensure that the correct localized or culture-specific content appears in the generated PDF:
Set the required culture cookie explicitly using the Cookies property in BlinkConverterSettings before starting conversion.
Example for setting German culture:
-{% tabs %} + {% highlight C# %} HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -1524,7 +1489,7 @@ htmlConverter.ConverterSettings = settings; PdfDocument doc = htmlConverter.Convert(url); {% endhighlight %} -{% endtabs %} + @@ -1536,17 +1501,14 @@ The problem is limited to Azure Functions with premium plans in Net 8.0 version. Prerequisites dependencies: -{% tabs %} {% highlight C# %} apt-get update && apt-get install -yq --no-install-recommends libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 libgbm1 {% endhighlight %} -{% endtabs %} N> We have option to exclude the default Blink binaries from the installation package. This will reduce the size of your deployment package in azure. Please refer to the code example below. -{% tabs %} {% highlight C# %} @@ -1556,7 +1518,6 @@ N> We have option to exclude the default Blink binaries from the installation pa {% endhighlight %} -{% endtabs %} ## How to Exclude BlinkBinaries or Runtime Files in Build or Deployment @@ -1569,7 +1530,6 @@ You can prevent runtime files from being included by restricting the package to Refer to the following package reference: -{% tabs %} {% highlight C# %} @@ -1579,7 +1539,6 @@ Refer to the following package reference: {% endhighlight %} -{% endtabs %} By using IncludeAssets="compile", only the required compile-time metadata is included, and all runtime dependencies (BlinkBinaries) are excluded from the final build or publish output. @@ -1590,13 +1549,11 @@ N> If you exclude runtime files, you must manually place BlinkBinaries on the se For .NET Framework applications, Blink runtime files are included through a .targets file referenced in the project. To exclude BlinkBinaries, simply remove this import entry. -{% tabs %} {% highlight C# %} {% endhighlight %} -{% endtabs %} Removing this line prevents the Syncfusion® build targets from copying BlinkBinaries and other runtime files into your bin folder during build or publish. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md index fe4838fbf1..7c0b7de60c 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md @@ -201,8 +201,6 @@ using Syncfusion.HtmlConverter; Step 4: Use the following code sample to convert the URL to PDF in the program.cs. -{% tabs %} - {% highlight c# tabtitle="C#" %} //Initialize HTML to PDF converter. @@ -222,8 +220,6 @@ document.Close(true); {% endhighlight %} -{% endtabs %} - By executing the program, you will get the PDF document as follows. htmltopdfoutput From 0c73b493bb099eafb9b963cf8b84bf69b167024a Mon Sep 17 00:00:00 2001 From: Chinnu M <65020530+chinnumuniyappan@users.noreply.github.com> Date: Thu, 21 May 2026 15:16:05 +0530 Subject: [PATCH 13/14] Front matter issue resolved --- .../PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md index f58534e921..0dfe71601c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Open-pdf-files/From-azure-blob-storage.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Open PDF file from Azure Blob storage +# Open PDF document from Azure Blob Storage To load a PDF file from Azure blob storage, you can follow the steps below From 540859c88be069b51885a68b9e4a92f16f0cb93c Mon Sep 17 00:00:00 2001 From: jeyalakshmit Date: Thu, 21 May 2026 16:53:24 +0530 Subject: [PATCH 14/14] 1027879-Remove HTML tab and add C# windows specific --- .../Conversions/HTML-To-PDF/NET/features.md | 1424 ++++++++++++++--- 1 file changed, 1191 insertions(+), 233 deletions(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md index ebf3a7b0a5..8f894b1a59 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md @@ -28,6 +28,21 @@ PdfDocument document = htmlConverter.Convert("https://www.google.com"); document.Save("Output.pdf"); document.Close(true); +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); {% endhighlight %} @@ -69,8 +84,29 @@ To convert the HTML string to PDF using [Convert](https://help.syncfusion.com/cr {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/Convert-the-HTML-string-to-PDF-document/.NET/Convert-the-HTML-string-to-PDF-document/Program.cs, 300" %} -using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.HtmlConverter; + +//Initialize HTML to PDF converter +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +//HTML string and Base URL +string htmlText = "\"Syncfusion_logo\"

Hello World

"; +string baseUrl = @"C:/Temp/HTMLFiles/"; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert(htmlText, baseUrl); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} + using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; //Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); @@ -108,16 +144,6 @@ document.Close(True) {% endhighlight %} -{% highlight html %} - - -Syncfusion_logo -

Hello World

- - - -{% endhighlight %} - {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Convert-the-HTML-string-to-PDF-document). @@ -247,17 +273,6 @@ File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData) {% endhighlight %} -{% highlight html %} - - - - Syncfusion_logo -

Hello World

- - - -{% endhighlight %} - {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Convert-the-HTML-string-to-image-file). @@ -286,7 +301,29 @@ Image image = htmlConverter.ConvertToImage(svg, ""); byte[] imageBytes = image.ImageData; // Save the image data to a file in JPEG format -File.WriteAllBytes("Output.jpg"), imageBytes); +File.WriteAllBytes("Output.jpg", imageBytes); + +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.HtmlConverter; + +// Create an instance of the Syncfusion HtmlToPdfConverter +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +// Read the SVG content from a file +string svg = File.ReadAllText("sample.svg"); + +// Convert the SVG content to an image using the converter +Image[] image = htmlConverter.ConvertToImage(svg, ""); + +// Save the image data to a file in JPEG format +for (int i = 0; i < image.Length; i++) +{ + image[i].Save($"Output_{i}.jpg", ImageFormat.Jpeg); +} {% endhighlight %} @@ -345,6 +382,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Disable JavaScript; By default, true +blinkConverterSettings.EnableJavaScript = false; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -402,6 +462,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +// Set additional delay; units in milliseconds +blinkConverterSettings.AdditionalDelay = 3000; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -458,6 +541,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Enable hyperlinks; By default - true +blinkConverterSettings.EnableHyperLink = false; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -516,6 +622,29 @@ document.Save("Output.pdf"); document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Set enable bookmarks +settings.EnableBookmarks = true; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = settings; + +//Convert HTML to PDF +PdfDocument document = htmlConverter.Convert("input.html"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -537,50 +666,6 @@ document.Save("Output.pdf") document.Close(True) {% endhighlight %} - -{% highlight html %} - - - - - - - -

Syncfusion®

- -

Introduction

- Syncfusion® is the enterprise technology partner of choice for software development, delivering a broad range of web, mobile, and desktop controls coupled with a service-oriented approach throughout the entire application life cycle. -

Products

-

WEB

- The most comprehensive suite for enterprise web development. -

Desktop

- Comprehensive suite of over 115 components including the fastest chart and grid components. -

Mobile

- Comprehensive suite of components for Xamarin.iOS, Xamarin.Android and Xamarin.Forms including the fastest chart and grid. -

Consulting

- We can build web, mobile, and desktop applications better and faster than anyone since we build on top of our award-winning suite of components and frameworks, saving you time and money. -

Company

-

About us

- Syncfusion® has established itself as the trusted partner worldwide for use in mission-critical applications. Founded in 2001 and headquartered in Research Triangle Park, N.C., Syncfusion® has more than 12,000 customers, including large financial institutions, Fortune 100 companies, and global IT consultancies. -

contact us

- Morrisville Office - Company Headquarters - 2501 Aerial Center Parkway - Suite 200 - Morrisville, NC 27560 - USA - - - -{% endhighlight %} - {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Creating-bookmarks-while-converting-HTML-to-PDF). @@ -618,6 +703,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Set enable table of contents +settings.EnableToc = true; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = settings; + +//Convert HTML to PDF +PdfDocument document = htmlConverter.Convert("input.html"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -640,49 +748,6 @@ document.Close(True) {% endhighlight %} -{% highlight html %} - - - - - - - -

Syncfusion®

- -

Introduction

- Syncfusion® is the enterprise technology partner of choice for software development, delivering a broad range of web, mobile, and desktop controls coupled with a service-oriented approach throughout the entire application life cycle. -

Products

-

WEB

- The most comprehensive suite for enterprise web development. -

Desktop

- Comprehensive suite of over 115 components including the fastest chart and grid components. -

Mobile

- Comprehensive suite of components for Xamarin.iOS, Xamarin.Android and Xamarin.Forms including the fastest chart and grid. -

Consulting

- We can build web, mobile, and desktop applications better and faster than anyone since we build on top of our award-winning suite of components and frameworks, saving you time and money. -

Company

-

About us

- Syncfusion® has established itself as the trusted partner worldwide for use in mission-critical applications. Founded in 2001 and headquartered in Research Triangle Park, N.C., Syncfusion® has more than 12,000 customers, including large financial institutions, Fortune 100 companies, and global IT consultancies. -

contact us

- Morrisville Office - Company Headquarters - 2501 Aerial Center Parkway - Suite 200 - Morrisville, NC 27560 - USA - - - -{% endhighlight %} - {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Create-TOC-while-converting-HTML-to-PDF). @@ -728,6 +793,39 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.HtmlToPdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Set enable table of contents +settings.EnableToc = true; +//Set the style for level 1(H1) items in table of contents +HtmlToPdfTocStyle tocstyleH1 = new HtmlToPdfTocStyle(); +tocstyleH1.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 10, PdfFontStyle.Regular); +tocstyleH1.BackgroundColor = new PdfSolidBrush(new PdfColor(Color.FromArgb(68, 114, 196))); +tocstyleH1.ForeColor = PdfBrushes.White; +tocstyleH1.Padding = new PdfPaddings(5, 5, 3, 3); +settings.Toc.SetItemStyle(1, tocstyleH1); +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = settings; + +//Convert HTML to PDF +PdfDocument document = htmlConverter.Convert("input.html"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.Drawing @@ -759,50 +857,6 @@ document.Save("Output.pdf") document.Close(True) {% endhighlight %} - -{% highlight html %} - - - - - - - -

Syncfusion®

- -

Introduction

- Syncfusion® is the enterprise technology partner of choice for software development, delivering a broad range of web, mobile, and desktop controls coupled with a service-oriented approach throughout the entire application life cycle. -

Products

-

WEB

- The most comprehensive suite for enterprise web development. -

Desktop

- Comprehensive suite of over 115 components including the fastest chart and grid components. -

Mobile

- Comprehensive suite of components for Xamarin.iOS, Xamarin.Android and Xamarin.Forms including the fastest chart and grid. -

Consulting

- We can build web, mobile, and desktop applications better and faster than anyone since we build on top of our award-winning suite of components and frameworks, saving you time and money. -

Company

-

About us

- Syncfusion® has established itself as the trusted partner worldwide for use in mission-critical applications. Founded in 2001 and headquartered in Research Triangle Park, N.C., Syncfusion® has more than 12,000 customers, including large financial institutions, Fortune 100 companies, and global IT consultancies. -

contact us

- Morrisville Office - Company Headquarters - 2501 Aerial Center Parkway - Suite 200 - Morrisville, NC 27560 - USA - - - -{% endhighlight %} - {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Create-custom-style-TOC-when-converting-HTML-to-PDF). @@ -854,28 +908,69 @@ htmlConverter.Close(); {% endhighlight %} -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} -Imports Syncfusion.Drawing -Imports Syncfusion.HtmlConverter -Imports Syncfusion.Pdf +using System.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; -' Create an instance of HTML-to-PDF converter -Dim htmlConverter As New HtmlToPdfConverter() -' Configure Blink converter settings -Dim blinkConverterSettings As New BlinkConverterSettings() With { - .ViewPortSize = New Size(1280, 0), ' Set viewport width for rendering - .EnableToc = True ' Enable Table of Contents (TOC) -} -' Set TOC starting page number to skip the cover page -blinkConverterSettings.Toc.StartingPageNumber = 1 -' Apply the settings to the converter -htmlConverter.ConverterSettings = blinkConverterSettings -' Read the main HTML content and convert it to PDF -Dim inputhtml As String = File.ReadAllText("input.html") -Dim document As PdfDocument = htmlConverter.Convert(inputhtml, "") -' Create cover page and insert to the 0th index. -' Apply scaling settings for the cover page +// Create an instance of HTML-to-PDF converter +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +// Configure Blink converter settings +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings() +{ + ViewPortSize = new Size(1280, 0), // Set viewport width for rendering + EnableToc = true, // Enable Table of Contents (TOC) +}; +// Set TOC starting page number to skip the cover page +blinkConverterSettings.Toc.StartingPageNumber = 1; +// Apply the settings to the converter +htmlConverter.ConverterSettings = blinkConverterSettings; +// Read the main HTML content and convert it to PDF +string inputhtml = File.ReadAllText("input.html"); +PdfDocument document = htmlConverter.Convert(inputhtml, ""); +//Create cover page and insert to the 0th index. +// Apply scaling settings for the cover page +htmlConverter.ConverterSettings = new BlinkConverterSettings() +{ + Scale = 1.5f +}; +// Convert the cover page HTML to PDF +string coverimage = File.ReadAllText("coverpage.html"); +PdfDocument coverPage = htmlConverter.Convert(coverimage, ""); +// Insert the cover page at the beginning of the main document +document.Pages.Insert(0, coverPage.Pages[0]); +// Save the PDF document +document.Save("Output.pdf"); +//Dispose the document +coverPage.Close(true); +document.Close(true); +htmlConverter.Close(); + +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports Syncfusion.Drawing +Imports Syncfusion.HtmlConverter +Imports Syncfusion.Pdf + +' Create an instance of HTML-to-PDF converter +Dim htmlConverter As New HtmlToPdfConverter() +' Configure Blink converter settings +Dim blinkConverterSettings As New BlinkConverterSettings() With { + .ViewPortSize = New Size(1280, 0), ' Set viewport width for rendering + .EnableToc = True ' Enable Table of Contents (TOC) +} +' Set TOC starting page number to skip the cover page +blinkConverterSettings.Toc.StartingPageNumber = 1 +' Apply the settings to the converter +htmlConverter.ConverterSettings = blinkConverterSettings +' Read the main HTML content and convert it to PDF +Dim inputhtml As String = File.ReadAllText("input.html") +Dim document As PdfDocument = htmlConverter.Convert(inputhtml, "") +' Create cover page and insert to the 0th index. +' Apply scaling settings for the cover page htmlConverter.ConverterSettings = New BlinkConverterSettings() With { .Scale = 1.5F } @@ -926,6 +1021,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set print media type +blinkConverterSettings.MediaType = MediaType.Print; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -983,6 +1101,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Set enable form +settings.EnableForm = true; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = settings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1038,6 +1179,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +// Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +blinkConverterSettings.Username = "username"; +blinkConverterSettings.Password = "password"; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.example.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1094,6 +1258,30 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +// Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +// Add cookies as name and value pair +blinkConverterSettings.Cookies.Add("CookieName1", " CookieValue1"); +blinkConverterSettings.Cookies.Add("CookieName2", " CookieValue2"); +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.example.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1150,6 +1338,30 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize HTML to PDF converter +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Add a bearer token to login a webpage +settings.HttpRequestHeaders.Add("Authorization", "bearer <>"); +//Assign Blink settings to HTML converter +htmlConverter.ConverterSettings = settings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.example.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1209,6 +1421,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); + +//Enable offline mode +blinkConverterSettings.EnableOfflineMode = true; + +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; +string inputHTML = Path.GetFullPath("input.html"); +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert(inputHTML); +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1267,6 +1502,30 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Add HTTP post parameters to HttpPostFields +settings.HttpPostFields.Add("firstName", "Andrew"); +settings.HttpPostFields.Add("lastName", "Fuller"); +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = settings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.example.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1321,6 +1580,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +string url = "https://www.example.com"; +Uri getMethodUri = new Uri(url); +string httpGetData = getMethodUri.Query.Length > 0 ? "&" : "?" + String.Format("{0}={1}", "firstName", "Andrew"); +httpGetData += String.Format("&{0}={1}", "lastName", "Fuller"); +string urlToConvert = url + httpGetData; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert(urlToConvert); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1392,6 +1674,31 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Set manual proxy settings +settings.ProxySettings.HostName = "127.0.0.1"; +settings.ProxySettings.PortNumber = 8080; +settings.ProxySettings.Type = BlinkProxyType.Http; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = settings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1451,6 +1758,30 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set Blink viewport size +blinkConverterSettings.ViewPortSize = new Size(800, 0); +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports System.Drawing @@ -1501,6 +1832,23 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +//Convert Partial webpage to PDF +PdfDocument document = htmlConverter.ConvertPartialHtml("input.html", "pic"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1516,26 +1864,6 @@ document.Save("Output.pdf") document.Close(True) {% endhighlight %} - -{% highlight html %} - - - - - -Hello world -
- Smiley face
- This is a Syncfusion Logo -
-
- Hello world -
- - - -{% endhighlight %} - {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Convert-partial-webpage-to-PDF-document). @@ -1577,6 +1905,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Set singlePageLayout option to render the whole HTML content in a single PDF page +settings.SinglePageLayout = SinglePageLayout.FitWidth; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = settings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1628,6 +1979,27 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +PdfLayoutResult layoutResult = null; +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com", out layoutResult); +//Draw the text at the end of HTML content +PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 11); +document.Pages[document.Pages.Count - 1].Graphics.DrawString("End of HTML content", font, PdfBrushes.Red, new PointF(0, layoutResult.Bounds.Bottom)); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1685,6 +2057,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +// Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set windows status +blinkConverterSettings.WindowStatus = "completed"; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("input.html"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1707,26 +2102,6 @@ document.Close(True) {% endhighlight %} -{% highlight html %} - - - - - -
- Wait for 2 Seconds -
- - - - -{% endhighlight %} - {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Set-windows-status-while-converting-HTML-to-PDF). @@ -1760,6 +2135,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize blink converter settings. +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set the page size. +blinkConverterSettings.PdfPageSize = PdfPageSize.A4; +//Assign Blink converter settings to HTML converter. +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert URL to PDF document. +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save the PDF document. +document.Save("Output.pdf"); +//Close the document. +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1814,6 +2212,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize blink converter settings. +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set the margin. +blinkConverterSettings.Margin.All = 50; +//Assign Blink converter settings to HTML converter. +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert URL to PDF document. +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save the PDF document +document.Save("Output.pdf"); +//Close the document. +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -1829,23 +2250,67 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com") -'Save and close the PDF document. -document.Save("Output.pdf") -document.Close(True) +'Save and close the PDF document. +document.Save("Output.pdf") +document.Close(True) + +{% endhighlight %} + +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/HTML-to-PDF-margin-customization). + +## Header and footer + +To set the header and footer when converting HTML to PDF, utilize the [PdfHeader](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_PdfHeader) and [PdfFooter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_PdfFooter) properties in the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. Please refer to the following code example. + +{% tabs %} + +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-to-PDF-Header-and-footer/.NET/HTML-to-PDF-Header-and-footer/Program.cs, 300" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + +//Initialize HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Create PDF page template element for header with bounds. +PdfPageTemplateElement header = new PdfPageTemplateElement(new RectangleF(0, 0, blinkConverterSettings.PdfPageSize.Width, 50)); +//Create font and brush for header element. +PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 7); +PdfBrush brush = new PdfSolidBrush(Color.Black); +//Draw the header string in header template element. +header.Graphics.DrawString("This is header", font, brush, PointF.Empty); +//Assign the header element to PdfHeader of Blink converter settings. +blinkConverterSettings.PdfHeader = header; +//Create PDF page template element for footer with bounds. +PdfPageTemplateElement footer = new PdfPageTemplateElement(new RectangleF(0, 0, blinkConverterSettings.PdfPageSize.Width, 50)); +//Create page number field. +PdfPageNumberField pageNumber = new PdfPageNumberField(font, PdfBrushes.Black); +//Create page count field. +PdfPageCountField count = new PdfPageCountField(font, PdfBrushes.Black); +//Add the fields in composite fields. +PdfCompositeField compositeField = new PdfCompositeField(font, PdfBrushes.Black, "Page {0} of {1}", pageNumber, count); +//Draw the composite field in footer +compositeField.Draw(footer.Graphics, PointF.Empty); +//Assign the footer element to PdfFooter of Blink converter settings. +blinkConverterSettings.PdfFooter = footer; +//Set Blink viewport size. +blinkConverterSettings.ViewPortSize = new Size(1024, 0); +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert URL to PDF. +PdfDocument document = htmlConverter.Convert("https://www.google.com/"); + +//Save a PDF document +document.Save("Output.pdf"); +//Close the document. +document.Close(true); {% endhighlight %} -{% endtabs %} - -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/HTML-to-PDF-margin-customization). - -## Header and footer - -To set the header and footer when converting HTML to PDF, utilize the [PdfHeader](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_PdfHeader) and [PdfFooter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_PdfFooter) properties in the [BlinkConverterSettings](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. Please refer to the following code example. - -{% tabs %} - -{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/HTML%20to%20PDF/Blink/HTML-to-PDF-Header-and-footer/.NET/HTML-to-PDF-Header-and-footer/Program.cs, 300" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.HtmlConverter; using Syncfusion.Pdf.Graphics; @@ -1966,6 +2431,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize blink converter settings. +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set the Orientation. +blinkConverterSettings.Orientation = PdfPageOrientation.Landscape; +//Assign Blink converter settings to HTML converter. +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert URL to PDF document. +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save a PDF document. +document.Save("Output.pdf"); +//Close the document. +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2020,6 +2508,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize blink converter settings. +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set the page rotate. +blinkConverterSettings.PageRotateAngle = PdfPageRotateAngle.RotateAngle90; +//Assign Blink converter settings to the HTML converter. +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert URL to PDF document. +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save a PDF document +document.Save("Output.pdf"); +//Close the document. +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2082,6 +2593,37 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize blink converter settings. +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set the Blink viewport size. +blinkConverterSettings.ViewPortSize = new Size(1280, 0); +//Set the html margin-top value based on the html header height and margin-top value. +blinkConverterSettings.Margin.Top = 70; +//Set the html margin-bottom value based on the html footer height and margin-bottom value. +blinkConverterSettings.Margin.Bottom = 40; +//Set the custom HTML header to add at the top of each page. +blinkConverterSettings.HtmlHeader = File.ReadAllText("header.html"); +//Set the custom HTML footer to add at the bottom of each page. +blinkConverterSettings.HtmlFooter = File.ReadAllText("footer.html"); +//Assign Blink converter settings to the HTML converter. +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert the URL to a PDF document. +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); + +//Save and close a PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2151,6 +2693,30 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set the Blink viewport size. +blinkConverterSettings.ViewPortSize = new Size(1280, 0); +blinkConverterSettings.Margin.All = 30; +//Set the custom CSS +blinkConverterSettings.Css = "body {\r\n background-color: red; \r\n}"; +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert the URL to PDF document. +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2211,6 +2777,30 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set the Blink viewport size. +blinkConverterSettings.ViewPortSize = new Size(1280, 0); +blinkConverterSettings.Margin.All = 30; +//Set the Custom JavaScript +blinkConverterSettings.JavaScript = "document.querySelectorAll('img').forEach((node)=>{node.remove();})"; +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert the URL to PDF document. +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2278,6 +2868,37 @@ htmlConverter.Close(); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Reuse the browser instance. +htmlConverter.ReuseBrowserProcess = true; +//Create PDF document. +PdfDocument document = new PdfDocument(); + +for (int i = 0; i < 10; i++) +{ + //Initialize the blink converter settings. + BlinkConverterSettings settings = new BlinkConverterSettings(); + settings.AdditionalDelay = 1000; + settings.EnableJavaScript = true; + //Assign the settings to HTML converter. + htmlConverter.ConverterSettings = settings; + //Convert the URL to PDF document. + document = htmlConverter.Convert("https://www.google.com"); + //Save and close the PDF document. + document.Save("Output.pdf"); + document.Close(true); +} +//Close HTML converter. +htmlConverter.Close(); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2347,6 +2968,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set Temporary Path to generate temporary files +blinkConverterSettings.TempPath = @"C:/HtmlConversion/Temp/"; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; + +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2402,6 +3046,27 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set Blink binaries path. +blinkConverterSettings.BlinkPath = @"C:/HtmlConversion/BlinkBinaries/"; +//Assign Blink converter settings to HTML converter. +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert URL to PDF document. +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2459,6 +3124,29 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize the blink converter settings. +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +//Set the Scale. +blinkConverterSettings.Scale = 1.0f; +//Assign the Blink converter settings to the HTML converter. +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert the URL to a PDF document. +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); + +//Save a PDF document +document.Save("Output.pdf"); +//Close the document. +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2487,13 +3175,37 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Enable Auto Scaling -The [EnableAutoScaling](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableAutoScaling) property allows you to automatically scale the HTML content to fit the PDF dimensions during the conversion process. When set to true, the HTML content will be resized to fit the size of the generated PDF, ensuring that the content fits within the page without clipping or overflowing. +The [EnableAutoScaling](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.BlinkConverterSettings.html#Syncfusion_HtmlConverter_BlinkConverterSettings_EnableAutoScaling) property allows you to automatically scale the HTML content to fit the PDF dimensions during the conversion process. When set to true, the HTML content will be resized to fit the size of the generated PDF, ensuring that the content fits within the page without clipping or overflowing. + +N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML to PDF conversion process. + +{% tabs %} + +{% highlight c# tabtitle="C# [Cross-platform]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +// Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +// Initialize BlinkConverterSettings to configure the Blink rendering engine. +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); + +// Enables automatic scaling to adjust the HTML content to fit the PDF's dimensions. +blinkConverterSettings.EnableAutoScaling = true; -N> EnableAutoScaling and GetHtmlBounds cannot be used simultaneously in the HTML to PDF conversion process. +// Assigns the Blink settings to the HTML to PDF converter. +htmlConverter.ConverterSettings = blinkConverterSettings; +// Converts the HTML file to a PDF document, using the path of the HTML file. +PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../Input.html")); +// Save the generated PDF document to a specified output file. +document.Save("Output.pdf"); +// Close the document. +document.Close(true); -{% tabs %} +{% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.HtmlConverter; using Syncfusion.Pdf; @@ -2510,7 +3222,7 @@ blinkConverterSettings.EnableAutoScaling = true; htmlConverter.ConverterSettings = blinkConverterSettings; // Converts the HTML file to a PDF document, using the path of the HTML file. PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../Input.html")); -// Save the generated PDF document to a specified output file. +// Save the PDF document. document.Save("Output.pdf"); // Close the document. document.Close(true); @@ -2573,6 +3285,28 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize the HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize the blink converter settings. +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +// Set the conversion timeout to 5000 milliseconds +blinkConverterSettings.ConversionTimeout = 5000; +//Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; +//Convert URL to PDF +PdfDocument document = htmlConverter.Convert("https://www.google.com"); + +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2629,6 +3363,30 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +// Initialize HTML to PDF converter +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +// Initialize Blink converter settings +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); +// Set the converter to wait for external fonts to be loaded before converting +blinkConverterSettings.WaitForExternalFonts = true; + +// Assign Blink converter settings to HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; +// Convert URL (or file path) to PDF +PdfDocument document = htmlConverter.Convert(Path.GetFullPath("Input.html")); + +// Save the PDF document. +document.Save("Output.pdf"); +// Close the document. +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2684,6 +3442,27 @@ document.Close(true); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +//Initialize HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize the BlinkConverterSettings. +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Set true to enable the accessibility tags in PDF generation. +settings.EnableAccessibilityTags= true; +//Assign the BlinkConverterSettings to the ConverterSettings property of HtmlToPdfConverter. +htmlConverter.ConverterSettings = settings; +//Convert URL to PDF. +PdfDocument document = htmlConverter.Convert("Input.html"); +//Save and close the PDF document. +document.Save("Output.pdf"); +document.Close(true); + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2736,6 +3515,29 @@ File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using System.Drawing.Imaging; +using Syncfusion.HtmlConverter; + +//Initialize HTML to PDF converter. +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +//Initialize the BlinkConverterSettings. +BlinkConverterSettings settings = new BlinkConverterSettings(); +//Set the Image Background color. +settings.ImageBackgroundColor = Color.Transparent; +//Assign the BlinkConverterSettings to the ConverterSettings property of HtmlToPdfConverter. +htmlConverter.ConverterSettings = settings; +//Convert HTML to Image. +Image[] image = htmlConverter.ConvertToImage("Input.html"); +for (int i = 0; i < image.Length; i++) +{ + image[i].Save($"Output_{i}.jpg", ImageFormat.Jpeg); +} + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2790,6 +3592,32 @@ File.WriteAllBytes(Path.GetFullPath(@"Output/Output.jpg"), image.ImageData); {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using System.Drawing.Imaging; +using Syncfusion.HtmlConverter; + +// Initialize HTML to PDF converter +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +// Initialize Blink converter settings +BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); + +// Set the crop region for the HTML conversion based on the bounds of the HTML file +blinkConverterSettings.CropRegion = htmlConverter.GetHtmlBounds(Path.GetFullPath("Input.html")); + +// Assign Blink converter settings to the HTML converter +htmlConverter.ConverterSettings = blinkConverterSettings; +// Convert the HTML file to an image +Image[] image = htmlConverter.ConvertToImage(Path.GetFullPath("Input.html")); +//Save the image. +for (int i = 0; i < image.Length; i++) +{ + image[i].Save($"Output_{i}.jpg", ImageFormat.Jpeg); +} + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.HtmlConverter @@ -2855,6 +3683,37 @@ using (HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter()) {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; + +// Initialize HTML to PDF converter +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +{ + // Initialize Blink converter settings + BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); + // Set Blink viewport size + blinkConverterSettings.ViewPortSize = new Size(1280, 0); + + // Restricts external CSS and images in local HTML content + blinkConverterSettings.EnableLocalFileAccess = false; + + // Assign Blink converter settings to HTML converter + htmlConverter.ConverterSettings = blinkConverterSettings; + // Read HTML content from file + string html = File.ReadAllText("sample.html"); + // Convert HTML to PDF document + using (PdfDocument document = htmlConverter.Convert(html, "")) + { + // Save the PDF document. + document.Save("Output.pdf"); + } +} + +{% endhighlight %} + {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports System.Drawing @@ -2970,6 +3829,80 @@ public void AddPdfSignatureField(MemoryStream stream) {% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + +// Initialize the HTML to PDF converter using the Blink rendering engine +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); + +// Configure the converter to preserve form fields in the PDF +BlinkConverterSettings settings = new BlinkConverterSettings +{ + EnableForm = true // Ensures form elements like ,