From 9546d47784a25ad8310e718b327cbfd80dff1d52 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 6 Oct 2025 14:29:25 +0530 Subject: [PATCH 1/5] 985481-ug: UG documentation feedback for PDF library- Working with OCR and Getting started. --- .../HTML-To-PDF/NET/Converting-HTML-to-PDF.md | 6 +- .../NET/NuGet-Packages-Required.md | 8 +- .../PDF/Conversions/HTML-To-PDF/overview.md | 9 +- .../Create-PDF-document-in-AKS-Environment.md | 49 +- ...reate-PDF-file-in-AWS-Elastic-Beanstalk.md | 106 ++-- .../NET/Create-PDF-file-in-AWS-Lambda.md | 142 ++--- .../NET/Create-PDF-file-in-Console.md | 7 +- ...ream-dispose-before-saving-PDF-document.md | 5 +- .../resolving-namespace-ambiguity-errors.md | 2 +- .../Open-and-Save-PDF-document-AWS-Lambda.md | 5 +- ...n-and-save-PDF-document-in-ASP-NET-Core.md | 4 +- .../NET/NuGet-Packages-Required.md | 8 +- .../NET/Open-pdf-files/From-AWS-S3.md | 42 +- .../Open-pdf-files/From-azure-blob-storage.md | 33 +- .../From-dropbox-cloud-file-storage.md | 41 +- .../From-google-cloud-storage.md | 40 +- .../NET/Open-pdf-files/From-google-drive.md | 94 ++-- .../NET/Save-pdf-files/To-AWS-S3.md | 25 +- .../Save-pdf-files/To-azure-blob-storage.md | 78 +-- .../To-dropbox-cloud-file-storage.md | 54 +- .../Save-pdf-files/To-google-cloud-storage.md | 53 +- .../NET/Save-pdf-files/To-google-drive.md | 126 +++-- .../NET/Working-with-OCR/AWS-Textract.md | 10 +- .../Azure-Kubernetes-Service.md | 7 +- .../NET/Working-with-OCR/Azure-Vision.md | 11 +- .../NET/Working-with-OCR/Features.md | 494 ++++++------------ .../NET/Working-with-OCR/Troubleshooting.md | 12 +- ...-PDF-document-in-ASP-NET-Core-JetBrains.md | 46 +- ...te-PDF-document-in-ASP-NET-Core-VS-Code.md | 6 +- ...-document-in-ASP-NET-Core-Visual-Studio.md | 74 ++- ...e-PDF-document-in-Blazor-MaUI-JetBrains.md | 100 ++-- ...ate-PDF-document-in-Blazor-MaUI-VS-Code.md | 104 ++-- ...F-document-in-Blazor-MaUI-Visual-studio.md | 100 ++-- ...PDF-document-in-Blazor-Server-JetBrains.md | 2 +- ...document-in-Blazor-Server-Visual-studio.md | 2 +- ...e-PDF-document-in-Blazor-WASM-JetBrains.md | 2 +- ...F-document-in-Blazor-WASM-Visual-studio.md | 4 +- ...reate-PDF-document-in-Console-JetBrains.md | 2 +- ...e-PDF-document-in-Console-Visual-Studio.md | 4 +- .../Create-PDF-document-in-MaUI-JetBrains.md | 22 +- .../Create-PDF-document-in-MaUI-VS-Code.md | 32 +- ...eate-PDF-document-in-MaUI-Visual-Studio.md | 21 +- .../Create-PDF-document-in-Mac-OS-VS-Code.md | 12 +- ...te-PDF-document-in-Mac-OS-Visual-Studio.md | 7 +- 44 files changed, 883 insertions(+), 1128 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 756947697..9d5775c35 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 @@ -16,14 +16,14 @@ Syncfusion® HTML-to-PDF converter will work seamlessly in various * Converts any [webpage to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-pdf). * Converts any raw [HTML string to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#html-string-to-pdf). * Converts [HTML form to fillable PDF form](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#html-form-to-pdf-form). -* Automatically creates [Table of Contents](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#table-of-contents). +* Automatically creates [Table of Contents](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#table-of-contents-with-custom-style). * Automatically creates [bookmark hierarchy](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#bookmarks). * Converts only a [part of the web page to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#partial-webpage-to-pdf). -* Supports PDF header and PDF footer. +* Supports PDF [header and PDF footer](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#header-and-footer). * Repeats HTML table header and footer in PDF. * Supports HTML5, CSS3, SVG, and Web fonts. * Converts any [HTML to an image](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-image). -* Converts any [SVG to image](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-image). +* Converts any [SVG to image](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#svg-file-to-image). * Supports accessing HTML pages using both [HTTP POST and GET](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#http-get-and-post). * Supports [cookies-based form authentication](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#form-authentication). * Thread safe. diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md index 55439dfed..cfd5f00b6 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/NuGet-Packages-Required.md @@ -20,7 +20,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, .NET8, and .NET9) {{'[Syncfusion.HtmlToPdfConverter.Net.Windows.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows/)'| markdownify }} @@ -28,7 +28,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, .NET8, and .NET9) {{'[Syncfusion.HtmlToPdfConverter.Net.Linux.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Linux/)'| markdownify }} @@ -36,7 +36,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, .NET8, and .NET9) {{'[Syncfusion.HtmlToPdfConverter.Net.Mac.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Mac/)'| markdownify }} @@ -44,7 +44,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, .NET8, and .NET9) {{'[Syncfusion.HtmlToPdfConverter.Net.Aws.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Aws/)'| markdownify }} diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md index 70695a8e2..be164c484 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/overview.md @@ -16,16 +16,15 @@ Syncfusion® HTML-to-PDF converter will work seamlessly in various * Converts any [webpage to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-pdf). * Converts any raw [HTML string to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#html-string-to-pdf). * Converts [HTML form to fillable PDF form](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#html-form-to-pdf-form). -* Automatically creates [Table of Contents](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#table-of-contents). +* Automatically creates [Table of Contents](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#table-of-contents-with-custom-style). * Automatically creates [bookmark hierarchy](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#bookmarks). * Converts only a [part of the web page to PDF](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#partial-webpage-to-pdf). -* Supports PDF header and PDF footer. +* Supports PDF [header and PDF footer](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#header-and-footer). * Repeats HTML table header and footer in PDF. * Supports HTML5, CSS3, SVG, and Web fonts. * Converts any [HTML to an image](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-image). -* Converts any [SVG to image](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#url-to-image). -* Supports accessing HTML pages using both [HTTP POST and GET](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#http-get-and-post) methods. -* Supports [HTTP cookies](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#form-authentication). +* Converts any [SVG to image](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#svg-file-to-image). +* Supports accessing HTML pages using both [HTTP POST and GET](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#http-get-and-post). * Supports [cookies-based form authentication](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#form-authentication). * Thread safe. * Supports internal and external [hyperlinks](https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/features#hyperlinks). diff --git a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-AKS-Environment.md b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-AKS-Environment.md index 441d88179..3e3f3047e 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-AKS-Environment.md +++ b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-AKS-Environment.md @@ -23,22 +23,21 @@ Step 3: Click **Create** button. Step 4: Install the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/). ![Install Syncfusion.Pdf.Net.Core NuGet package](AKS_images/NuGet_package.png) - Step 5: A default action method named Index will be present in *HomeController.cs*. Right click on Index method and select Go To View where you will be directed to its associated view page *Index.cshtml*. Add a new button in the *Index.cshtml* as shown below. {% tabs %} {% highlight c# tabtitle="C#" %} - @{ - Html.BeginForm("CreatePDFDocument", "Home", FormMethod.Get); - { -
- -
- } - Html.EndForm(); +@{ + Html.BeginForm("CreatePDFDocument", "Home", FormMethod.Get); + { +
+ +
} + Html.EndForm(); +} {% endhighlight %} @@ -50,10 +49,10 @@ Step 6: Include the following namespaces in *HomeController.cs*. {% highlight c# tabtitle="C#" %} - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf; - using System.Diagnostics; - using Syncfusion.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using System.Diagnostics; +using Syncfusion.Drawing; {% endhighlight %} @@ -65,7 +64,7 @@ Step 7: Add a new action method named CreatePDFDocument in HomeController.cs fil {% highlight c# tabtitle="C#" %} - public IActionResult CreatePDFDocument() +public IActionResult CreatePDFDocument() { //Create a new PDF document. PdfDocument document = new PdfDocument(); @@ -165,7 +164,7 @@ Step 2: You need to gather the credentials in order to interact with the cluster {% highlight c# tabtitle="C#" %} - az aks get-credentials --resource-group CreatePdfDocument --name aks-uk-demo-msdn +az aks get-credentials --resource-group CreatePdfDocument --name aks-uk-demo-msdn {% endhighlight %} @@ -175,7 +174,7 @@ Step 3: You can review the credentials with the following command: {% tabs %} {% highlight c# tabtitle="C#" %} - cat .kube/config +cat .kube/config {% endhighlight %} @@ -187,7 +186,7 @@ Step 4: Now in the Cloud Shell, create a new file called deploy.yaml as follows: {% tabs %} {% highlight c# tabtitle="C#" %} - code deploy.yaml +code deploy.yaml {% endhighlight %} @@ -236,7 +235,7 @@ Step 6: Once you save and close the code editor, it’s finally time to apply th {% tabs %} {% highlight c# tabtitle="C#" %} - kubectl apply -f deploy.yaml +kubectl apply -f deploy.yaml {% endhighlight %} @@ -250,10 +249,10 @@ Step 8: You can run the following commands: {% tabs %} {% highlight c# tabtitle="C#" %} - kubectl get pods - kubectl get nodes - kubectl get service - kubectl describe deployment +kubectl get pods +kubectl get nodes +kubectl get service +kubectl describe deployment {% endhighlight %} {% endtabs %} @@ -262,7 +261,7 @@ or {% tabs %} {% highlight c# tabtitle="C#" %} - kubectl get all +kubectl get all {% endhighlight %} {% endtabs %} @@ -286,8 +285,8 @@ If you want to clean up the cluster, you can run the following commands: {% tabs %} {% highlight c# tabtitle="C#" %} - kubectl delete -f deploy.yaml - kubectl delete svc asp-docker-app --namespace=default +kubectl delete -f deploy.yaml +kubectl delete svc asp-docker-app --namespace=default {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-AWS-Elastic-Beanstalk.md b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-AWS-Elastic-Beanstalk.md index dfcdabdfb..91599fc0b 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-AWS-Elastic-Beanstalk.md +++ b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-AWS-Elastic-Beanstalk.md @@ -29,11 +29,11 @@ Step 4: A default controller named HomeController.cs gets added to create the AS {% tabs %} {% highlight c# tabtitle="C#" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf.Grid; - using Syncfusion.Pdf.Parsing; - using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Drawing; {% endhighlight %} {% endtabs %} @@ -43,18 +43,18 @@ Step 5: Add a new button in index.cshtml as follows {% tabs %} {% highlight c# tabtitle="C#" %} - @{ - Html.BeginForm("CreatePDF", "Home", FormMethod.Get); - { -
- -
-
- @ViewBag.Message -
+@{ +Html.BeginForm("CreatePDF", "Home", FormMethod.Get); +{ +
+ +
+
+ @ViewBag.Message
- } - Html.EndForm(); +
+} +Html.EndForm(); } {% endhighlight %} @@ -65,43 +65,43 @@ Step 6: Add a new action method named CreatePDF in HomeController.cs file and in {% tabs %} {% highlight c# tabtitle="C#" %} - public IActionResult CreatePDF() - { - //Open an existing PDF document. - FileStream fileStream = new FileStream("Data/Input.pdf", FileMode.Open, FileAccess.Read); - PdfLoadedDocument document = new PdfLoadedDocument(fileStream); - - //Get the first page from a document. - PdfLoadedPage page = document.Pages[0] as PdfLoadedPage; - - //Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; - - //Create a PdfGrid. - PdfGrid pdfGrid = new PdfGrid(); - //Add values to the list. - List data = new List(); - data.Add(new { Product_ID = "1001", Product_Name = "Bicycle", Price = "10,000" }); - data.Add(new { Product_ID = "1002", Product_Name = "Head Light", Price = "3,000" }); - data.Add(new { Product_ID = "1003", Product_Name = "Break wire", Price = "1,500" }); - - //Assign data source. - pdfGrid.DataSource = data; - - //Apply built-in table style. - pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent3); - - //Draw the grid to the page of PDF document. - pdfGrid.Draw(graphics, new RectangleF(40, 400, page.Size.Width - 80, 0)); - //Create the memory stream. - MemoryStream stream = new MemoryStream(); - //Save the document to the memory stream. - document.Save(stream); - //Close the documet - document.Close(true); - //Return the PDF file as a download - return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "Output.pdf"); - } +public IActionResult CreatePDF() +{ + //Open an existing PDF document. + FileStream fileStream = new FileStream("Data/Input.pdf", FileMode.Open, FileAccess.Read); + PdfLoadedDocument document = new PdfLoadedDocument(fileStream); + + //Get the first page from a document. + PdfLoadedPage page = document.Pages[0] as PdfLoadedPage; + + //Create PDF graphics for the page. + PdfGraphics graphics = page.Graphics; + + //Create a PdfGrid. + PdfGrid pdfGrid = new PdfGrid(); + //Add values to the list. + List data = new List(); + data.Add(new { Product_ID = "1001", Product_Name = "Bicycle", Price = "10,000" }); + data.Add(new { Product_ID = "1002", Product_Name = "Head Light", Price = "3,000" }); + data.Add(new { Product_ID = "1003", Product_Name = "Break wire", Price = "1,500" }); + + //Assign data source. + pdfGrid.DataSource = data; + + //Apply built-in table style. + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent3); + + //Draw the grid to the page of PDF document. + pdfGrid.Draw(graphics, new RectangleF(40, 400, page.Size.Width - 80, 0)); + //Create the memory stream. + MemoryStream stream = new MemoryStream(); + //Save the document to the memory stream. + document.Save(stream); + //Close the documet + document.Close(true); + //Return the PDF file as a download + return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "Output.pdf"); +} {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-AWS-Lambda.md b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-AWS-Lambda.md index 3e88a4918..6f391393a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-AWS-Lambda.md +++ b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-AWS-Lambda.md @@ -35,11 +35,11 @@ Step 6: Include the following namespaces in the **Function.cs** file. {% tabs %} {% highlight c# tabtitle="C#" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Drawing; - using Syncfusion.Pdf.Parsing; - using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Drawing; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf.Grid; {% endhighlight %} {% endtabs %} @@ -49,43 +49,43 @@ step 7: Add the following code in Function.cs to open the PDF document and updat {% tabs %} {% highlight c# tabtitle="C#" %} - string filePath = Path.GetFullPath(@"Data/Input.pdf"); - //Open an existing PDF document. - using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) - { - PdfLoadedDocument document = new PdfLoadedDocument(stream); - - //Get the first page from a document. - PdfLoadedPage page = document.Pages[0] as PdfLoadedPage; - - //Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; - - //Create a PdfGrid. - PdfGrid pdfGrid = new PdfGrid(); - //Add values to the list. - List data = new List(); - data.Add(new { Product_ID = "1001", Product_Name = "Bicycle", Price = "10,000" }); - data.Add(new { Product_ID = "1002", Product_Name = "Head Light", Price = "3,000" }); - data.Add(new { Product_ID = "1003", Product_Name = "Break wire", Price = "1,500" }); +string filePath = Path.GetFullPath(@"Data/Input.pdf"); +//Open an existing PDF document. +using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) +{ + PdfLoadedDocument document = new PdfLoadedDocument(stream); + + //Get the first page from a document. + PdfLoadedPage page = document.Pages[0] as PdfLoadedPage; + + //Create PDF graphics for the page. + PdfGraphics graphics = page.Graphics; + + //Create a PdfGrid. + PdfGrid pdfGrid = new PdfGrid(); + //Add values to the list. + List data = new List(); + data.Add(new { Product_ID = "1001", Product_Name = "Bicycle", Price = "10,000" }); + data.Add(new { Product_ID = "1002", Product_Name = "Head Light", Price = "3,000" }); + data.Add(new { Product_ID = "1003", Product_Name = "Break wire", Price = "1,500" }); - //Assign data source. - pdfGrid.DataSource = data; + //Assign data source. + pdfGrid.DataSource = data; - //Apply built-in table style. - pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent3); + //Apply built-in table style. + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent3); - //Draw the grid to the page of PDF document. - pdfGrid.Draw(graphics, new RectangleF(40, 400, page.Size.Width - 80, 0)); + //Draw the grid to the page of PDF document. + pdfGrid.Draw(graphics, new RectangleF(40, 400, page.Size.Width - 80, 0)); - //Save the document into stream. - MemoryStream memoryStream = new MemoryStream(); - document.Save(memoryStream); - //Close the document. - document.Close(true); - //return the stream as base64 string - return Convert.ToBase64String(memoryStream.ToArray()); - } + //Save the document into stream. + MemoryStream memoryStream = new MemoryStream(); + document.Save(memoryStream); + //Close the document. + document.Close(true); + //return the stream as base64 string + return Convert.ToBase64String(memoryStream.ToArray()); +} {% endhighlight %} {% endtabs %} @@ -127,11 +127,11 @@ Step 3: Include the following namespaces in Program.cs file. {% tabs %} {% highlight c# tabtitle="C#" %} - using Amazon; - using Amazon.Lambda; - using Amazon.Lambda.Model; - using Newtonsoft.Json; - using System.IO; +using Amazon; +using Amazon.Lambda; +using Amazon.Lambda.Model; +using Newtonsoft.Json; +using System.IO; {% endhighlight %} {% endtabs %} @@ -141,34 +141,34 @@ Step 4: Add the following code sample in Program.cs to invoke the published AWS {% tabs %} {% highlight c# tabtitle="C#" %} - //Create a new AmazonLambdaClient - AmazonLambdaClient client = new AmazonLambdaClient("awsaccessKeyID", "awsSecreteAccessKey", RegionEndpoint.USEast1); - //Create new InvokeRequest with published function name. - InvokeRequest invoke = new InvokeRequest - { - FunctionName = "MyNewFunction", //Add your lambda function name here - InvocationType = InvocationType.RequestResponse, - Payload = "\"Test\"" - }; - //Get the InvokeResponse from client InvokeRequest - InvokeResponse response = await client.InvokeAsync(invoke); - //Read the response stream - var stream = new StreamReader(response.Payload); - //Deserialize the response stream - JsonReader reader = new JsonTextReader(stream); - JsonSerializer serializer = new JsonSerializer(); - var responseText = serializer.Deserialize(reader); - - //Convert Base64String into byte array - byte[] bytes = Convert.FromBase64String(responseText.ToString()); - - //Write the byte array into a file - FileStream fileStream = new FileStream("Sample.pdf", FileMode.Create); - fileStream.Write(bytes, 0, bytes.Length); - fileStream.Flush(); - fileStream.Dispose(); - - System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo() { FileName = "Sample.pdf", UseShellExecute = true }); +//Create a new AmazonLambdaClient +AmazonLambdaClient client = new AmazonLambdaClient("awsaccessKeyID", "awsSecreteAccessKey", RegionEndpoint.USEast1); +//Create new InvokeRequest with published function name. +InvokeRequest invoke = new InvokeRequest +{ + FunctionName = "MyNewFunction", //Add your lambda function name here + InvocationType = InvocationType.RequestResponse, + Payload = "\"Test\"" +}; +//Get the InvokeResponse from client InvokeRequest +InvokeResponse response = await client.InvokeAsync(invoke); +//Read the response stream +var stream = new StreamReader(response.Payload); +//Deserialize the response stream +JsonReader reader = new JsonTextReader(stream); +JsonSerializer serializer = new JsonSerializer(); +var responseText = serializer.Deserialize(reader); + +//Convert Base64String into byte array +byte[] bytes = Convert.FromBase64String(responseText.ToString()); + +//Write the byte array into a file +FileStream fileStream = new FileStream("Sample.pdf", FileMode.Create); +fileStream.Write(bytes, 0, bytes.Length); +fileStream.Flush(); +fileStream.Dispose(); + +System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo() { FileName = "Sample.pdf", UseShellExecute = true }); {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-Console.md b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-Console.md index 216d5fb61..cb0f12707 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-Console.md +++ b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-file-in-Console.md @@ -71,7 +71,8 @@ Step 5: Include the following code sample in *Program.cs* to create a PDF file. {% highlight c# tabtitle="C#" %} //Create a new PDF document. -using (PdfDocument document = new PdfDocument()) { +using (PdfDocument document = new PdfDocument()) +{ //Add a page to the document. PdfPage page = document.Pages.Add(); //Create PDF graphics for a page. @@ -88,11 +89,11 @@ using (PdfDocument document = new PdfDocument()) { Step 6: Build the project. -Click on Build > Build Solution or press Ctrl + Shift + B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 7: Run the project. -Click the Start button (green arrow) or press F5 to run the app. +Click the **Run** button (green arrow) in the toolbar or press F5 to run the app. You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Getting%20Started/Console/.NET%20Framework/Create%20PDF). diff --git a/Document-Processing/PDF/PDF-Library/NET/FAQs/Font-stream-dispose-before-saving-PDF-document.md b/Document-Processing/PDF/PDF-Library/NET/FAQs/Font-stream-dispose-before-saving-PDF-document.md index 5595bc44f..c884e11dd 100644 --- a/Document-Processing/PDF/PDF-Library/NET/FAQs/Font-stream-dispose-before-saving-PDF-document.md +++ b/Document-Processing/PDF/PDF-Library/NET/FAQs/Font-stream-dispose-before-saving-PDF-document.md @@ -41,10 +41,7 @@ using (FileStream fontStream = new FileStream("path_to_custom_font.ttf", FileMod page.Graphics.DrawString("Hello, Syncfusion PDF!", font, PdfBrushes.Black, new Syncfusion.Drawing.PointF(100, 100)); // Save the document to a file - using (FileStream fs = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) - { - document.Save(fs); - } + document.Save("Output.pdf"); } // PdfDocument is disposed here } // Font stream is disposed here after saving diff --git a/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md b/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md index 3158845ff..66d0c61e3 100644 --- a/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md +++ b/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md @@ -5,7 +5,7 @@ platform: document-processing documentation: UG --- -# Resolving Namespace Conflicts in Syncfusion® PDF Packages +# Resolving Namespace Conflicts in Syncfusion® PDF Packages ## Conflict Scenario diff --git a/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-Save-PDF-document-AWS-Lambda.md b/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-Save-PDF-document-AWS-Lambda.md index dd09a6f30..8152cdb3b 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-Save-PDF-document-AWS-Lambda.md +++ b/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-Save-PDF-document-AWS-Lambda.md @@ -49,9 +49,8 @@ step 7: Add the following code sample in **Function.cs** to **open a PDF documen {% tabs %} {% highlight c# tabtitle="C#" %} -//Open an existing PDF document. -FileStream document = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(stream); +//Load an existing PDF document. +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-save-PDF-document-in-ASP-NET-Core.md b/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-save-PDF-document-in-ASP-NET-Core.md index fb4964c45..96e1e3c70 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-save-PDF-document-in-ASP-NET-Core.md +++ b/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-save-PDF-document-in-ASP-NET-Core.md @@ -65,10 +65,8 @@ Step 6: Add a new action method **OpenAndSaveDocument** in HomeController.cs and {% highlight c# tabtitle="C#" %} -//Load PDF document as stream. -FileStream docStream = new FileStream("Input.docx", FileMode.Open, FileAccess.Read); //Load an existing PDF document. -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); {% endhighlight %} 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 2f6947346..a50bc565c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md +++ b/Document-Processing/PDF/PDF-Library/NET/NuGet-Packages-Required.md @@ -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, .NET8, and .NET9) {{'[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, .NET8, and .NET9) {{'[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, .NET8, and .NET9) {{'[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, .NET8, and .NET9) {{'[Syncfusion.HtmlToPdfConverter.Net.Aws.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Aws/)'| markdownify }} 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 c13f68075..cbf749d73 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 cdcf6c0da..59311c999 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,38 +25,37 @@ 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 %} {% endtabs %} - Step 5: Add the below code example to load a PDF from Azure blob storage. {% tabs %} {% 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 4fe84327c..ddebc43fc 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 @@ -11,11 +11,8 @@ To Open a PDF file from Dropbox cloud file storage, you can follow the steps bel Step 1: Create a Dropbox API - To create a Dropbox API App, you should follow the official documentation provided by Dropbox [link](https://www.dropbox.com/developers/documentation/dotnet#tutorial). The process involves visiting the Dropbox Developer website and using their App Console to set up your API app. This app will allow you to interact with Dropbox programmatically, enabling secure access to files and data. - - Step 2: Create a simple console application ![Project configuration window](Open-PDF-Images/Console-Application.png) @@ -29,7 +26,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 +39,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 9c93ae372..2f7b1bc32 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 @@ -9,7 +9,6 @@ documentation: UG To Open a PDF file from Google cloud storage, you can follow the steps below - Step 1: Create a simple console application ![Project configuration window](Open-PDF-Images/Console-Application.png) @@ -18,15 +17,14 @@ Step 3: Install the [Google.Cloud.Storage.V1](https://www.nuget.org/packages/Goo ![NuGet package installation](Open-PDF-Images/Google.Cloud.Storage.V1-nuget.png) - Step 4: Include the following namespaces in the Program.cs file. {% tabs %} {% 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 +37,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 c41da9125..1c1ca7b0f 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/Save-pdf-files/To-AWS-S3.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md index 671681c49..d6a483d35 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md @@ -20,34 +20,32 @@ Step 2: Install the [Syncfusion.Pdf.Net.Core ](https://www.nuget.org/packages/Sy

![NuGet package installation](Save-PDF-Images/AWSSDK.S3-nuget.png) - Step 3: Include the following namespaces in the Program.cs file. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf; - using Amazon.S3; - using Syncfusion.Drawing; - using Amazon.S3.Transfer; - using Amazon; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using Amazon.S3; +using Syncfusion.Drawing; +using Amazon.S3.Transfer; +using Amazon; {% endhighlight %} {% endtabs %} - Step 4: Add the below code example to create a simple PDF and save in AWS S3. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} - // Create a new PDF document - using (PdfDocument document = new PdfDocument()) - { +// Create a new PDF document +using (PdfDocument document = new PdfDocument()) +{ // Add a page to the document PdfPage page = document.Pages.Add(); @@ -85,11 +83,6 @@ Step 4: Add the below code example to create a simple PDF and save in AWS S3. } } } - - - - - {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-azure-blob-storage.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-azure-blob-storage.md index cdc1c6655..8a3271fa3 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-azure-blob-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-azure-blob-storage.md @@ -26,11 +26,11 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Drawing; - using Microsoft.Azure.Storage; - using Microsoft.Azure.Storage.Blob; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Drawing; +using Microsoft.Azure.Storage; +using Microsoft.Azure.Storage.Blob; {% endhighlight %} @@ -43,40 +43,40 @@ Step 5: Add the below code example to create a simple PDF and save in Azure blob {% highlight c# tabtitle="C# [Cross-platform]" %} - // Create a new PDF document - using (PdfDocument doc = new PdfDocument()) - { - // Add a page to the document. - PdfPage page = doc.Pages.Add(); - // Get the graphics object for drawing on the page. - PdfGraphics graphics = page.Graphics; - // Create a font to use for drawing text - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); - // Draw the text. - graphics.DrawString("Hello, World!", font, PdfBrushes.Black, new PointF(10, 10)); - // Create a memory stream to save the PDF document. - MemoryStream stream = new MemoryStream(); - doc.Save(stream); - // Write the contents of the memory stream to a file named "sample.pdf". - File.WriteAllBytes("sample.pdf", stream.ToArray()); - // Close the document - doc.Close(true); - } - // Parse the connection string for the Azure Storage Account. - CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); - // Create a client for accessing Blob storage. - CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); - // Get a reference to the container name. - CloudBlobContainer container = blobClient.GetContainerReference(containerName); - container.CreateIfNotExists(); - // Get a reference to the block blob name. - CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName); - // Open the local file "sample.pdf" for reading - using (var fileStream = File.OpenRead("sample.pdf")) - { - // Upload the contents of the local file to the Azure Blob Storage - blockBlob.UploadFromStream(fileStream); - } +// Create a new PDF document +using (PdfDocument doc = new PdfDocument()) +{ + // Add a page to the document. + PdfPage page = doc.Pages.Add(); + // Get the graphics object for drawing on the page. + PdfGraphics graphics = page.Graphics; + // Create a font to use for drawing text + PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); + // Draw the text. + graphics.DrawString("Hello, World!", font, PdfBrushes.Black, new PointF(10, 10)); + // Create a memory stream to save the PDF document. + MemoryStream stream = new MemoryStream(); + doc.Save(stream); + // Write the contents of the memory stream to a file named "sample.pdf". + File.WriteAllBytes("sample.pdf", stream.ToArray()); + // Close the document + doc.Close(true); +} +// Parse the connection string for the Azure Storage Account. +CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); +// Create a client for accessing Blob storage. +CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); +// Get a reference to the container name. +CloudBlobContainer container = blobClient.GetContainerReference(containerName); +container.CreateIfNotExists(); +// Get a reference to the block blob name. +CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName); +// Open the local file "sample.pdf" for reading +using (var fileStream = File.OpenRead("sample.pdf")) +{ + // Upload the contents of the local file to the Azure Blob Storage + blockBlob.UploadFromStream(fileStream); +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-dropbox-cloud-file-storage.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-dropbox-cloud-file-storage.md index 7db51e8f9..09daa442f 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-dropbox-cloud-file-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-dropbox-cloud-file-storage.md @@ -30,11 +30,11 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf; - using Dropbox.Api; - using Dropbox.Api.Files; - using Syncfusion.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using Dropbox.Api; +using Dropbox.Api.Files; +using Syncfusion.Drawing; {% endhighlight %} @@ -47,31 +47,31 @@ Step 5: Add the below code example to create a simple PDF and save in Dropbox cl {% highlight c# tabtitle="C# [Cross-platform]" %} - // Create a new PDF document. - PdfDocument doc = new PdfDocument(); - // Add a new page to the document. - PdfPage page = doc.Pages.Add(); - // Get the graphics object for the page to draw on. - PdfGraphics graphics = page.Graphics; - // Create a font for drawing text. - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); - // Draw the text - graphics.DrawString("Hello, World!", font, PdfBrushes.Black, new PointF(10, 10)); - // Save the PDF to a memory stream. - MemoryStream stream = new MemoryStream(); - doc.Save(stream); - // Close the PDF document. - doc.Close(true); - var accessToken = "YOUR_ACCESS_TOKEN";// Replace with your actual access token - // Initialize a DropboxClient with the provided access token. - using (var dbx = new DropboxClient(accessToken)) - { - // Upload the PDF to Dropbox. - var uploadResult = await dbx.Files.UploadAsync( +// Create a new PDF document. +PdfDocument doc = new PdfDocument(); +// Add a new page to the document. +PdfPage page = doc.Pages.Add(); +// Get the graphics object for the page to draw on. +PdfGraphics graphics = page.Graphics; +// Create a font for drawing text. +PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); +// Draw the text +graphics.DrawString("Hello, World!", font, PdfBrushes.Black, new PointF(10, 10)); +// Save the PDF to a memory stream. +MemoryStream stream = new MemoryStream(); +doc.Save(stream); +// Close the PDF document. +doc.Close(true); +var accessToken = "YOUR_ACCESS_TOKEN";// Replace with your actual access token +// Initialize a DropboxClient with the provided access token. +using (var dbx = new DropboxClient(accessToken)) +{ + // Upload the PDF to Dropbox. + var uploadResult = await dbx.Files.UploadAsync( "/path/to/save/Sample.pdf", WriteMode.Overwrite.Instance, body: new MemoryStream(stream.ToArray())); - } +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-cloud-storage.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-cloud-storage.md index 3b6573552..637e7b38f 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-cloud-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-cloud-storage.md @@ -9,7 +9,6 @@ documentation: UG To save a PDF file to Google cloud storage, you can follow the steps below - Step 1: Create a simple console application ![Project configuration window](Save-PDF-Images/Console-Application.png) @@ -19,57 +18,53 @@ Step 3: Install the [Syncfusion.Pdf.Net.Core ](https://www.nuget.org/packages/Sy

![NuGet package installation](Save-PDF-Images/Google.Cloud.Storage.V1-nuget.png) - Step 4: Include the following namespaces in the Program.cs file. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} - using Syncfusion.Pdf; - using Google.Cloud.Storage.V1; - using Syncfusion.Pdf.Graphics; - using Google.Apis.Auth.OAuth2; - using Syncfusion.Drawing; - using System.IO; +using Syncfusion.Pdf; +using Google.Cloud.Storage.V1; +using Syncfusion.Pdf.Graphics; +using Google.Apis.Auth.OAuth2; +using Syncfusion.Drawing; +using System.IO; {% endhighlight %} {% endtabs %} - Step 5: Add the below code example to create a simple PDF and save in Google cloud storage. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} - // Step 1: Create a PDF document - PdfDocument document = new PdfDocument(); - - // Step 2: Add a page - PdfPage page = document.Pages.Add(); - - // Step 3: Add content to the page (e.g., text, images, etc.) - PdfGraphics graphics = page.Graphics; - graphics.DrawString("Hello, World!", new PdfStandardFont(PdfFontFamily.Helvetica, 12), PdfBrushes.Black, new PointF(10, 10)); +// Step 1: Create a PDF document +PdfDocument document = new PdfDocument(); - // Step 4: Save the PDF to a memory stream - MemoryStream stream = new MemoryStream(); - document.Save(stream); - document.Close(true); +// Step 2: Add a page +PdfPage page = document.Pages.Add(); - // Step 5: Upload the PDF to Google Cloud Storage - // Load the credentials file - GoogleCredential credential = GoogleCredential.FromFile("credentials.json");//Replace with your actual credentials.json +// Step 3: Add content to the page (e.g., text, images, etc.) +PdfGraphics graphics = page.Graphics; +graphics.DrawString("Hello, World!", new PdfStandardFont(PdfFontFamily.Helvetica, 12), PdfBrushes.Black, new PointF(10, 10)); - // Create a storage client - StorageClient storage = StorageClient.Create(credential); +// Step 4: Save the PDF to a memory stream +MemoryStream stream = new MemoryStream(); +document.Save(stream); +document.Close(true); - // Upload the PDF to the specified bucket and object name - storage.UploadObject("bucketName", "Sample.pdf", null, stream);// +// Step 5: Upload the PDF to Google Cloud Storage +// Load the credentials file +GoogleCredential credential = GoogleCredential.FromFile("credentials.json");//Replace with your actual credentials.json +// Create a storage client +StorageClient storage = StorageClient.Create(credential); +// Upload the PDF to the specified bucket and object name +storage.UploadObject("bucketName", "Sample.pdf", null, stream);// {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-drive.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-drive.md index c8c288478..476cad1aa 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-drive.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-drive.md @@ -29,81 +29,79 @@ Step 4: Include the following namespaces in the Program.cs file. {% highlight c# tabtitle="C# [Cross-platform]" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Google.Apis.Auth.OAuth2; - using Google.Apis.Drive.v3; - using Google.Apis.Services; - using Google.Apis.Util.Store; - using File = Google.Apis.Drive.v3.Data.File; - using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Google.Apis.Auth.OAuth2; +using Google.Apis.Drive.v3; +using Google.Apis.Services; +using Google.Apis.Util.Store; +using File = Google.Apis.Drive.v3.Data.File; +using Syncfusion.Drawing; {% endhighlight %} {% endtabs %} - Step 5: Add the below code example to create a simple PDF and save in google drive. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} - // Create a new PDF document - PdfDocument document = new PdfDocument(); - // Add a new page to the document - PdfPage page = document.Pages.Add(); - // Get graphics object for the page - PdfGraphics graphics = page.Graphics; - // Draw text on the page - graphics.DrawString("Hello, World!", new PdfStandardFont(PdfFontFamily.Helvetica, 12), PdfBrushes.Black, new PointF(10, 10)); - // Create a memory stream to save the PDF document - MemoryStream stream = new MemoryStream(); - // Save the document to the memory stream - document.Save(stream); - // Close the document - document.Close(true); - - // Load Google Drive API credentials from a file - UserCredential credential; - string[] Scopes = { DriveService.Scope.Drive }; - string ApplicationName = "YourAppName"; - - using (var stream1 = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))//Replace with your actual credentials.json - { - string credPath = "token.json"; - // Authorize the Google Drive API access - credential = GoogleWebAuthorizationBroker.AuthorizeAsync( - GoogleClientSecrets.Load(stream1).Secrets, - Scopes, - "user", - CancellationToken.None, - new FileDataStore(credPath, true)).Result; - } - // Create a new instance of Google Drive service - var service = new DriveService(new BaseClientService.Initializer() - { - HttpClientInitializer = credential, - ApplicationName = ApplicationName, - }); - - - // Create metadata for the file to be uploaded - var fileMetadata = new File() - { - Name = "Sample1.pdf", // Name of the file in Google Drive - MimeType = "application/pdf", - }; - FilesResource.CreateMediaUpload request; - - // Create a memory stream from the PDF document - using (var fs = new MemoryStream(stream.ToArray())) - { - // Create an upload request for Google Drive - request = service.Files.Create(fileMetadata, fs, "application/pdf"); - // Upload the file - request.Upload(); - } +// Create a new PDF document +PdfDocument document = new PdfDocument(); +// Add a new page to the document +PdfPage page = document.Pages.Add(); +// Get graphics object for the page +PdfGraphics graphics = page.Graphics; +// Draw text on the page +graphics.DrawString("Hello, World!", new PdfStandardFont(PdfFontFamily.Helvetica, 12), PdfBrushes.Black, new PointF(10, 10)); +// Create a memory stream to save the PDF document +MemoryStream stream = new MemoryStream(); +// Save the document to the memory stream +document.Save(stream); +// Close the document +document.Close(true); + +// Load Google Drive API credentials from a file +UserCredential credential; +string[] Scopes = { DriveService.Scope.Drive }; +string ApplicationName = "YourAppName"; + +using (var stream1 = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))//Replace with your actual credentials.json +{ + string credPath = "token.json"; + // Authorize the Google Drive API access + credential = GoogleWebAuthorizationBroker.AuthorizeAsync( + GoogleClientSecrets.Load(stream1).Secrets, + Scopes, + "user", + CancellationToken.None, + new FileDataStore(credPath, true)).Result; +} +// Create a new instance of Google Drive service +var service = new DriveService(new BaseClientService.Initializer() +{ + HttpClientInitializer = credential, + ApplicationName = ApplicationName, +}); + +// Create metadata for the file to be uploaded +var fileMetadata = new File() +{ + Name = "Sample1.pdf", // Name of the file in Google Drive + MimeType = "application/pdf", +}; +FilesResource.CreateMediaUpload request; + +// Create a memory stream from the PDF document +using (var fs = new MemoryStream(stream.ToArray())) +{ + // Create an upload request for Google Drive + request = service.Files.Create(fileMetadata, fs, "application/pdf"); + // Upload the file + request.Upload(); +} {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/AWS-Textract.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/AWS-Textract.md index 61912e2a3..4a0a5d953 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/AWS-Textract.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/AWS-Textract.md @@ -40,8 +40,7 @@ Step 4: Use the following code sample to perform OCR on a PDF document using [Pe using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Region.pdf", FileMode.Open); - PdfLoadedDocument lDoc = new PdfLoadedDocument(stream); + PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Set the OCR language. processor.Settings.Language = Languages.English; //Initialize the AWS Textract external OCR engine. @@ -49,14 +48,11 @@ using (OCRProcessor processor = new OCRProcessor()) processor.ExternalEngine = azureOcrEngine; //Perform OCR with input document. string text = processor.PerformOCR(lDoc); - //Create file stream. - FileStream fileStream = new FileStream("Output.pdf", FileMode.CreateNew); + //Save the document into stream. - lDoc.Save(fileStream); + lDoc.Save("Output.pdf"); //Close the document. lDoc.Close(); - stream.Dispose(); - fileStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Azure-Kubernetes-Service.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Azure-Kubernetes-Service.md index d832804f4..8479c43f0 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Azure-Kubernetes-Service.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Azure-Kubernetes-Service.md @@ -93,10 +93,9 @@ public ActionResult PerformOCR() lDoc.Close(); //Set the position as '0' stream.Position = 0; - //Download the PDF document in the browser - FileStreamResult fileStreamResult = new FileStreamResult(stream, "application/pdf"); - fileStreamResult.FileDownloadName = "Sample.pdf"; - return fileStreamResult; + + // Return file result + return File(stream.ToArray(), "application/pdf", "Sample.pdf"); } } diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Azure-Vision.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Azure-Vision.md index c2a02c3a4..3e0dcd603 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Azure-Vision.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Azure-Vision.md @@ -40,8 +40,7 @@ Step 4: Use the following code sample to perform OCR on a PDF document using [Pe using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument lDoc = new PdfLoadedDocument(stream); + PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Initialize the Azure vision OCR external engine. @@ -49,15 +48,11 @@ using (OCRProcessor processor = new OCRProcessor()) processor.ExternalEngine = azureOcrEngine; //Perform OCR. processor.PerformOCR(lDoc); - //Create file stream. - FileStream outputStream = new FileStream("OCR.pdf", FileMode.CreateNew); + //Save the document into stream. - lDoc.Save(outputStream); - //If the position is not set to '0' then the PDF will be empty. - outputStream.Position = 0; + lDoc.Save("Output.pdf"); //Close the document. lDoc.Close(true); - outputStream.Close(); } {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Features.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Features.md index 76588446a..bcb2f328d 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Features.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Features.md @@ -21,18 +21,13 @@ To perform OCR for an entire PDF document using [PerformOCR](https://help.syncfu using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -44,17 +39,13 @@ using (OCRProcessor processor = new OCRProcessor()) 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document) - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + 'Save the PDF document. + document.Save("Output.pdf) 'Close the document document.Close(True) End Using @@ -79,8 +70,7 @@ To perform OCR on a particular region or several regions of a PDF page with the using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; @@ -101,12 +91,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf"); //Close the document. document.Close(true); } @@ -118,8 +104,8 @@ using (OCRProcessor processor = new OCRProcessor()) 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English @@ -140,11 +126,8 @@ Using processor As OCRProcessor = New OCRProcessor() 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document) - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + 'Save the PDF document. + document.Save("Output.pdf) 'Close the document. document.Close(True) End Using @@ -171,8 +154,7 @@ The following code sample demonstrates the OCR processor with Tesseract version using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; @@ -181,12 +163,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document, tessdata (Language packs) and enabling isMemoryOptimized property. processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -198,8 +176,7 @@ using (OCRProcessor processor = new OCRProcessor()) 'Initialize the OCR processor with tesseract binaries folder path. Using processor As OCRProcessor = New OCRProcessor("TesseractBinaries/3.05/") 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English @@ -208,11 +185,9 @@ Using processor As OCRProcessor = New OCRProcessor("TesseractBinaries/3.05/") 'Perform OCR with input document, tessdata (Language packs) and enabling isMemoryOptimized property. processor.PerformOCR(document) - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -237,8 +212,7 @@ The following code sample explains the OCR processor with Tesseract version 4.0 using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; @@ -247,12 +221,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document, tessdata (Language packs) and enabling isMemoryOptimized property. processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -264,8 +234,7 @@ using (OCRProcessor processor = new OCRProcessor()) 'Initialize the OCR processor with tesseract binaries folder path. Using processor As OCRProcessor = New OCRProcessor("TesseractBinaries/4.0/") 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English @@ -273,12 +242,9 @@ Using processor As OCRProcessor = New OCRProcessor("TesseractBinaries/4.0/") processor.Settings.TesseractVersion = TesseractVersion.Version4_0 'Perform OCR with input document, tessdata (Language packs) and enabling isMemoryOptimized property. processor.PerformOCR(document) - - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -380,19 +346,14 @@ N> Memory optimization for performing OCR on large PDF documents is not supporte using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Perform OCR with input document, tessdata (Language packs) and enable isMemoryOptimized property. processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -404,19 +365,14 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Perform OCR with input document, tessdata (Language packs) and enable isMemoryOptimized property. processor.PerformOCR(document) - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using - + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -437,8 +393,7 @@ You can get the OCRed text from the rotated page of PDF document using the [Page using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Set OCR page auto detection rotation. @@ -446,12 +401,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -464,8 +415,7 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Set OCR page auto detection rotation. @@ -473,11 +423,8 @@ Using processor As OCRProcessor = New OCRProcessor() 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document) - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + 'Save the PDF document to file stream. + document.Save("Output.pdf") 'Close the document. document.Close(True) @@ -504,8 +451,7 @@ using (OCRProcessor processor = new OCRProcessor()) { // Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); - PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(stream); + PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); // Set the path to the tessdata folder. processor.TessDataPath = @"/path/to/tessdata-fast/or/tessdata-best"; @@ -513,12 +459,8 @@ using (OCRProcessor processor = new OCRProcessor()) // Perform OCR on the loaded PDF document. processor.PerformOCR(pdfLoadedDocument); - // Create a file stream to save the processed PDF document. - using (FileStream outputFileStream = new FileStream(@"Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - // Save the processed PDF document to the specified file stream. - pdfLoadedDocument.Save(outputFileStream); - } + // Save the processed PDF document. + pdfLoadedDocument.Save("Output.pdf"); // Close the loaded PDF document. pdfLoadedDocument.Close(true); } @@ -531,8 +473,7 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As New OCRProcessor() ' Load an existing PDF document. - Dim stream As New FileStream("Input.pdf", FileMode.Open, FileAccess.Read) - Dim pdfLoadedDocument As New PdfLoadedDocument(stream) + Dim pdfLoadedDocument As New PdfLoadedDocument("Input.pdf") ' Set the path to the tessdata folder. processor.TessDataPath = "/path/to/tessdata-fast/or/tessdata-best" @@ -540,11 +481,8 @@ Using processor As New OCRProcessor() ' Perform OCR on the loaded PDF document. processor.PerformOCR(pdfLoadedDocument) - ' Create a file stream to save the processed PDF document. - Using outputFileStream As New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - ' Save the processed PDF document to the specified file stream. - pdfLoadedDocument.Save(outputFileStream) - End Using + ' Save the processed PDF document. + pdfLoadedDocument.Save("Output.pdf") ' Close the loaded PDF document. pdfLoadedDocument.Close(True) @@ -567,8 +505,7 @@ You can get the OCRed text and its bounds from a scanned PDF document by using t using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; @@ -585,12 +522,8 @@ using (OCRProcessor processor = new OCRProcessor()) RectangleF bounds = line.Rectangle; } - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -603,8 +536,7 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Create the layout result. @@ -619,11 +551,8 @@ Using processor As OCRProcessor = New OCRProcessor() Dim bounds As RectangleF = line.Rectangle Next - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -656,8 +585,7 @@ The following code sample demonstrates the OCR processor with native call suppor using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Set tesseract OCR Engine. @@ -665,12 +593,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document, tessdata (Language packs) and enabling isMemoryOptimized property. processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -683,20 +607,16 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Set tesseract OCR Engine. processor.Settings.TesseractVersion = TesseractVersion.Version3_02 'Perform OCR with input document, tessdata (Language packs) and enabling isMemoryOptimized property. processor.PerformOCR(document) - - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -719,8 +639,7 @@ The following code sample demonstrates the OCR processor with native call suppor using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Set tesseract OCR Engine. @@ -730,12 +649,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document, tessdata (Language packs) and enabling isMemoryOptimized property. processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -748,8 +663,7 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Set tesseract OCR Engine. @@ -759,11 +673,8 @@ Using processor As OCRProcessor = New OCRProcessor() 'Perform OCR with input document, tessdata (Language packs) and enabling isMemoryOptimized property. processor.PerformOCR(document) - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -789,20 +700,15 @@ While performing OCR on an existing scanned PDF document, the OCR Processor will using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Set custom temp file path location. processor.Settings.TempFolder = "D:/Temp/"; //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -815,20 +721,16 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Set custom temp file path location. processor.Settings.TempFolder = "D:/Temp/" 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document) - - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -914,8 +816,7 @@ N> The page segmentation mode is supported only in the Tesseract version 4.0 and using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //** For .NET Framework only **. @@ -925,12 +826,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -943,8 +840,7 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English ' ** For .NET Framework only **. @@ -953,12 +849,9 @@ Using processor As OCRProcessor = New OCRProcessor() processor.Settings.PageSegment = PageSegMode.AutoOsd 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document) - - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -979,8 +872,7 @@ The [OCREngineMode](https://help.syncfusion.com/cr/document-processing/Syncfusio using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Set tesseract version. ** For .NET Framework only. ** @@ -990,12 +882,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -1008,8 +896,7 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Set tesseract version. ** For .NET Framework only. ** @@ -1018,12 +905,9 @@ Using processor As OCRProcessor = New OCRProcessor() processor.Settings.OCREngineMode = OCREngineMode.LSTMOnly 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document) - - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -1046,8 +930,7 @@ The [WhiteList](https://help.syncfusion.com/cr/document-processing/Syncfusion.OC using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Set tesseract version. ** For .NET Framework only. ** @@ -1059,12 +942,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -1077,8 +956,7 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Set tesseract version. ** For .NET Framework only. ** @@ -1089,12 +967,9 @@ Using processor As OCRProcessor = New OCRProcessor() processor.Settings.WhiteList = "PDF" 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document) - - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -1113,8 +988,8 @@ The [BlackList](https://help.syncfusion.com/cr/document-processing/Syncfusion.OC using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Set tesseract version. ** For .NET Framework only. ** @@ -1126,12 +1001,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -1143,8 +1014,7 @@ using (OCRProcessor processor = new OCRProcessor()) Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. - Dim stream As FileStream = New FileStream("Input.pdf", FileMode.Open) - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream) + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Set OCR language. processor.Settings.Language = Languages.English 'Set tesseract version. ** For .NET Framework only. ** @@ -1156,11 +1026,8 @@ Using processor As OCRProcessor = New OCRProcessor() 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document) - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + 'Save the PDF document. + document.Save("Output.pdf") 'Close the document. document.Close(True) End Using @@ -1197,12 +1064,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Process OCR by providing the bitmap image. PdfDocument document = processor.PerformOCR(imageStream); - //Create file stream. - using (FileStream outputFileStream = new FileStream(@"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"); //Close the document. document.Close(true); } @@ -1226,11 +1089,8 @@ Using processor As OCRProcessor = New OCRProcessor() 'Process OCR by providing the bitmap image. Dim document As PdfDocument = processor.PerformOCR(imageStream) - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + 'Save the PDF document. + document.Save("Output.pdf)) 'Close the document. document.Close(True) End Using @@ -1252,8 +1112,7 @@ You can perform OCR on Images with Unicode characters. To preserve the Unicode c using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language. processor.Settings.Language = Languages.English; //Sets Unicode font to preserve the Unicode characters in a PDF document. @@ -1262,12 +1121,8 @@ using (OCRProcessor processor = new OCRProcessor()) //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -1349,19 +1204,14 @@ N> You can get the TesseractBinaries or TessData files from the NuGet package ru using (OCRProcessor processor = new OCRProcessor(@"TesseractBinaries\")) { //Load an existing PDF document. - FileStream stream = new FileStream("Input.pdf", FileMode.Open); - PdfLoadedDocument document = new PdfLoadedDocument(stream); + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set OCR language to process. processor.Settings.Language = Languages.English; //Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document, @"TessData\"); - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); //Close the document. document.Close(true); } @@ -1380,11 +1230,8 @@ Using processor As OCRProcessor = New OCRProcessor("TesseractBinaries\") 'Perform OCR with input document and tessdata (Language packs). processor.PerformOCR(document, "TessData\") - 'Create file stream. - Using outputFileStream As FileStream = New FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite) - 'Save the PDF document to file stream. - document.Save(outputFileStream) - End Using + 'Save the PDF document. + document.Save("Output.pdf)) 'Close the document. document.Close(True) End Using @@ -1404,10 +1251,8 @@ To get the Image rotation angle, you can rotate the image with 4 angles (0,90,18 //Initialize the OCR processor.@ using (OCRProcessor processor = new OCRProcessor()) { - //Get the stream from an image file. - FileStream stream = new FileStream(@"D:\Input.pdf", FileMode.Open); - //Set the OCR language to process. - PdfLoadedDocument document = new PdfLoadedDocument(stream); + //Load an existing PDF document. + PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Set the OCR language. processor.Settings.Language = Languages.English; //Set the Unicode font to preserve the Unicode characters in a PDF document. @@ -1425,12 +1270,8 @@ using (OCRProcessor processor = new OCRProcessor()) } } } - //Create file stream. - using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf); } @@ -1440,10 +1281,8 @@ using (OCRProcessor processor = new OCRProcessor()) 'Initialize the OCR processor Using processor As OCRProcessor = New OCRProcessor() - 'Get the stream from an image file. - Dim stream As FileStream = New FileStream(@"D:\Input.pdf", FileMode.Open); - 'Set the OCR language to process. - Dim document As PdfLoadedDocument = New PdfLoadedDocument(stream); + 'Load an existing PDF document.. + Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf"); 'Set the OCR language. processor.Settings.Language = Languages.English; 'Set the Unicode font to preserve the Unicode characters in a PDF document. @@ -1485,21 +1324,17 @@ We have support to improve the image quality while performing OCR for an image o using (OCRProcessor processor = new OCRProcessor()) { //Load an existing PDF document. - FileStream stream = new FileStream("../../../document.pdf", FileMode.Open); - PdfLoadedDocument lDoc = new PdfLoadedDocument(stream); + PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Set the OCR language. processor.Settings.Language = Languages.English; processor.ImageProcessor = new ImageProcessor(); //Perform OCR with input document. string text = processor.PerformOCR(lDoc); - //Create file stream. - FileStream fileStream = new FileStream("../../../OCR.pdf", FileMode.CreateNew); - //Save the document into stream. - lDoc.Save(fileStream); + + //Save the document. + lDoc.Save("Output.pdf"); //Close the document. lDoc.Close(true); - stream.Dispose(); - fileStream.Dispose(); } {% endhighlight %} @@ -1509,8 +1344,7 @@ We have support to improve the image quality while performing OCR for an image o ' Initialize the OCR processor. Using processor As New OCRProcessor() ' Load an existing PDF document. - Dim stream As New FileStream("../../../document.pdf", FileMode.Open) - Dim lDoc As New PdfLoadedDocument(stream) + Dim lDoc As New PdfLoadedDocument("Input.pdf") ' Set the OCR language. processor.Settings.Language = Languages.English @@ -1519,16 +1353,11 @@ We have support to improve the image quality while performing OCR for an image o ' Perform OCR with input document. Dim text As String = processor.PerformOCR(lDoc) - ' Create file stream. - Dim fileStream As New FileStream("../../../OCR.pdf", FileMode.CreateNew) - ' Save the document into stream. - lDoc.Save(fileStream) + lDoc.Save("Output.pdf") ' Close the document. - lDoc.Close(true) - stream.Dispose() - fileStream.Dispose() + lDoc.Close(True) End Using {% endhighlight %} @@ -1572,11 +1401,8 @@ Here is a basic example of using Syncfusion® OCR processor with m 12 // Font size ); - // Open the PDF file to be processed - FileStream fileStream = new FileStream("Input.pdf", FileMode.Open); - - // Load the PDF document from the file stream - PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream); + // Load the PDF document + PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); // Configure OCR settings OCRSettings ocrSettings = new OCRSettings(); @@ -1590,18 +1416,11 @@ Here is a basic example of using Syncfusion® OCR processor with m // Perform OCR on the loaded PDF document, providing the path to the tessdata directory ocrProcessor.PerformOCR(loadedDocument, "tessdata"); - // Create a file stream to save the OCR-processed PDF - FileStream outputFileStream = new FileStream("OCR_Output.pdf", FileMode.Create); - - // Save the OCR-processed document to the file stream - loadedDocument.Save(outputFileStream); + // Save the OCR-processed document + loadedDocument.Save("Output.pdf"); // Close the loaded document and commit changes loadedDocument.Close(true); - - // Close the file streams - outputFileStream.Close(); - fileStream.Close(); } {% endhighlight %} @@ -1617,11 +1436,8 @@ Here is a basic example of using Syncfusion® OCR processor with m 12 // Font size ); - // Open the PDF file to be processed - FileStream fileStream = new FileStream("Input.pdf", FileMode.Open); - // Load the PDF document from the file stream - PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream); + PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); // Configure OCR settings OCRSettings ocrSettings = new OCRSettings(); @@ -1654,11 +1470,8 @@ Here is a basic example of using Syncfusion® OCR processor with m New FileStream("arialuni.ttf", FileMode.Open), ' Path to the TrueType font file 12 ' Font size ) - - ' Open the PDF file to be processed - Using fileStream As New FileStream("Input.pdf", FileMode.Open) ' Load the PDF document from the file stream - Dim loadedDocument As New PdfLoadedDocument(fileStream) + Dim loadedDocument As New PdfLoadedDocument("Input.pdf") ' Configure OCR settings Dim ocrSettings As New OCRSettings() @@ -1672,10 +1485,8 @@ Here is a basic example of using Syncfusion® OCR processor with m ' Perform OCR on the loaded PDF document, providing the path to the tessdata directory ocrProcessor.PerformOCR(loadedDocument, "tessdata") - ' Save the OCR-processed document to the specified file - Using fileSaveStream As New FileStream("OCR_Output.pdf", FileMode.Create) - loadedDocument.Save(fileSaveStream) - End Using + ' Save the OCR-processed document + loadedDocument.Save("Output.pdf") ' Close the loaded document and commit changes loadedDocument.Close(True) @@ -1702,37 +1513,28 @@ Line breaks can be added to OCRed text using the [OCRLayoutResult](https://help. // Initialize the OCR processor using (OCRProcessor processor = new OCRProcessor()) { - // Load the existing PDF document - using (FileStream stream = new FileStream(@"Input.pdf", FileMode.Open)) - { - // Load the PDF document from the file stream - PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(stream); - - // Set OCR language to English - processor.Settings.Language = Languages.English; + // Load the PDF document from the file stream + PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); - // Set the page segmentation mode to process sparse text with orientation and script detection - processor.Settings.PageSegment = PageSegMode.SparseTextOsd; + // Set OCR language to English + processor.Settings.Language = Languages.English; - // Perform OCR on the loaded PDF document to extract text - processor.PerformOCR(pdfLoadedDocument, processor.TessDataPath, out OCRLayoutResult layoutResult); + // Set the page segmentation mode to process sparse text with orientation and script detection + processor.Settings.PageSegment = PageSegMode.SparseTextOsd; - // Extract the OCRed text from the first page and join lines with newline characters - string ocrText = string.Join("\n", layoutResult.Pages[0].Lines.Select(line => line.Text)); + // Perform OCR on the loaded PDF document to extract text + processor.PerformOCR(pdfLoadedDocument, processor.TessDataPath, out OCRLayoutResult layoutResult); - // Create a file stream for saving the processed PDF document - using (FileStream outputFileStream = new FileStream(@"Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - // Save the PDF document to the file stream - pdfLoadedDocument.Save(outputFileStream); - } + // Extract the OCRed text from the first page and join lines with newline characters + string ocrText = string.Join("\n", layoutResult.Pages[0].Lines.Select(line => line.Text)); - // Close the PDF document - pdfLoadedDocument.Close(true); + // Save the PDF document to the file stream + pdfLoadedDocument.Save("Output.pdf"); + // Close the PDF document + pdfLoadedDocument.Close(true); - // Write the extracted OCR text to an output text file - File.WriteAllText("Output.txt", ocrText); - } + // Write the extracted OCR text to an output text file + File.WriteAllText("Output.txt", ocrText); } {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Troubleshooting.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Troubleshooting.md index c4e3cfef3..a0ef79410 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Troubleshooting.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Troubleshooting.md @@ -351,17 +351,17 @@ Step 1: Execute the following command in terminal window to check dependencies a {% tabs %} {% highlight C# %} - ldd liblept1753.so - ldd libSyncfusionTesseract.so +ldd liblept1753.so +ldd libSyncfusionTesseract.so {% endhighlight %} {% endtabs %} -Run the following commands in terminal +Run the following commands in terminal
Step 1: {% tabs %} {% highlight C# %} - sudo apt-get install libleptonica-dev libjpeg62 +sudo apt-get install libleptonica-dev libjpeg62 {% endhighlight %} {% endtabs %} @@ -369,7 +369,7 @@ Step 2: {% tabs %} {% highlight C# %} - ln -s /usr/lib/x86_64-linux-gnu/libtiff.so.6 /usr/lib/x86_64-linux-gnu/libtiff.so.5 +ln -s /usr/lib/x86_64-linux-gnu/libtiff.so.6 /usr/lib/x86_64-linux-gnu/libtiff.so.5 {% endhighlight %} {% endtabs %} @@ -377,7 +377,7 @@ Step 3: {% tabs %} {% highlight C# %} - ln -s /lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so +ln -s /lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-JetBrains.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-JetBrains.md index d7467450f..21fdcda25 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-JetBrains.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-JetBrains.md @@ -34,10 +34,10 @@ Step 4: A default controller with name HomeController.cs gets added on creation {% highlight c# tabtitle="C#" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Drawing; - using System.IO; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Drawing; +using System.IO; {% endhighlight %} @@ -58,30 +58,28 @@ Step 6: Add a new action method named ``CreatePDFDocument`` in HomeController.cs {% highlight c# tabtitle="C#" %} - //Create a new PDF document. - PdfDocument document = new PdfDocument(); - //Add a page to the document. - PdfPage page = document.Pages.Add(); - //Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; - //Set the standard font. - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); - //Draw the text. - graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0)); - //Saving the PDF to the MemoryStream. - MemoryStream stream = new MemoryStream(); - document.Save(stream); - //Set the position as '0'. - stream.Position = 0; - //Download the PDF document in the browser. - FileStreamResult fileStreamResult = new FileStreamResult(stream, "application/pdf"); - fileStreamResult.FileDownloadName = "Sample.pdf"; - return fileStreamResult; +//Create a new PDF document. +PdfDocument document = new PdfDocument(); +//Add a page to the document. +PdfPage page = document.Pages.Add(); +//Create PDF graphics for the page. +PdfGraphics graphics = page.Graphics; +//Set the standard font. +PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); +//Draw the text. +graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0)); +//Saving the PDF to the MemoryStream. +MemoryStream stream = new MemoryStream(); +document.Save(stream); +//Set the position as '0'. +stream.Position = 0; +// Return file result +return File(stream.ToArray(), "application/pdf", "Sample.pdf"); {% endhighlight %} Step 7: Build the project. -Click the **Build** button in the toolbar or press Ctrl+Shift+B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 8: Run the project. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-VS-Code.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-VS-Code.md index 65d05f2c1..64a45e23a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-VS-Code.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-VS-Code.md @@ -68,10 +68,8 @@ MemoryStream stream = new MemoryStream(); document.Save(stream); //Set the position as '0'. stream.Position = 0; -//Download the PDF document in the browser. -FileStreamResult fileStreamResult = new FileStreamResult(stream, "application/pdf"); -fileStreamResult.FileDownloadName = "Sample.pdf"; -return fileStreamResult; +// Return file result +return File(stream.ToArray(), "application/pdf", "Sample.pdf"); {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-Visual-Studio.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-Visual-Studio.md index 9ace274cc..94a8af88a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-Visual-Studio.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-ASP-NET-Core-Visual-Studio.md @@ -3,16 +3,14 @@ * Install .NET SDK: Ensure that you have the .NET SDK installed on your system. You can download it from the [.NET Downloads page](https://dotnet.microsoft.com/en-us/download). * Install Visual Studio: Download and install Visual Studio from the [official website](https://visualstudio.microsoft.com/downloads/). - - Step 1: Create a new C# ASP.NET Core Web Application project. - ![Create ASP.NET Core Web application in Visual Studio](Asp.Net.Core_images/Creation1.png) +![Create ASP.NET Core Web application in Visual Studio](Asp.Net.Core_images/Creation1.png) Step 2: In configuration windows, name your project and click Next. - ![Select Web Application pattern](Asp.Net.Core_images/Creation2.png) +![Select Web Application pattern](Asp.Net.Core_images/Creation2.png) Step 3: Install the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core/) package as reference to your ASP.NET Core applications from [NuGet.org](https://www.nuget.org/). - ![Install PDF .NET Core NuGet package](Asp.Net.Core_images/Creation3.png) +![Install PDF .NET Core NuGet package](Asp.Net.Core_images/Creation3.png) N> Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion® license key in your application to use our components. @@ -20,23 +18,23 @@ Step 4: A default controller with name HomeController.cs gets added on creation {% highlight c# tabtitle="C#" %} - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Drawing; - using System.IO; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Drawing; +using System.IO; {% endhighlight %} Step 5: A default action method named Index will be present in HomeController.cs. Right click on Index method and select Go To View where you will be directed to its associated view page Index.cshtml. Add a new button in the Index.cshtml as shown below. {% highlight c# tabtitle="C#" %} - @{Html.BeginForm("CreateDocument", "Home", FormMethod.Get); - { -
- -
- } - Html.EndForm(); - } +@{Html.BeginForm("CreateDocument", "Home", FormMethod.Get); + { +
+ +
+ } + Html.EndForm(); +} {% endhighlight %} @@ -44,29 +42,29 @@ Step 6: Add a new action method named ``CreatePDFDocument`` in HomeController.cs {% highlight c# tabtitle="C#" %} - //Create a new PDF document. - PdfDocument document = new PdfDocument(); - //Add a page to the document. - PdfPage page = document.Pages.Add(); - //Create PDF graphics for the page. - PdfGraphics graphics = page.Graphics; - //Set the standard font. - PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); - //Draw the text. - graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0)); - //Saving the PDF to the MemoryStream. - MemoryStream stream = new MemoryStream(); - document.Save(stream); - //Set the position as '0'. - stream.Position = 0; - //Download the PDF document in the browser. - FileStreamResult fileStreamResult = new FileStreamResult(stream, "application/pdf"); - fileStreamResult.FileDownloadName = "Sample.pdf"; - return fileStreamResult; +//Create a new PDF document. +PdfDocument document = new PdfDocument(); +//Add a page to the document. +PdfPage page = document.Pages.Add(); +//Create PDF graphics for the page. +PdfGraphics graphics = page.Graphics; +//Set the standard font. +PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); +//Draw the text. +graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0)); +//Saving the PDF to the MemoryStream. +MemoryStream stream = new MemoryStream(); +document.Save(stream); +//Set the position as '0'. +stream.Position = 0; +// Return file result +return File(stream.ToArray(), "application/pdf", "Sample.pdf"); {% endhighlight %} Step 7: Build the project. - Click on Build > Build Solution or press Ctrl + Shift + B to build the project. + +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 8: Run the project. - Click the Start button (green arrow) or press F5 to run the app. + +Click the **Run** button (green arrow) in the toolbar or press F5 to run the app. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-JetBrains.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-JetBrains.md index ef413654f..0dbfe0318 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-JetBrains.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-JetBrains.md @@ -35,11 +35,11 @@ Step 4: Next, include the following namespaces in the ``_Imports.razor`` file. {% highlight c# tabtitle="C#" %} - @using Syncfusion.Pdf; - @using Syncfusion.Pdf.Graphics; - @using Syncfusion.Pdf.Grid; - @using Syncfusion.Drawing; - @using BlazorMauiAppCreatePdfSample.Services +@using Syncfusion.Pdf; +@using Syncfusion.Pdf.Graphics; +@using Syncfusion.Pdf.Grid; +@using Syncfusion.Drawing; +@using BlazorMauiAppCreatePdfSample.Services {% endhighlight %} @@ -65,52 +65,52 @@ The [PdfDocument](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Pdf {% highlight c# tabtitle="C#" %} - @functions { - void ExportToPdf() +@functions { + void ExportToPdf() + { + int paragraphAfterSpacing = 8; + int cellMargin = 8; + //Create a new PDF document. + PdfDocument pdfDocument = new PdfDocument(); + //Add Page to the PDF document. + PdfPage page = pdfDocument.Pages.Add(); + //Create a new font. + PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 16); + //Create a text element to draw a text in PDF page. + PdfTextElement title = new PdfTextElement("Weather Forecast", font, PdfBrushes.Black); + PdfLayoutResult result = title.Draw(page, new PointF(0, 0)); + PdfStandardFont contentFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); + //Create text element. + PdfTextElement content = new PdfTextElement("This component demonstrates fetching data from a client side and Exporting the data to PDF document using Syncfusion .NET PDF library.", contentFont, PdfBrushes.Black); + PdfLayoutFormat format = new PdfLayoutFormat(); + format.Layout = PdfLayoutType.Paginate; + //Draw a text to the PDF document. + result = content.Draw(page, new RectangleF(0, result.Bounds.Bottom + paragraphAfterSpacing, page.GetClientSize().Width, page.GetClientSize().Height), format); + //Create a PdfGrid. + PdfGrid pdfGrid = new PdfGrid(); + pdfGrid.Style.CellPadding.Left = cellMargin; + pdfGrid.Style.CellPadding.Right = cellMargin; + //Applying built-in style to the PDF grid + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent1); + //Assign data source. + pdfGrid.DataSource = forecasts; + pdfGrid.Style.Font = contentFont; + //Draw PDF grid into the PDF page. + pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, result.Bounds.Bottom + paragraphAfterSpacing)); + using (MemoryStream ms = new MemoryStream()) { - int paragraphAfterSpacing = 8; - int cellMargin = 8; - //Create a new PDF document. - PdfDocument pdfDocument = new PdfDocument(); - //Add Page to the PDF document. - PdfPage page = pdfDocument.Pages.Add(); - //Create a new font. - PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 16); - //Create a text element to draw a text in PDF page. - PdfTextElement title = new PdfTextElement("Weather Forecast", font, PdfBrushes.Black); - PdfLayoutResult result = title.Draw(page, new PointF(0, 0)); - PdfStandardFont contentFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); - //Create text element. - PdfTextElement content = new PdfTextElement("This component demonstrates fetching data from a client side and Exporting the data to PDF document using Syncfusion .NET PDF library.", contentFont, PdfBrushes.Black); - PdfLayoutFormat format = new PdfLayoutFormat(); - format.Layout = PdfLayoutType.Paginate; - //Draw a text to the PDF document. - result = content.Draw(page, new RectangleF(0, result.Bounds.Bottom + paragraphAfterSpacing, page.GetClientSize().Width, page.GetClientSize().Height), format); - //Create a PdfGrid. - PdfGrid pdfGrid = new PdfGrid(); - pdfGrid.Style.CellPadding.Left = cellMargin; - pdfGrid.Style.CellPadding.Right = cellMargin; - //Applying built-in style to the PDF grid - pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent1); - //Assign data source. - pdfGrid.DataSource = forecasts; - pdfGrid.Style.Font = contentFont; - //Draw PDF grid into the PDF page. - pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, result.Bounds.Bottom + paragraphAfterSpacing)); - using (MemoryStream ms = new MemoryStream()) - { - // Save the PDF document to the memory stream - pdfDocument.Save(ms); - // Close the PDF document - pdfDocument.Close(true); - // Reset the memory stream position - ms.Position = 0; - // Create a SaveService instance - SaveService service = new SaveService(); - // Save and view the PDF document - service.SaveAndView("Output.pdf", "application/pdf", ms); - } + // Save the PDF document to the memory stream + pdfDocument.Save(ms); + // Close the PDF document + pdfDocument.Close(true); + // Reset the memory stream position + ms.Position = 0; + // Create a SaveService instance + SaveService service = new SaveService(); + // Save and view the PDF document + service.SaveAndView("Output.pdf", "application/pdf", ms); } + } {% endhighlight %} @@ -118,7 +118,7 @@ The [PdfDocument](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Pdf Step 7: Build the project. -Click the **Build** button in the toolbar or press Ctrl+Shift+B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 8: Run the project. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-VS-Code.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-VS-Code.md index 707d40fd7..d194af714 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-VS-Code.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-VS-Code.md @@ -25,11 +25,11 @@ Step 4: Include necessary namespaces in `_Imports.razor` file. {% tabs %} {% highlight c# tabtitle="C#" %} - @using Syncfusion.Pdf; - @using Syncfusion.Pdf.Graphics; - @using Syncfusion.Pdf.Grid; - @using Syncfusion.Drawing; - @using BlazorMauiAppCreatePdfSample.Services +@using Syncfusion.Pdf; +@using Syncfusion.Pdf.Graphics; +@using Syncfusion.Pdf.Grid; +@using Syncfusion.Drawing; +@using BlazorMauiAppCreatePdfSample.Services {% endhighlight %} @@ -41,7 +41,7 @@ Step 5: Create a button in ``Weather.razor`` using the following code. {% highlight CSHTML %} - + {% endhighlight %} @@ -55,52 +55,52 @@ The [PdfDocument](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Pdf {% highlight c# tabtitle="C#" %} - @functions { - void ExportToPdf() - { - int paragraphAfterSpacing = 8; - int cellMargin = 8; - //Create a new PDF document. - PdfDocument pdfDocument = new PdfDocument(); - //Add Page to the PDF document. - PdfPage page = pdfDocument.Pages.Add(); - //Create a new font. - PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 16); - //Create a text element to draw a text in PDF page. - PdfTextElement title = new PdfTextElement("Weather Forecast", font, PdfBrushes.Black); - PdfLayoutResult result = title.Draw(page, new PointF(0, 0)); - PdfStandardFont contentFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); - //Create text element. - PdfTextElement content = new PdfTextElement("This component demonstrates fetching data from a client side and Exporting the data to PDF document using Syncfusion .NET PDF library.", contentFont, PdfBrushes.Black); - PdfLayoutFormat format = new PdfLayoutFormat(); - format.Layout = PdfLayoutType.Paginate; - //Draw a text to the PDF document. - result = content.Draw(page, new RectangleF(0, result.Bounds.Bottom + paragraphAfterSpacing, page.GetClientSize().Width, page.GetClientSize().Height), format); - //Create a PdfGrid. - PdfGrid pdfGrid = new PdfGrid(); - pdfGrid.Style.CellPadding.Left = cellMargin; - pdfGrid.Style.CellPadding.Right = cellMargin; - //Applying built-in style to the PDF grid - pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent1); - //Assign data source. - pdfGrid.DataSource = forecasts; - pdfGrid.Style.Font = contentFont; - //Draw PDF grid into the PDF page. - pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, result.Bounds.Bottom + paragraphAfterSpacing)); - using (MemoryStream ms = new MemoryStream()) - { - // Save the PDF document to the memory stream - pdfDocument.Save(ms); - // Close the PDF document - pdfDocument.Close(true); - // Reset the memory stream position - ms.Position = 0; - // Create a SaveService instance - SaveService service = new SaveService(); - // Save and view the PDF document - service.SaveAndView("Output.pdf", "application/pdf", ms); - } - } +@functions { + void ExportToPdf() + { + int paragraphAfterSpacing = 8; + int cellMargin = 8; + //Create a new PDF document. + PdfDocument pdfDocument = new PdfDocument(); + //Add Page to the PDF document. + PdfPage page = pdfDocument.Pages.Add(); + //Create a new font. + PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 16); + //Create a text element to draw a text in PDF page. + PdfTextElement title = new PdfTextElement("Weather Forecast", font, PdfBrushes.Black); + PdfLayoutResult result = title.Draw(page, new PointF(0, 0)); + PdfStandardFont contentFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); + //Create text element. + PdfTextElement content = new PdfTextElement("This component demonstrates fetching data from a client side and Exporting the data to PDF document using Syncfusion .NET PDF library.", contentFont, PdfBrushes.Black); + PdfLayoutFormat format = new PdfLayoutFormat(); + format.Layout = PdfLayoutType.Paginate; + //Draw a text to the PDF document. + result = content.Draw(page, new RectangleF(0, result.Bounds.Bottom + paragraphAfterSpacing, page.GetClientSize().Width, page.GetClientSize().Height), format); + //Create a PdfGrid. + PdfGrid pdfGrid = new PdfGrid(); + pdfGrid.Style.CellPadding.Left = cellMargin; + pdfGrid.Style.CellPadding.Right = cellMargin; + //Applying built-in style to the PDF grid + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent1); + //Assign data source. + pdfGrid.DataSource = forecasts; + pdfGrid.Style.Font = contentFont; + //Draw PDF grid into the PDF page. + pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, result.Bounds.Bottom + paragraphAfterSpacing)); + using (MemoryStream ms = new MemoryStream()) + { + // Save the PDF document to the memory stream + pdfDocument.Save(ms); + // Close the PDF document + pdfDocument.Close(true); + // Reset the memory stream position + ms.Position = 0; + // Create a SaveService instance + SaveService service = new SaveService(); + // Save and view the PDF document + service.SaveAndView("Output.pdf", "application/pdf", ms); + } + } {% endhighlight %} diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-Visual-studio.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-Visual-studio.md index c4f63b315..68acd34f6 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-Visual-studio.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-MaUI-Visual-studio.md @@ -15,11 +15,11 @@ Step 3: Include necessary namespaces in `_Imports.razor` file. {% highlight c# tabtitle="C#" %} - @using Syncfusion.Pdf; - @using Syncfusion.Pdf.Graphics; - @using Syncfusion.Pdf.Grid; - @using Syncfusion.Drawing; - @using BlazorMauiAppCreatePdfSample.Services +@using Syncfusion.Pdf; +@using Syncfusion.Pdf.Graphics; +@using Syncfusion.Pdf.Grid; +@using Syncfusion.Drawing; +@using BlazorMauiAppCreatePdfSample.Services {% endhighlight %} @@ -45,52 +45,52 @@ The [PdfDocument](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Pdf {% highlight c# tabtitle="C#" %} - @functions { - void ExportToPdf() +@functions { + void ExportToPdf() + { + int paragraphAfterSpacing = 8; + int cellMargin = 8; + //Create a new PDF document. + PdfDocument pdfDocument = new PdfDocument(); + //Add Page to the PDF document. + PdfPage page = pdfDocument.Pages.Add(); + //Create a new font. + PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 16); + //Create a text element to draw a text in PDF page. + PdfTextElement title = new PdfTextElement("Weather Forecast", font, PdfBrushes.Black); + PdfLayoutResult result = title.Draw(page, new PointF(0, 0)); + PdfStandardFont contentFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); + //Create text element. + PdfTextElement content = new PdfTextElement("This component demonstrates fetching data from a client side and Exporting the data to PDF document using Syncfusion .NET PDF library.", contentFont, PdfBrushes.Black); + PdfLayoutFormat format = new PdfLayoutFormat(); + format.Layout = PdfLayoutType.Paginate; + //Draw a text to the PDF document. + result = content.Draw(page, new RectangleF(0, result.Bounds.Bottom + paragraphAfterSpacing, page.GetClientSize().Width, page.GetClientSize().Height), format); + //Create a PdfGrid. + PdfGrid pdfGrid = new PdfGrid(); + pdfGrid.Style.CellPadding.Left = cellMargin; + pdfGrid.Style.CellPadding.Right = cellMargin; + //Applying built-in style to the PDF grid + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent1); + //Assign data source. + pdfGrid.DataSource = forecasts; + pdfGrid.Style.Font = contentFont; + //Draw PDF grid into the PDF page. + pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, result.Bounds.Bottom + paragraphAfterSpacing)); + using (MemoryStream ms = new MemoryStream()) { - int paragraphAfterSpacing = 8; - int cellMargin = 8; - //Create a new PDF document. - PdfDocument pdfDocument = new PdfDocument(); - //Add Page to the PDF document. - PdfPage page = pdfDocument.Pages.Add(); - //Create a new font. - PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 16); - //Create a text element to draw a text in PDF page. - PdfTextElement title = new PdfTextElement("Weather Forecast", font, PdfBrushes.Black); - PdfLayoutResult result = title.Draw(page, new PointF(0, 0)); - PdfStandardFont contentFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); - //Create text element. - PdfTextElement content = new PdfTextElement("This component demonstrates fetching data from a client side and Exporting the data to PDF document using Syncfusion .NET PDF library.", contentFont, PdfBrushes.Black); - PdfLayoutFormat format = new PdfLayoutFormat(); - format.Layout = PdfLayoutType.Paginate; - //Draw a text to the PDF document. - result = content.Draw(page, new RectangleF(0, result.Bounds.Bottom + paragraphAfterSpacing, page.GetClientSize().Width, page.GetClientSize().Height), format); - //Create a PdfGrid. - PdfGrid pdfGrid = new PdfGrid(); - pdfGrid.Style.CellPadding.Left = cellMargin; - pdfGrid.Style.CellPadding.Right = cellMargin; - //Applying built-in style to the PDF grid - pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent1); - //Assign data source. - pdfGrid.DataSource = forecasts; - pdfGrid.Style.Font = contentFont; - //Draw PDF grid into the PDF page. - pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, result.Bounds.Bottom + paragraphAfterSpacing)); - using (MemoryStream ms = new MemoryStream()) - { - // Save the PDF document to the memory stream - pdfDocument.Save(ms); - // Close the PDF document - pdfDocument.Close(true); - // Reset the memory stream position - ms.Position = 0; - // Create a SaveService instance - SaveService service = new SaveService(); - // Save and view the PDF document - service.SaveAndView("Output.pdf", "application/pdf", ms); - } + // Save the PDF document to the memory stream + pdfDocument.Save(ms); + // Close the PDF document + pdfDocument.Close(true); + // Reset the memory stream position + ms.Position = 0; + // Create a SaveService instance + SaveService service = new SaveService(); + // Save and view the PDF document + service.SaveAndView("Output.pdf", "application/pdf", ms); } + } {% endhighlight %} @@ -98,7 +98,7 @@ The [PdfDocument](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Pdf Step 6: Build the project. -Click on Build > Build Solution or press `Ctrl + Shift + B` to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 7: Run the project. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-Server-JetBrains.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-Server-JetBrains.md index d1e65fe75..88be2740a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-Server-JetBrains.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-Server-JetBrains.md @@ -208,7 +208,7 @@ Step 8: Add the following JavaScript function in the `_Host.cshtml` available un Step 9: Build the project. -Click the **Build** button in the toolbar or press Ctrl+Shift+B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 10: Run the project. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-Server-Visual-studio.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-Server-Visual-studio.md index 14f5297b0..3f2d56cfb 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-Server-Visual-studio.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-Server-Visual-studio.md @@ -190,7 +190,7 @@ Step 9: Add the following JavaScript function in the `App.razor` available under Step 10: Build the project. -Click on Build > Build Solution or press Ctrl + Shift + B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 11: Run the project. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-WASM-JetBrains.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-WASM-JetBrains.md index a7dbae5ea..afda73fb8 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-WASM-JetBrains.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-WASM-JetBrains.md @@ -161,7 +161,7 @@ Step 7: Add the following JavaScript function in the ``index.html`` available un Step 8: Build the project. -Click the **Build** button in the toolbar or press Ctrl+Shift+B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 9: Run the project. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-WASM-Visual-studio.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-WASM-Visual-studio.md index 58cddf53e..cffe5cb10 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-WASM-Visual-studio.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Blazor-WASM-Visual-studio.md @@ -145,8 +145,8 @@ Step 8: Add the following JavaScript function to the `index.html` file located i Step 9: Build the project. -Click on Build > Build Solution or press `Ctrl + Shift + B` to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 10: Run the project. -Click the `Start` button (green arrow) or press `F5` to run the application. \ No newline at end of file +Click the **Run** button (green arrow) in the toolbar or press F5 to run the application. \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Console-JetBrains.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Console-JetBrains.md index daa78b595..f6a2b03aa 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Console-JetBrains.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Console-JetBrains.md @@ -68,7 +68,7 @@ document.Close(true); Step 6: Build the project. -Click the **Build** button in the toolbar or press Ctrl+Shift+B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 7: Run the project. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Console-Visual-Studio.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Console-Visual-Studio.md index ef5cad4dd..656c6227f 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Console-Visual-Studio.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Console-Visual-Studio.md @@ -52,8 +52,8 @@ document.Close(true); Step 6: Build the project. -Click on Build > Build Solution or press Ctrl + Shift + B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 7: Run the project. -Click the Start button (green arrow) or press F5 to run the app. \ No newline at end of file +Click the **Run** button (green arrow) in the toolbar or press F5 to run the app. \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-JetBrains.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-JetBrains.md index ff290f40a..1870b5b6c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-JetBrains.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-JetBrains.md @@ -66,13 +66,13 @@ Step 5: Include the following namespaces in the *MainWindow.xaml.cs* file. {% highlight c# tabtitle="C#" %} - using CreatePdfDemoSample.Services; - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf.Grid; - using Syncfusion.Drawing; - using System.Reflection; - using System.Xml.Linq; +using CreatePdfDemoSample.Services; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Drawing; +using System.Reflection; +using System.Xml.Linq; {% endhighlight %} @@ -385,7 +385,11 @@ Step 6: Add a new action method *createPdf_Click* in *MainWindow.xaml.cs* and in {% endcapture %} {{ codesnippet3 | OrderList_Indent_Level_1 }} -Step 7: Build and Run the Project +Step 7: Build the project. -Click the **Run** button (green arrow) in the toolbar or press `F5` to build and run the application. When you click the "Export to PDF" button, a PDF document will be generated and opened using the default PDF viewer on the target device. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. + +Step 8: Run the project. + +Click the **Run** button (green arrow) in the toolbar or press F5 to run the app. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-VS-Code.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-VS-Code.md index f70501704..9f5c1ad49 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-VS-Code.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-VS-Code.md @@ -4,8 +4,6 @@ * Install Visual Studio Code: Download and install Visual Studio Code from the [official website](https://code.visualstudio.com/download). * Install C# Extension for VS Code: Open Visual Studio Code, go to the Extensions view (Ctrl+Shift+X), and search for 'C#'. Install the official [C# extension provided by Microsoft](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp). - - Step 1: Open the terminal (Ctrl+` ) and run the following command to create a new .NET MAUI Application. ``` @@ -61,13 +59,13 @@ Step 6: Include the following namespaces in the *MainWindow.xaml.cs* file. {% highlight c# tabtitle="C#" %} - using CreatePdfDemoSample.Services; - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf.Grid; - using Syncfusion.Drawing; - using System.Reflection; - using System.Xml.Linq; +using CreatePdfDemoSample.Services; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Drawing; +using System.Reflection; +using System.Xml.Linq; {% endhighlight %} @@ -374,8 +372,6 @@ Step 7: Add a new action method *createPdf_Click* in *MainWindow.xaml.cs* and in } #endregion - - {% endhighlight %} {% endtabs %} @@ -384,16 +380,16 @@ Step 7: Add a new action method *createPdf_Click* in *MainWindow.xaml.cs* and in Step 8: Build the project. - Run the following command in terminal to build the project. +Run the following command in terminal to build the project. - ``` - dotnet build - ``` +``` +dotnet build +``` Step 9: Run the project. - Run the following command in terminal to run the project. +Run the following command in terminal to run the project. - ``` - dotnet run +``` +dotnet run ``` diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-Visual-Studio.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-Visual-Studio.md index f9e9f332b..b6c9db5bf 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-Visual-Studio.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-MaUI-Visual-Studio.md @@ -3,8 +3,6 @@ * Install .NET SDK: Ensure that you have the .NET SDK installed on your system. You can download it from the [.NET Downloads page](https://dotnet.microsoft.com/en-us/download). * Install Visual Studio: Download and install Visual Studio Code from the [official website](https://code.visualstudio.com/download). - - Step 1: Create a new project in VS2022, select the .NET MAUI App (Preview) template, and click the **Next** button. ![.NET MAUI sample creation step1](MAUI_images/Create_Project.png) @@ -52,13 +50,13 @@ Step 5: Include the following namespaces in the *MainWindow.xaml.cs* file. {% highlight c# tabtitle="C#" %} - using CreatePdfDemoSample.Services; - using Syncfusion.Pdf; - using Syncfusion.Pdf.Graphics; - using Syncfusion.Pdf.Grid; - using Syncfusion.Drawing; - using System.Reflection; - using System.Xml.Linq; +using CreatePdfDemoSample.Services; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Drawing; +using System.Reflection; +using System.Xml.Linq; {% endhighlight %} @@ -375,7 +373,8 @@ Step 6: Add a new action method *createPdf_Click* in *MainWindow.xaml.cs* and in Step 7: Build the project. -Click on Build > Build Solution or press Ctrl + Shift + B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 8: Run the project. - Click the Start button (green arrow) or press F5 to run the app. + +Click the **Run** button (green arrow) in the toolbar or press F5 to run the app. diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Mac-OS-VS-Code.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Mac-OS-VS-Code.md index 5c2094155..893a3ecbd 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Mac-OS-VS-Code.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Mac-OS-VS-Code.md @@ -4,8 +4,6 @@ * Install Visual Studio Code: Download and install Visual Studio Code from the [official website](https://code.visualstudio.com/download). * Install C# Extension for VS Code: Open Visual Studio Code, go to the Extensions view (Ctrl+Shift+X), and search for 'C#'. Install the official [C# extension provided by Microsoft](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp). - - Step 1: Open the terminal (Ctrl+` ) and run the following command to create a .NET Core console application. ``` @@ -104,14 +102,14 @@ Step 7: Build the project. Run the following command in terminal to build the project. - ``` - dotnet build - ``` +``` +dotnet build +``` Step 8: Run the project. Run the following command in terminal to build the project. - ``` - dotnet run +``` +dotnet run ``` diff --git a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Mac-OS-Visual-Studio.md b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Mac-OS-Visual-Studio.md index f45720a1f..05c014667 100644 --- a/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Mac-OS-Visual-Studio.md +++ b/Document-Processing/PDF/PDF-Library/NET/tabcontent-support/Create-PDF-document-in-Mac-OS-Visual-Studio.md @@ -3,8 +3,6 @@ * Install .NET SDK: Ensure that you have the .NET SDK installed on your system. You can download it from the [.NET Downloads page](https://dotnet.microsoft.com/en-us/download). * Install Visual Studio: Download and install Visual Studio Code from the [official website](https://code.visualstudio.com/download). - - Step 1: Create a new .NET Core console application project. ![Mac OS console application](GettingStarted_images/Mac_OS_Console.png) @@ -92,7 +90,8 @@ using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output.pd Step 6: Build the project. -Click on Build > Build Solution or press Ctrl + Shift + B to build the project. +To build the project, go to the `Build` menu and select `Build Solution`, or simply press Ctrl+Shift+B. Step 7: Run the project. - Click the Start button (green arrow) or press F5 to run the app. + +Click the **Run** button (green arrow) in the toolbar or press F5 to run the app. From f750298ab3e6e150a2877bf3d6b6a421f48e4eba Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 6 Oct 2025 17:10:40 +0530 Subject: [PATCH 2/5] 985481-ug: Resolved CI failures. --- .../Open-and-Save-PDF-document-AWS-Lambda.md | 2 +- ...n-and-save-PDF-document-in-ASP-NET-Core.md | 4 +- .../NET/Open-pdf-files/From-AWS-S3.md | 7 +- .../Open-pdf-files/From-azure-blob-storage.md | 2 +- .../From-dropbox-cloud-file-storage.md | 4 +- .../From-google-cloud-storage.md | 2 +- .../NET/Open-pdf-files/From-google-drive.md | 4 +- .../NET/Save-pdf-files/To-AWS-S3.md | 5 +- .../Save-pdf-files/To-azure-blob-storage.md | 3 +- .../To-dropbox-cloud-file-storage.md | 6 +- .../Save-pdf-files/To-google-cloud-storage.md | 2 +- .../NET/Save-pdf-files/To-google-drive.md | 3 +- .../NET/Working-with-OCR/Features.md | 287 +++++++++++------- 13 files changed, 193 insertions(+), 138 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-Save-PDF-document-AWS-Lambda.md b/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-Save-PDF-document-AWS-Lambda.md index 8152cdb3b..9d4a5dee8 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-Save-PDF-document-AWS-Lambda.md +++ b/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-Save-PDF-document-AWS-Lambda.md @@ -9,7 +9,7 @@ keywords: aws lambda save pdf, aws load pdf, c# save pdf, c# load pdf # Open and save PDF document in AWS Lambda -The [Syncfusion® .NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core) is used to create, read, and edit PDF documents programatically without the dependency of Adobe Acrobat. Using this library, **open and save PDF document in AWS Lambda**. +The [Syncfusion® .NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core) is used to create, read, and edit PDF documents programmatically without the dependency of Adobe Acrobat. Using this library, **open and save PDF document in AWS Lambda**. ## Steps to open and save PDF document in AWS Lambda diff --git a/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-save-PDF-document-in-ASP-NET-Core.md b/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-save-PDF-document-in-ASP-NET-Core.md index 96e1e3c70..3f9e07cec 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-save-PDF-document-in-ASP-NET-Core.md +++ b/Document-Processing/PDF/PDF-Library/NET/Loading-and-saving-document/Open-and-save-PDF-document-in-ASP-NET-Core.md @@ -9,9 +9,9 @@ keywords: .net core save pdf, .net core load pdf, c# save pdf, c# load pdf # Open and save PDF document in ASP.NET Core -The [Syncfusion® .NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core) is used to create, read, and edit PDF documents programatically without the dependency of Adobe Acrobat. Using this library, you can **open and save PDF document in ASP.NET Core**. +The [Syncfusion® .NET Core PDF library](https://www.syncfusion.com/document-processing/pdf-framework/net-core) is used to create, read, and edit PDF documents programmatically without the dependency of Adobe Acrobat. Using this library, you can **open and save PDF document in ASP.NET Core**. -## Steps to open and save PDF document programatically: +## Steps to open and save PDF document programmatically: Step 1: Create a new ASP.NET Core Web application project. ![Create ASP.NET Core Web application in Visual Studio](Images/Create_ASP_NET_Core_application.png) 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 cbf749d73..a1338eb22 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,15 +1,14 @@ --- 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 provides a detailed guide on how to open a PDF file stored in an AWS S3 bucket using C# and the Syncfusion .NET PDF library. platform: document-processing control: PDF documentation: UG --- -# Open PDF file from AWS S3 +# Open PDF from AWS S3 To load a PDF file from AWS S3, you can follow the steps below - Step 1: Create a simple console application ![Project configuration window](Open-PDF-Images/Console-Application.png) @@ -18,7 +17,6 @@ Step 3: Install the [AWSSDK.S3](https://www.nuget.org/packages/AWSSDK.S3) NuGet ![NuGet package installation](Open-PDF-Images/AWSSDK.S3-nuget.png) - Step 4: Include the following namespaces in the Program.cs file. {% tabs %} @@ -33,7 +31,6 @@ using Amazon.S3.Transfer; {% endtabs %} - Step 5: Add the below code example to load a PDF from AWS S3. {% tabs %} 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 59311c999..02013f46b 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 from Azure Blob storage To load a PDF file from Azure blob storage, you can follow the steps below 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 ddebc43fc..f0627de28 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 @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Open PDF file from Dropbox cloud file storage +# Open PDF from Dropbox cloud file storage To Open a PDF file from Dropbox cloud file storage, you can follow the steps below @@ -33,7 +33,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 %} 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 2f7b1bc32..5c2a70da6 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 @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Open PDF file from Google Cloud storage +# Open PDF from Google Cloud storage To Open a PDF file from Google cloud storage, you can follow the steps below 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 1c1ca7b0f..a3584a132 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 @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Open PDF file from Google Drive +# Open PDF from Google Drive To Open a PDF file from Google Drive, you can follow the steps below @@ -21,7 +21,6 @@ Step 3: Install the [Google.Apis.Drive.v3](https://www.nuget.org/packages/Google ![NuGet package installation](open-PDF-Images/Google.Apis.Drive.V3-nuget.png) - Step 4: Include the following namespaces in the Program.cs file. {% tabs %} @@ -37,7 +36,6 @@ using Google.Apis.Util.Store; {% endtabs %} - Step 5: Add the below code example to open a PDF from google drive. {% tabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md index d6a483d35..bee88deef 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md @@ -1,15 +1,14 @@ --- title: Save PDF file to AWS S3 | Syncfusion -description: This page describes how to save PDF file to file AWS S3 in C# using Syncfusion .NET PDF library. +description: This page describes how to save PDF file to file AWS S3 bucket in C# using Syncfusion .NET PDF library. platform: document-processing control: PDF documentation: UG --- -# Save PDF file to AWS S3 +# Save PDF to AWS S3 To save a PDF file to AWS S3, you can follow the steps below - Step 1: Create a simple console application ![Project configuration window](Save-PDF-Images/Console-Application.png) diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-azure-blob-storage.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-azure-blob-storage.md index 8a3271fa3..2176fa1ad 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-azure-blob-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-azure-blob-storage.md @@ -5,11 +5,10 @@ platform: document-processing control: PDF documentation: UG --- -# Save PDF file to Azure Blob storage +# Save PDF to Azure Blob storage To save a PDF file to Azure blob storage, you can follow the steps below - Step 1: Create a simple console application ![Project configuration window](Save-PDF-Images/Console-Application.png) diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-dropbox-cloud-file-storage.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-dropbox-cloud-file-storage.md index 09daa442f..b1bd65c33 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-dropbox-cloud-file-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-dropbox-cloud-file-storage.md @@ -5,17 +5,14 @@ platform: document-processing control: PDF documentation: UG --- -# Save PDF file to Dropbox cloud file storage +# Save PDF to Dropbox cloud file storage To save a PDF file to Dropbox cloud file storage, you can follow the steps below Step 1: Create a Dropbox API - To create a Dropbox API App, you should follow the official documentation provided by Dropbox [link](https://www.dropbox.com/developers/documentation/dotnet#tutorial). The process involves visiting the Dropbox Developer website and using their App Console to set up your API app. This app will allow you to interact with Dropbox programmatically, enabling secure access to files and data. - - Step 2: Create a simple console application ![Project configuration window](Save-PDF-Images/Console-Application.png) @@ -40,7 +37,6 @@ using Syncfusion.Drawing; {% endtabs %} - Step 5: Add the below code example to create a simple PDF and save in Dropbox cloud file storage. {% tabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-cloud-storage.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-cloud-storage.md index 637e7b38f..cce3938fb 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-cloud-storage.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-cloud-storage.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Save PDF file to Google Cloud storage +# Save PDF to Google Cloud storage To save a PDF file to Google cloud storage, you can follow the steps below diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-drive.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-drive.md index 476cad1aa..974927405 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-drive.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-google-drive.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Save PDF file to Google Drive +# Save PDF to Google Drive To save a PDF file to Google Drive, you can follow the steps below @@ -22,7 +22,6 @@ Step 3: Install the [Syncfusion.Pdf.Net.Core ](https://www.nuget.org/packages/Sy

![NuGet package installation](Save-PDF-Images/Google.Apis.Drive.V3-nuget.png) - Step 4: Include the following namespaces in the Program.cs file. {% tabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Features.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Features.md index bcb2f328d..a03afe40b 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Features.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-OCR/Features.md @@ -17,6 +17,9 @@ To perform OCR for an entire PDF document using [PerformOCR](https://help.syncfu {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/Perform-OCR-for-the-entire-PDF-document/Perform-OCR-for-the-entire-PDF-document/Program.cs, 300" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -36,6 +39,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. @@ -66,6 +72,9 @@ To perform OCR on a particular region or several regions of a PDF page with the {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/Perform-OCR-on-particular-region-of-PDF-document/Perform-OCR-on-particular-region-of-PDF-document/Program.cs, 300" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -101,6 +110,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document. @@ -150,6 +162,9 @@ The following code sample demonstrates the OCR processor with Tesseract version {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -173,6 +188,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor with tesseract binaries folder path. Using processor As OCRProcessor = New OCRProcessor("TesseractBinaries/3.05/") 'Load an existing PDF document. @@ -208,6 +226,9 @@ The following code sample explains the OCR processor with Tesseract version 4.0 {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -231,6 +252,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor with tesseract binaries folder path. Using processor As OCRProcessor = New OCRProcessor("TesseractBinaries/4.0/") 'Load an existing PDF document. @@ -261,6 +285,9 @@ The below code example illustrates how to perform OCR on image file using [Perfo {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/Perform-OCR-on-image-file/Perform-OCR-on-image-file/Program.cs, 300" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -276,6 +303,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() 'Load the input image. @@ -298,6 +328,9 @@ You can get the OCRed Unicode text from an image file by using the ``UnicodeFont {% highlight c# tabtitle="ASP.NET Core" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -342,6 +375,9 @@ N> Memory optimization for performing OCR on large PDF documents is not supporte {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -361,6 +397,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -389,6 +428,9 @@ You can get the OCRed text from the rotated page of PDF document using the [Page {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -411,6 +453,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -446,6 +491,9 @@ For more details, refer to the following code sample. {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + // Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -469,6 +517,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + ' Initialize the OCR processor. Using processor As New OCRProcessor() @@ -501,6 +552,9 @@ You can get the OCRed text and its bounds from a scanned PDF document by using t {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -532,6 +586,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -581,6 +638,9 @@ The following code sample demonstrates the OCR processor with native call suppor {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -603,6 +663,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -635,6 +698,9 @@ The following code sample demonstrates the OCR processor with native call suppor {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -659,6 +725,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor with tesseract binaries folder path. Using processor As OCRProcessor = New OCRProcessor() @@ -696,6 +765,9 @@ While performing OCR on an existing scanned PDF document, the OCR Processor will {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -717,6 +789,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -812,6 +887,9 @@ N> The page segmentation mode is supported only in the Tesseract version 4.0 and {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -836,6 +914,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -868,6 +949,9 @@ The [OCREngineMode](https://help.syncfusion.com/cr/document-processing/Syncfusio {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -892,6 +976,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -926,6 +1013,9 @@ The [WhiteList](https://help.syncfusion.com/cr/document-processing/Syncfusion.OC {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -952,6 +1042,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -984,6 +1077,9 @@ The [BlackList](https://help.syncfusion.com/cr/document-processing/Syncfusion.OC {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -1010,6 +1106,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -1048,6 +1147,9 @@ The following code sample illustrates how to OCR an image to a PDF document: {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/OCR_Image_to_PDF/OCR_Image_to_PDF/Program.cs, 300" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -1073,6 +1175,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor. Using processor As OCRProcessor = New OCRProcessor() @@ -1108,6 +1213,9 @@ You can perform OCR on Images with Unicode characters. To preserve the Unicode c {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/Perform-OCR-an-image-and-convert-it-to-a-PDF-document/Perform-OCR-an-image-and-convert-it-to-a-PDF-document/Program.cs, 300" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor. using (OCRProcessor processor = new OCRProcessor()) { @@ -1129,12 +1237,6 @@ using (OCRProcessor processor = new OCRProcessor()) {% endhighlight %} -{% highlight c# tabtitle="C# [Cross-platform]" %} - -//By default unicode characters can be extracted from image file in .NET Framework applications like WF, WPF, ASP.NET and ASP.NET MVC. - -{% endhighlight %} - {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} //By default unicode characters can be extracted from image file in .NET Framework applications like WF, WPF, ASP.NET and ASP.NET MVC. @@ -1170,6 +1272,9 @@ Refer to the following code sample to set the performance of the OCR. {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor OCRProcessor processor = new OCRProcessor(); @@ -1180,6 +1285,9 @@ processor.Settings.Performance = Performance.Fast; {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor Dim processor As New OCRProcessor() @@ -1200,6 +1308,9 @@ N> You can get the TesseractBinaries or TessData files from the NuGet package ru {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor by providing the path of the tesseract binaries (SyncfusionTesseract.dll and liblept168.dll) using (OCRProcessor processor = new OCRProcessor(@"TesseractBinaries\")) { @@ -1220,6 +1331,9 @@ using (OCRProcessor processor = new OCRProcessor(@"TesseractBinaries\")) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor Using processor As OCRProcessor = New OCRProcessor("TesseractBinaries\") 'Load an existing PDF document. @@ -1248,6 +1362,9 @@ To get the Image rotation angle, you can rotate the image with 4 angles (0,90,18 {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/Get-image-rotation-angle-from-OCR/Get-image-rotation-angle-from-OCR/Program.cs, 300" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; + //Initialize the OCR processor.@ using (OCRProcessor processor = new OCRProcessor()) { @@ -1274,11 +1391,13 @@ using (OCRProcessor processor = new OCRProcessor()) document.Save("Output.pdf); } - {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + 'Initialize the OCR processor Using processor As OCRProcessor = New OCRProcessor() 'Load an existing PDF document.. @@ -1318,54 +1437,58 @@ We have support to improve the image quality while performing OCR for an image o {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/Perform-OCR-ImageEnhancement/OCR_ImageEnhancement/Program.cs, 300" %} + +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; - //Initialize the OCR processor. - using (OCRProcessor processor = new OCRProcessor()) - { - //Load an existing PDF document. - PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); - //Set the OCR language. - processor.Settings.Language = Languages.English; - processor.ImageProcessor = new ImageProcessor(); - //Perform OCR with input document. - string text = processor.PerformOCR(lDoc); - - //Save the document. - lDoc.Save("Output.pdf"); - //Close the document. - lDoc.Close(true); - } +//Initialize the OCR processor. +using (OCRProcessor processor = new OCRProcessor()) +{ + //Load an existing PDF document. + PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); + //Set the OCR language. + processor.Settings.Language = Languages.English; + processor.ImageProcessor = new ImageProcessor(); + //Perform OCR with input document. + string text = processor.PerformOCR(lDoc); + + //Save the document. + lDoc.Save("Output.pdf"); + //Close the document. + lDoc.Close(true); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} - ' Initialize the OCR processor. - Using processor As New OCRProcessor() - ' Load an existing PDF document. - Dim lDoc As New PdfLoadedDocument("Input.pdf") +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + +' Initialize the OCR processor. +Using processor As New OCRProcessor() + ' Load an existing PDF document. + Dim lDoc As New PdfLoadedDocument("Input.pdf") - ' Set the OCR language. - processor.Settings.Language = Languages.English - processor.ImageProcessor = New ImageProcessor() + ' Set the OCR language. + processor.Settings.Language = Languages.English + processor.ImageProcessor = New ImageProcessor() - ' Perform OCR with input document. - Dim text As String = processor.PerformOCR(lDoc) + ' Perform OCR with input document. + Dim text As String = processor.PerformOCR(lDoc) - ' Save the document into stream. - lDoc.Save("Output.pdf") + ' Save the document into stream. + lDoc.Save("Output.pdf") - ' Close the document. - lDoc.Close(True) - End Using + ' Close the document. + lDoc.Close(True) +End Using {% endhighlight %} {% endtabs %} - - N> Note: In this sample, we are using the SixLabors.ImageSharp library to improve the image quality. You can any image processing library as per your requirement. You can downloaded a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/OCR/.NET/Perform-OCR-ImageEnhancement). @@ -1390,7 +1513,10 @@ Here is a basic example of using Syncfusion® OCR processor with m {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/OCR-with-multiple-langauages/OCR%20with%20multiple%20languages/Program.cs, 300" %} + + using Syncfusion.OCRProcessor; + using Syncfusion.Pdf.Parsing; // Initialize the OCR processor within a using block to ensure resources are properly disposed using (OCRProcessor ocrProcessor = new OCRProcessor()) @@ -1425,44 +1551,11 @@ Here is a basic example of using Syncfusion® OCR processor with m {% endhighlight %} -{% highlight c# tabtitle="C# [Windows-specific]" %} - - // Initialize the OCR processor within a using block to ensure resources are properly disposed - using (OCRProcessor ocrProcessor = new OCRProcessor()) - { - // Set the Unicode font for the OCR processor using a TrueType font file - ocrProcessor.UnicodeFont = new Syncfusion.Pdf.Graphics.PdfTrueTypeFont( - new FileStream("arialuni.ttf", FileMode.Open), // Path to the TrueType font file - 12 // Font size - ); - - // Load the PDF document from the file stream - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); - - // Configure OCR settings - OCRSettings ocrSettings = new OCRSettings(); - - // Specify the languages to be used for OCR - ocrSettings.Language = "eng+deu+ara+ell+fra"; // English, German, Arabic, Greek, French - - // Apply the OCR settings to the OCR processor - ocrProcessor.Settings = ocrSettings; - - // Perform OCR on the loaded PDF document, providing the path to the tessdata directory - ocrProcessor.PerformOCR(loadedDocument, "tessdata"); - - // Save the OCR-processed document to the file save - loadedDocument.Save("OCR_Output.pdf"); - - // Close the loaded document and commit changes - loadedDocument.Close(true); - - } - -{% endhighlight %} - {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Imports Syncfusion.OCRProcessor + Imports Syncfusion.Pdf.Parsing + ' Initialize the OCR processor within a Using block to ensure resources are properly disposed Using ocrProcessor As New OCRProcessor() ' Set the Unicode font for the OCR processor using a TrueType font file @@ -1508,38 +1601,10 @@ Line breaks can be added to OCRed text using the [OCRLayoutResult](https://help. {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/OCR/.NET/Adding-Line-Breaks-Using-OCR/.NET/Adding-Line-Breaks-Using-OCR/Program.cs, 300" %} -// Initialize the OCR processor -using (OCRProcessor processor = new OCRProcessor()) -{ - // Load the PDF document from the file stream - PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); - - // Set OCR language to English - processor.Settings.Language = Languages.English; - - // Set the page segmentation mode to process sparse text with orientation and script detection - processor.Settings.PageSegment = PageSegMode.SparseTextOsd; - - // Perform OCR on the loaded PDF document to extract text - processor.PerformOCR(pdfLoadedDocument, processor.TessDataPath, out OCRLayoutResult layoutResult); - - // Extract the OCRed text from the first page and join lines with newline characters - string ocrText = string.Join("\n", layoutResult.Pages[0].Lines.Select(line => line.Text)); - - // Save the PDF document to the file stream - pdfLoadedDocument.Save("Output.pdf"); - // Close the PDF document - pdfLoadedDocument.Close(true); - - // Write the extracted OCR text to an output text file - File.WriteAllText("Output.txt", ocrText); -} - -{% endhighlight %} - -{% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.OCRProcessor; +using Syncfusion.Pdf.Parsing; // Initialize the OCR processor using (OCRProcessor processor = new OCRProcessor()) @@ -1561,7 +1626,6 @@ using (OCRProcessor processor = new OCRProcessor()) // Save the PDF document to the file stream pdfLoadedDocument.Save("Output.pdf"); - // Close the PDF document pdfLoadedDocument.Close(true); @@ -1573,6 +1637,9 @@ using (OCRProcessor processor = new OCRProcessor()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.OCRProcessor +Imports Syncfusion.Pdf.Parsing + ' Initialize the OCR processor Using processor As New OCRProcessor() ' Load the PDF document from the file stream @@ -1605,4 +1672,4 @@ End Using {% endtabs %} -You can downloaded a complete working sample from GitHub. \ No newline at end of file +You can downloaded a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/OCR/.NET/Adding-Line-Breaks-Using-OCR/.NET). \ No newline at end of file From 1787abc53fb4caa6c790a855a483e89c3e3b9742 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 6 Oct 2025 17:24:43 +0530 Subject: [PATCH 3/5] 985481-ug: Resolved CI failures. --- .../PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md index bee88deef..ef9fe58e7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md +++ b/Document-Processing/PDF/PDF-Library/NET/Save-pdf-files/To-AWS-S3.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Save PDF to AWS S3 +# Save PDF to an AWS S3 bucket To save a PDF file to AWS S3, you can follow the steps below From ebafaa0199adc2d9a5e41472d5e4ee8157618f92 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 6 Oct 2025 17:34:28 +0530 Subject: [PATCH 4/5] 985481-ug: Resolved CI failures. --- .../NET/FAQs/resolving-namespace-ambiguity-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md b/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md index 66d0c61e3..3158845ff 100644 --- a/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md +++ b/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md @@ -5,7 +5,7 @@ platform: document-processing documentation: UG --- -# Resolving Namespace Conflicts in Syncfusion® PDF Packages +# Resolving Namespace Conflicts in Syncfusion® PDF Packages ## Conflict Scenario From 13997859a8d0e79042e1b834a68a7001415616ec Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 6 Oct 2025 17:36:13 +0530 Subject: [PATCH 5/5] 985481-ug: Proper fix. --- .../NET/FAQs/resolving-namespace-ambiguity-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md b/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md index 3158845ff..8d1dd76c5 100644 --- a/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md +++ b/Document-Processing/PDF/PDF-Library/NET/FAQs/resolving-namespace-ambiguity-errors.md @@ -5,7 +5,7 @@ platform: document-processing documentation: UG --- -# Resolving Namespace Conflicts in Syncfusion® PDF Packages +# Resolving PDF Namespace Conflicts ## Conflict Scenario