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..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. @@ -392,13 +388,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"); @@ -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/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®® 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 %}