From 507dfb9df92cccbc91aa6e81d166b9e77cea153b Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 8 Oct 2025 15:50:18 +0530 Subject: [PATCH 01/11] 983933-ug: Need to add the details in troubleshooting section --- .../HTML-To-PDF/NET/troubleshooting.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md index 480910a21..ee2fc3725 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md @@ -543,6 +543,58 @@ settings.CommandLineArguments.Add("--ignore-certificate-errors"); +## Security Alert - Bundled chrome.exe in HTML-to-PDF Conversion + + + + + + + + + + + + + + +
Issue +Security alerts are triggered when the Syncfusion HTML-to-PDF converter uses a bundled `chrome.exe` executable to render HTML content in headless mode during PDF generation. +
Reason +The HTML-to-PDF conversion relies on Chromium's Blink rendering engine:
+ +1.The NuGet package includes Blink binaries (`chrome.exe`) under `runtimes/win-x64/native`
+3.Security systems flag the execution of embedded binaries as potential risks
+
Solution +Use system-installed Chromium instead of bundled binaries: +

+Step 1: Configure Blink Path +{% tabs %} +{% highlight C# tabtitle="C#" %} + +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); +BlinkConverterSettings settings = new BlinkConverterSettings(); + +// Point to system-installed Chrome. +settings.BlinkPath = @"C:\Program Files\Google\Chrome\Application"; + +//Convert HTML to PDF. +htmlConverter.ConverterSettings = settings; +PdfDocument document = htmlConverter.Convert("https://example.com"); + +//Save and close the document. +document.Save(fs); +document.Close(true); + +{% endhighlight %} +{% endtabs %} + +Step 2: Verify Installation
+Ensure Chrome exists at the specified path (standard locations): `C:\Program Files\Google\Chrome\Application` + +
+ ## Conversion failure in windows server 2012 R2 From 8dadf0de9165dde3dffe95fe6a23ebcbe73ddcbb Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 8 Oct 2025 16:48:22 +0530 Subject: [PATCH 02/11] 983933-ug: Added proper code. --- .../PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md index ee2fc3725..5599d4a2f 100644 --- a/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md +++ b/Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md @@ -582,7 +582,7 @@ htmlConverter.ConverterSettings = settings; PdfDocument document = htmlConverter.Convert("https://example.com"); //Save and close the document. -document.Save(fs); +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} From 3426fae2a1cc6871da27d3c42b63288b4ca70dc1 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 8 Oct 2025 17:14:15 +0530 Subject: [PATCH 03/11] 984905-ug: Need to update the FAQ about installing required dependencies in linux. --- .../NET/Working-with-Image-Extraction.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Image-Extraction.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Image-Extraction.md index c1e9a3cf1..02af7045c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Image-Extraction.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Image-Extraction.md @@ -185,3 +185,54 @@ documentExtractor.Dispose() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Image%20Extraction/Extract-images-from-PDF-documents). N> To extract images from PDF page in .NET Core application, add the [Syncfusion.Pdf.Imaging.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Imaging.Net.Core) package to your project. + +## Troubleshooting and FAQ's + +### Missing SkiaSharp Native Assets on Ubuntu ARM64 + +
+ + + + + + + + + + + + +
Issue +Image extraction fails on Ubuntu 22.04.5 LTS servers running on ARM64 architecture due to missing SkiaSharp native dependencies. +
Reason +SkiaSharp requires platform-specific native binaries for graphics operations:
+ +1.The default SkiaSharp package doesn't include ARM64 Linux binaries.
+2.Ubuntu ARM64 environments lack these native assets by default.
+3.SkiaSharp fails to initialize without these dependencies.
+
Solution +Add the appropriate native assets package based on your environment:
+ +1.For Standard Linux Environments
+(Ubuntu, Alpine, CentOS, Debian, Fedora, RHEL, Azure App Service, Google App Engine) +

+{% highlight c# tabtitle="C#" %} + +dotnet add package SkiaSharp.NativeAssets.Linux --version 3.116.1 + +{% endhighlight %} + +2.For Serverless Environments
+(AWS Lambda, AWS Elastic Beanstalk) +

+{% highlight c# tabtitle="C#" %} + +dotnet add package SkiaSharp.NativeAssets.Linux.NoDependencies --version 3.116.1 + +{% endhighlight %} + +For Ubuntu 22.04.5 LTS on ARM64, use `SkiaSharp.NativeAssets.Linux`
+Check your `.csproj` file for the following entry: `` + +
\ No newline at end of file From 3decb1f722ce63e92087490cb6200c29fb74c31d Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 8 Oct 2025 17:50:18 +0530 Subject: [PATCH 04/11] 984905-ug: Resolved CI failures. --- .../PDF/PDF-Library/NET/Working-with-Image-Extraction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Image-Extraction.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Image-Extraction.md index 02af7045c..932a39df7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Image-Extraction.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Image-Extraction.md @@ -221,7 +221,7 @@ dotnet add package SkiaSharp.NativeAssets.Linux --version 3.116.1 {% endhighlight %} -2.For Serverless Environments
+2.For cloud native deployments
(AWS Lambda, AWS Elastic Beanstalk)

{% highlight c# tabtitle="C#" %} From d2c0a890d859616a9a394448ab37a2050ad988d0 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 6 Oct 2025 18:48:59 +0530 Subject: [PATCH 05/11] 985481-1: UG documentation feedback for PDF library --- .../PDF/PDF-Library/NET/Merge-Documents.md | 207 +++---- .../PDF/PDF-Library/NET/PdfGrid.md | 509 +++++++++++++----- 2 files changed, 496 insertions(+), 220 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md index 0aa295cb1..880b4c7ec 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md +++ b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md @@ -21,29 +21,26 @@ Refer to the following code example to merge multiple documents from disk. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs" %} -//Due to platform limitations, the PDF file cannot be loaded from disk. However, you can merge multiple documents from stream using the following code snippet. -//Creates a PDF document. +using Syncfusion.Pdf; + +//Creates a new PDF document. PdfDocument finalDoc = new PdfDocument(); -FileStream stream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -FileStream stream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); -//Creates a PDF stream for merging. -Stream[] streams = { stream1, stream2 }; +//Creates a string array of source files to be merged. +string[] source = { "file1.pdf", "file2.pdf" }; //Merges PDFDocument. -PdfDocumentBase.Merge(finalDoc, streams); +PdfDocument.Merge(finalDoc, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); -//Close the document. +//Saves the final document. +finalDoc.Save("Sample.pdf"); +//Closes the document. finalDoc.Close(true); -//Disposes the streams. -stream1.Dispose(); -stream2.Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Creates a new PDF document. PdfDocument finalDoc = new PdfDocument(); //Creates a string array of source files to be merged. @@ -60,6 +57,8 @@ finalDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Creates a new PDF document. Dim finalDoc As New PdfDocument() 'Creates a string array of source files to be merged. @@ -81,19 +80,20 @@ You can merge the PDF document streams by using the following code example. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs" %} +using Syncfusion.Pdf; + //Creates a PDF document. PdfDocument finalDoc = new PdfDocument(); -FileStream stream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -FileStream stream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); +Stream stream1 = File.OpenRead("file1.pdf"); +Stream stream2 = File.OpenRead("file2.pdf"); //Creates a PDF stream for merging. Stream[] streams = { stream1, stream2 }; //Merges PDFDocument. PdfDocumentBase.Merge(finalDoc, streams); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); -//Close the document. +//Saves the document. +finalDoc.Save("sample.pdf"); +//Closes the document. finalDoc.Close(true); //Disposes the streams. stream1.Dispose(); @@ -102,6 +102,9 @@ stream2.Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} + +using Syncfusion.Pdf; + //Creates a PDF document. PdfDocument finalDoc = new PdfDocument(); Stream stream1 = File.OpenRead("file1.pdf"); @@ -122,6 +125,8 @@ stream2.Dispose(); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Creates a PDF document. Dim finalDoc As New PdfDocument() Dim stream1 As Stream = File.OpenRead("file1.pdf") @@ -151,6 +156,8 @@ Essential® PDF provides support for importing the pages from one {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Importing-pages-from-one-document-another-document/.NET/Importing-pages-from-one-document-another-document/Program.cs" %} +using Syncfusion.Pdf; + //Load the PDF document. FileStream docStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); //Load the PDF document. @@ -171,6 +178,8 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Load the PDF document. PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Create a new document. @@ -188,6 +197,8 @@ lDoc.Close(true) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Load the PDF document Dim lDoc As New PdfLoadedDocument("file1.pdf") 'Creates a new document @@ -212,6 +223,8 @@ You can import multiple pages from an existing document by using [ImportPageRang {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Import-multiple-pages-from-an-existing-PDF/.NET/Import-multiple-pages-from-an-existing-PDF/Program.cs" %} +using Syncfusion.Pdf; + //Load the PDF document. FileStream docStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); //Load the PDF document. @@ -232,6 +245,8 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Loads PDF document. PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Create a new document. @@ -249,6 +264,8 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Loads PDF document Dim lDoc As New PdfLoadedDocument("file1.pdf") 'Creates a new document @@ -273,23 +290,20 @@ You can also import pages from multiple documents and arrange the pages by using {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Import-pages-from-multiple-documents-and-arrange-pages/.NET/Import-pages-from-multiple-documents-and-arrange-pages/Program.cs" %} -//Load the PDF document. -FileStream docStream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream1); -//Load the PDF document. -FileStream docStream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc2 = new PdfLoadedDocument(docStream2); +using Syncfusion.Pdf; + +//Loads document. +PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); +//Loads document. +PdfLoadedDocument lDoc2 = new PdfLoadedDocument("file1.pdf"); //Create the new document. PdfDocument document = new PdfDocument(); //Imports and arranges the pages. -document.ImportPage(lDoc, 1); -document.ImportPage(lDoc2, 0); +document.ImportPage(lDoc, 2); +document.ImportPage(lDoc2, 1); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Saves the document. +document.Save("sample.pdf"); //Closes the documents. document.Close(true); lDoc.Close(true); @@ -299,6 +313,8 @@ lDoc2.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Loads document. PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); //Loads document. @@ -320,6 +336,8 @@ lDoc2.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Loads a document Dim lDoc As New PdfLoadedDocument("file1.pdf") Dim lDoc2 As New PdfLoadedDocument("file2.pdf") @@ -359,6 +377,8 @@ You can split a large PDF document into multiple documents using [Split](https:/ {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Loads the PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("large.pdf"); //Splits the document. @@ -370,6 +390,8 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Loads the PDF document Dim loadedDocument As New PdfLoadedDocument("large.pdf") 'Splits the document @@ -388,31 +410,25 @@ The following code shows how to merge multiple PDF documents using [Merge](https {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs" %} -//Due to platform limitations, the PDF file cannot be loaded from disk. However, you can merge multiple documents from stream using the following code snippet. +using Syncfusion.Pdf; +//Input documents. +string[] inputDocuments = Directory.GetFiles("../../Data/Split"); //Creates a PDF document. -PdfDocument finalDoc = new PdfDocument(); -//Load the PDF document. -FileStream stream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -FileStream stream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); -//Creates a PDF stream for merging. -Stream[] streams = { stream1, stream2 }; -//Merges PDFDocument. -PdfDocumentBase.Merge(finalDoc, streams); +PdfDocument document = new PdfDocument(); +//Merges the document. +PdfDocumentBase.Merge(document, inputDocuments); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); -//Close the document. -finalDoc.Close(true); -//Disposes the streams. -stream1.Dispose(); -stream2.Dispose(); +//Save and close the document. +document.Save("Output.pdf"); +document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Input documents. string[] inputDocuments = Directory.GetFiles("../../Data/Split"); //Creates a PDF document. @@ -428,6 +444,8 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Input documents Dim inputDocuments As String() = Directory.GetFiles("../../Data/Split") 'Create a PDF document @@ -454,33 +472,29 @@ Refer to the following code example to optimize the PDF resources when merging P {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Optimize-the-PDF-resources-when-merging-PDF-documents/.NET/Optimize-the-PDF-resources-when-merging-PDF-documents/Program.cs" %} -//Due to platform limitations, the PDF file cannot be loaded from disk. However, you can optimize PDF resources when merging multiple documents from stream using the following code snippet. -//Create a PDF document. +using Syncfusion.Pdf; + +//Create a new PDF document. PdfDocument finalDoc = new PdfDocument(); -//Load the PDF document. -FileStream stream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -FileStream stream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); -//Creates a PDF stream for merging. -Stream[] streams = { stream1, stream2 }; +//Creates a string array of source files to be merged. +string[] source = { "file1.pdf", "file2.pdf" }; PdfMergeOptions mergeOptions = new PdfMergeOptions(); //Enable Optimize Resources. mergeOptions.OptimizeResources = true; //Merges PDFDocument. -PdfDocumentBase.Merge(finalDoc, mergeOptions, streams); +PdfDocument.Merge(finalDoc, mergeOptions, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the final document. +finalDoc.Save("Sample.pdf"); //Close the document. finalDoc.Close(true); -//Disposes the streams. -stream1.Dispose(); -stream2.Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Create a new PDF document. PdfDocument finalDoc = new PdfDocument(); //Creates a string array of source files to be merged. @@ -500,6 +514,8 @@ finalDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Create a new PDF document Dim finalDoc As New PdfDocument() 'Creates a string array of source files to be merged @@ -530,38 +546,34 @@ The following code sample illustrates this. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Extend-the-margin-of-PDF-pages-while-merging-PDFs/.NET/Extend-the-margin-of-PDF-pages-while-merging-PDFs/Program.cs" %} -//Due to platform limitations, the PDF file cannot be loaded from disk. However, you can optimize PDF resources when merging multiple documents from a stream using the following code snippet. -//Create a PDF document. + using Syncfusion.Pdf; + +//Create a new PDF document. PdfDocument finalDoc = new PdfDocument(); //Create new instance for the document margin. -PdfMargins margin= new PdfMargins(); -margin.All=40; +PdfMargins margin = new PdfMargins(); +margin.All = 40; //Set margin. finalDoc.PageSettings.Margins = margin; -//Load the PDF document. -FileStream stream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -FileStream stream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); -//Create a PDF stream for merging. -Stream[] streams = { stream1, stream2 }; +//Create a string array of source files to be merged. +string[] source = { "file1.pdf", "file2.pdf" }; PdfMergeOptions mergeOptions = new PdfMergeOptions(); -//Enable the Extend Margin. -mergeOptions.ExtendMargin = true; +// Enable the Extend Margin Property. +mergeOptions.ExtendMargin=true; //Merge PDFDocument. -PdfDocumentBase.Merge(finalDoc, mergeOptions, streams); +PdfDocument.Merge(finalDoc, mergeOptions, source); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +//Save the final document. +finalDoc.Save("Sample.pdf"); //Close the document. finalDoc.Close(true); -//Dispose the stream. -stream1.Dispose(); -stream2.Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Create a new PDF document. PdfDocument finalDoc = new PdfDocument(); //Create new instance for the document margin. @@ -586,6 +598,8 @@ finalDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Create a new PDF document Dim finalDoc As New PdfDocument() 'Create new instance for the document margin @@ -619,35 +633,30 @@ The Syncfusion® PDF library enables users to merge PDF documents Refer to the following code to merge PDF documents without losing accessibility tags. {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags/Program.cs" %} - -//Due to platform limitations, the PDF file cannot be loaded from disk. However, you can optimize PDF resources when merging multiple documents from a stream using the following code snippet. +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags/Program.cs" %} + +using Syncfusion.Pdf; -//Create a PDF document. +//Create a new PDF document. PdfDocument finalDoc = new PdfDocument(); -//Load the PDF document. -FileStream stream1 = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -FileStream stream2 = new FileStream("file2.pdf", FileMode.Open, FileAccess.Read); -//Create a PDF stream for merging. -Stream[] streams = { stream1, stream2 }; +//Create a string array of source files to be merged. +string[] source = { "file1.pdf", "file2.pdf" }; PdfMergeOptions mergeOptions = new PdfMergeOptions(); //Enable the Merge Accessibility Tags. mergeOptions.MergeAccessibilityTags = true; //Merge PDFDocument. -PdfDocumentBase.Merge(finalDoc, mergeOptions, streams); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -finalDoc.Save(stream); +PdfDocument.Merge(finalDoc, mergeOptions, source); +//Save the final document. +finalDoc.Save("Sample.pdf"); //Close the document. finalDoc.Close(true); -//Dispose the stream. -stream1.Dispose(); -stream2.Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; + //Create a new PDF document. PdfDocument finalDoc = new PdfDocument(); //Create a string array of source files to be merged. @@ -666,6 +675,8 @@ finalDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf + 'Create a new PDF document Dim finalDoc As New PdfDocument() 'Create a string array of source files to be merged diff --git a/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md b/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md index cd976a20b..1fd2dac05 100644 --- a/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md +++ b/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md @@ -29,6 +29,11 @@ The following code sample illustrates how to create a simple table from a data s {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; +using System.Data; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -49,10 +54,8 @@ pdfGrid.DataSource = dataTable; //Draw the grid to the page of PDF document. pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -60,6 +63,11 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; +using System.Data; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -130,6 +138,10 @@ The below code sample illustrates how to create the simple table directly using {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-the-data-directly-to-the-table-in-a-PDF/.NET/Add-the-data-directly-to-the-table-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add page. @@ -154,10 +166,8 @@ pdfGridRow.Cells[2].Value = "$10,000"; //Draw the PdfGrid. pdfGrid.Draw(pdfPage, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -165,6 +175,10 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add a page. @@ -240,6 +254,11 @@ Refer to the following code sample to create a table using [PdfGrid](https://hel {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Create-table-from-list-in-a-PDF-document/.NET/Create-table-from-list-in-a-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf.Parsing; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -262,10 +281,8 @@ pdfGrid.DataSource = tableData; //Draw the grid to the page of PDF document. pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -273,6 +290,11 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf.Parsing; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -345,6 +367,11 @@ You can create a table from a [DataSource](https://help.syncfusion.com/cr/docume {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Create-table-in-an-existing-document/.NET/Create-table-in-an-existing-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf.Parsing; + //Load the PDF document. FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); PdfLoadedDocument doc = new PdfLoadedDocument(docStream); @@ -368,10 +395,8 @@ pdfGrid.DataSource = dataTable; //Draw the grid to the page of PDF document. pdfGrid.Draw(graphics, new Syncfusion.Drawing.PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -379,6 +404,11 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf.Parsing; + //Load a PDF document. PdfLoadedDocument doc = new PdfLoadedDocument("input.pdf"); //Get the first page from the document. @@ -453,6 +483,10 @@ The following code example illustrates how to customize the cell in the [PdfGrid {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Cell-customization-in-PdfGrid/.NET/Cell-customization-in-PdfGrid/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -500,10 +534,8 @@ pdfGridCell.ImagePosition = PdfGridImagePosition.Fit; //Draw the PdfGrid. parentPdfGrid.Draw(pdfPage, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -511,6 +543,10 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -629,7 +665,11 @@ The following code sample illustrates how to customize the row in ``PdfGrid``. {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Row-customization-of-PdfGrid-in-a-PDF/.NET/Row-customization-of-PdfGrid-in-a-PDF/Program.cs" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Row-customization-of-PdfGrid-in-a-PDF/.NET/Row-customization-of-PdfGrid-in-a-PDF/Program.cs" %} + +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); @@ -664,10 +704,8 @@ pdfGrid.Rows[0].Style = pdfGridRowStyle; //Draw the PdfGrid. PdfGridLayoutResult result = pdfGrid.Draw(pdfPage, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -675,6 +713,10 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add page. @@ -769,6 +811,12 @@ The following code snippet illustrates how to customize the column in ``PdfGrid` {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Column-customization-of-PdfGrid-in-a-PDF/.NET/Column-customization-of-PdfGrid-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using System.Data; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add a page. @@ -800,10 +848,8 @@ pdfGrid.Columns[0].Format = format; //Draw the PdfGrid. PdfGridLayoutResult result = pdfGrid.Draw(pdfPage, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -811,6 +857,12 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using System.Data; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add a page. @@ -904,6 +956,10 @@ The following code snippet illustrates how to customize the table using [PdfGrid {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Customize-the-table-in-a-PDF-document/.NET/Customize-the-table-in-a-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -935,10 +991,8 @@ pdfGrid.Style = gridStyle; //Draw the grid to the page of a PDF document. pdfGrid.Draw(page, new PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -946,6 +1000,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -1043,7 +1101,10 @@ The below code example illustrates how to apply built-in table style using [Appl {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Create-table-with-built-in-style/.NET/Create-table-with-built-in-style/Program.cs" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Create-table-with-built-in-style/.NET/Create-table-with-built-in-style/Program.cs" %} + +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -1074,16 +1135,17 @@ pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent1); //Draw the grid to the page of PDF document. pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -1167,6 +1229,9 @@ The below code example illustrates how to apply built-in table styles with table {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Apply-built-in-style-to-table-with-table-option/.NET/Apply-built-in-style-to-table-with-table-option/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -1200,10 +1265,8 @@ pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent4, tableStyleOptio //Draw the grid to the page of PDF document. pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -1211,6 +1274,9 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -1304,6 +1370,10 @@ The below sample illustrates how to allow the ``PdfGrid`` to flow across pages. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Paginate-the-table-in-PDF-document/.NET/Paginate-the-table-in-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -1330,10 +1400,8 @@ layoutFormat.Layout = PdfLayoutType.Paginate; //Draw the grid to the page of PDF document. pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(10, 10), layoutFormat); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1341,6 +1409,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -1419,6 +1491,10 @@ The following code sample illustrates how to automatically adjust the width of t {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Automatically-adjust-the-table-width-in-a-PDF/.NET/Automatically-adjust-the-table-width-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a new section to the document. @@ -1450,9 +1526,8 @@ grid.Style.AllowHorizontalOverflow = true; //Draw the PdfGrid on the page. grid.Draw(page, PointF.Empty); -//Saving the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the instance of PdfDocument. document.Close(true); @@ -1460,6 +1535,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a new section to the document. @@ -1548,6 +1627,10 @@ The Essential® PDF supports maintaining the position of a PDF gri {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-multiple-tables-in-a-PDF-document/.NET/Add-multiple-tables-in-a-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -1588,9 +1671,8 @@ pdfGrid.DataSource = dataTable; //Draw the grid on the page using previous result. pdfGrid.Draw(page, new PointF(10, pdfGridLayoutResult.Bounds.Bottom + 20)); -//Saving the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1598,6 +1680,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -1707,6 +1793,11 @@ The following code snippet explains how to apply string formatting for the whole {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Apply-string-formatting-for-whole-table-in-a-PDF/.NET/Apply-string-formatting-for-whole-table-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the document. @@ -1740,15 +1831,19 @@ for (int i = 0; i < grid.Columns.Count; i++) //Draw the PdfGrid on the page. grid.Draw(page, new PointF(10, 10)); -//Saving the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the document. @@ -1842,6 +1937,11 @@ The following code snippet explains how to add string formatting to a particular {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-string-formatting-to-a-column-in-table/.NET/Add-string-formatting-to-a-column-in-table/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the document. @@ -1872,15 +1972,19 @@ grid.Columns[1].Format = stringFormat; //Draw the PdfGrid on the page. grid.Draw(page, new PointF(10, 10)); -//Saving the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the document. @@ -1965,6 +2069,11 @@ The following code sample illustrates how to add the string formatting for a par {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-string-formatting-for-a-cell-in-table/.NET/Add-string-formatting-for-a-cell-in-table/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the PdfDocument. @@ -1995,14 +2104,18 @@ grid.Rows[2].Cells[1].StringFormat = stringFormat; //Draw the PdfGrid on a page. grid.Draw(page, new PointF(10, 10)); -//Save the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the PdfDocument. @@ -2086,6 +2199,11 @@ The following code sample illustrates how to add the string formatting for a par {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-string-formatting-for-a-row-in-table/.NET/Add-string-formatting-for-a-row-in-table/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the PdfDocument. @@ -2119,15 +2237,18 @@ for (int i = 0; i < grid.Columns.Count; i++) //Draw the PdfGrid on the page. grid.Draw(page, new PointF(10, 10)); -//Save a PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); -document.Close(true); +//Save the PDF document. +document.Save("Output.pdf"); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the document. @@ -2224,6 +2345,11 @@ The following code sample illustrates how to span a row in the [PdfGrid](https:/ {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-row-spanning-in-a-PDF-table/.NET/Add-row-spanning-in-a-PDF-table/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create the page. @@ -2252,9 +2378,8 @@ gridCell.Style.BackgroundBrush = PdfBrushes.Yellow; //Draw the PdfGrid. pdfGrid.Draw(page, new PointF(10, 10)); -//Saving the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -2262,6 +2387,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create the page. @@ -2342,7 +2472,12 @@ The following code sample illustrates how to span a column in the [PdfGrid](http {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-column-spanning-in-a-PDF-table/.NET/Add-column-spanning-in-a-PDF-table/Program.cs" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-column-spanning-in-a-PDF-table/.NET/Add-column-spanning-in-a-PDF-table/Program.cs" %} + +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; //Create a new PDF document. PdfDocument document = new PdfDocument(); @@ -2372,15 +2507,19 @@ gridCell.Style.BackgroundBrush = PdfBrushes.Yellow; //Draw the PdfGrid. pdfGrid.Draw(page, new PointF(10, 10)); -//Save a PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create the page. @@ -2466,6 +2605,11 @@ The following code sample explains how to add different cell styles to a cell in {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-different-cell-styles-to-a-cell-in-a-PDF-table/.NET/Add-different-cell-styles-to-a-cell-in-a-PDF-table/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add a page. @@ -2532,9 +2676,8 @@ gridCell.StringFormat = stringFormat; //Draw the table on the PDF page. pdfGrid.Draw(pdfPage, new PointF(10, 10)); -//Save a PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the instance of the PdfDocument. pdfDocument.Close(true); @@ -2542,6 +2685,11 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); /Add a page. @@ -2697,6 +2845,11 @@ The Syncfusion® .NET PDF library supports applying different styl {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-different-styles-to-a-row-in-PDF-table/.NET/Add-different-styles-to-a-row-in-PDF-table/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add a page. @@ -2751,9 +2904,8 @@ gridRow.ApplyStyle(gridCellStyle); //Draw the table on the PDF page. pdfGrid.Draw(pdfPage, new PointF(10, 10)); -//Save a PDF to the Memory Stream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the instance of the PdfDocument. pdfDocument.Close(true); @@ -2761,6 +2913,11 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add a page. @@ -2894,6 +3051,11 @@ The following code sample explains how to use the ``ApplyStyle`` method to apply {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Applying-Customizing-Styles-in-PDF-Grid/.NET/Applying-Customizing-Styles-in-PDF-Grid/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -2927,11 +3089,8 @@ pdfGrid.Rows[0].ApplyStyle(rowStyle); //Draw grid to the page of PDF document. pdfGrid.Draw(page, new PointF(10, 10)); -//Save the PDF document to stream. -using(FileStream outputStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite )) -{ - document.Save(outputStream); -} +//Save the PDF document. +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -2939,6 +3098,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -3045,6 +3209,11 @@ The following code sample explains how to apply word wrap in the PDF table cell. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Apply-word-wrap-in-the-PDF-table-cell/.NET/Apply-word-wrap-in-the-PDF-table-cell/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -3080,9 +3249,8 @@ foreach (PdfGridRow row in grid.Headers) //Draw a grid to the resultant page of the first grid. grid.Draw(page, new PointF(10, 20)); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -3090,6 +3258,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -3193,6 +3366,11 @@ The following code sample illustrates how to rotate the [PdfGrid](https://help.s {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Draw-rotated-table-in-PDF-document/.NET/Draw-rotated-table-in-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -3219,9 +3397,8 @@ pdfGrid.RepeatHeader = true; //Draw a grid to the page of a PDF document. pdfGrid.Draw(page, new RectangleF(100, 20, 0, page.GetClientSize().Width)); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -3241,6 +3418,11 @@ private void PdfGrid_BeginPageLayout(object sender, BeginPageLayoutEventArgs e) {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -3362,6 +3544,12 @@ The following code example illustrates how to render the HTML string in a [PdfGr {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Draw-HTML-styled-text-in-a-PDF-table-cell/.NET/Draw-HTML-styled-text-in-a-PDF-table-cell/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -3387,9 +3575,8 @@ row2.Cells[1].Value = richTextElement; //Draw the PdfGrid. pdfGrid.Draw(pdfPage, PointF.Empty); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -3397,6 +3584,12 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using System.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -3477,6 +3670,12 @@ The following code illustrates adding the background image into a table cell. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-the-background-image-in-a-PDF-table-cell/.NET/Add-the-background-image-in-a-PDF-table-cell/Program.cs" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using Syncfusion.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Add a page to the PDF document. @@ -3517,9 +3716,8 @@ pdfGridCell.ImagePosition = PdfGridImagePosition.Stretch; //Draw the PdfGrid. pdfGrid.Draw(pdfPage, PointF.Empty); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -3527,6 +3725,12 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using System.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); @@ -3630,6 +3834,13 @@ The following code illustrates how to create a table with different font styles {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-different-font-style-for-particular-table-cell/.NET/Add-different-font-style-for-particular-table-cell/Program.cs" %} + +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using Syncfusion.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -3665,9 +3876,8 @@ pdfGrid.Rows[0].Cells[0].StringFormat = format; //Draw the PdfGrid. pdfGrid.Draw(pdfPage, PointF.Empty); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -3689,6 +3899,12 @@ private static void PdfGrid_BeginCellLayout(object sender, PdfGridBeginCellLayou {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using System.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -3820,6 +4036,12 @@ The following code sample shows how to insert the image in a particular [PdfGrid {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Insert-image-in-a-particular-table-cell/.NET/Insert-image-in-a-particular-table-cell/Program.cs" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using Syncfusion.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -3843,9 +4065,8 @@ pdfGrid.BeginCellLayout += PdfGrid_BeginCellLayout; //Draw a grid to the page of a PDF document. pdfGrid.Draw(pdfPage, new PointF(10, 10)); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -3866,6 +4087,12 @@ private static void PdfGrid_BeginCellLayout(object sender, PdfGridBeginCellLayou {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using System.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -3968,6 +4195,12 @@ The following code sample illustrates how to draw a border less table in a PDF d {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Draw-borderless-table-in-PDF-document/.NET/Draw-borderless-table-in-PDF-document/Program.cs" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using Syncfusion.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -4022,9 +4255,8 @@ for (int i = 0; i < pdfGrid.Rows.Count; i++) //Draw a grid to the page of a PDF document. pdfGrid.Draw(pdfPage, new PointF(10, 10)); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -4032,6 +4264,12 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using System.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -4167,6 +4405,11 @@ The following code illustrates how to create the nested table in a PDF document {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Create-nested-table-in-a-PDF-document/.NET/Create-nested-table-in-a-PDF-document/Program.cs" %} +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using Syncfusion.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -4208,9 +4451,8 @@ parentPdfGrid.Rows[1].Cells[2].Style.CellPadding = new PdfPaddings(5, 5, 5, 5); //Draw the parent PdfGrid parentPdfGrid.Draw(pdfPage, PointF.Empty); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); +//Save the PDF document. +pdfDocument.Save("Output.pdf"); //Close the document. pdfDocument.Close(true); @@ -4218,6 +4460,11 @@ pdfDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using System.Drawing; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Create the page. @@ -4330,6 +4577,12 @@ The following code sample illustrates how to add a hyperlink in a table cell. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Add-a-hyperlink-in-a-table-cell/.NET/Add-a-hyperlink-in-a-table-cell/Program.cs" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a new page. @@ -4359,9 +4612,8 @@ row.Cells[1].Style = cellStyle; //Draw the grid. grid.Draw(page, new PointF(0, 0)); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -4369,6 +4621,12 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf; +using System.Drawing; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Adds a new page. @@ -4455,6 +4713,9 @@ The following code sample demonstrates how to prevent row breaks across pages in {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; + // Create a new PDF document using (PdfDocument document = new PdfDocument()) { @@ -4485,18 +4746,17 @@ using (PdfDocument document = new PdfDocument()) // Draw the grid on the page pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, 0)); - //Create file stream. - using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document. + document.Save("Output.pdf"); } {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; + // Create a new PDF document using (PdfDocument document = new PdfDocument()) { @@ -4583,6 +4843,10 @@ The following code sample demonstrates how to change the page margins beginning {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + // Create PDF document with default settings PdfDocument document = new PdfDocument(); @@ -4622,11 +4886,8 @@ pdfGrid.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format); -// Generate output file -using (FileStream stream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) -{ - document.Save(stream); -} +//Save the PDF document. +document.Save("Output.pdf"); // Proper document cleanup document.Close(true); @@ -4635,6 +4896,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using System.Drawing; + // Create PDF document with default settings PdfDocument document = new PdfDocument(); @@ -4731,4 +4996,4 @@ document.Close(True) {% endtabs %} -You can download a complete working sample from GitHub. \ No newline at end of file +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET). \ No newline at end of file From 3e942e4b0e740e4c77b1c2dd31e48bb4feb59f6d Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Tue, 7 Oct 2025 10:08:27 +0530 Subject: [PATCH 06/11] 985481-1: Completed both md files. --- .../PDF/PDF-Library/NET/Merge-Documents.md | 8 +- .../PDF/PDF-Library/NET/PdfGrid.md | 161 +++++++++++++++++- 2 files changed, 161 insertions(+), 8 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md index 880b4c7ec..90372a57a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md +++ b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md @@ -159,9 +159,7 @@ Essential® PDF provides support for importing the pages from one using Syncfusion.Pdf; //Load the PDF document. -FileStream docStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Create a new document. PdfDocument document = new PdfDocument(); //Imports the page at 1 from the lDoc. @@ -226,9 +224,7 @@ You can import multiple pages from an existing document by using [ImportPageRang using Syncfusion.Pdf; //Load the PDF document. -FileStream docStream = new FileStream("file1.pdf", FileMode.Open, FileAccess.Read); -//Load the PDF document. -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Create a new document. PdfDocument document = new PdfDocument(); //Imports the page at 1 from the lDoc. diff --git a/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md b/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md index 1fd2dac05..d7ab7252d 100644 --- a/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md +++ b/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md @@ -97,6 +97,11 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Grid +Imports System.Data + 'Create a new PDF document. Dim doc As PdfDocument = New PdfDocument() 'Add a page. @@ -212,6 +217,10 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim pdfDocument As New PdfDocument() 'Add page. @@ -326,6 +335,11 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Pdf.Parsing + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -373,8 +387,7 @@ using Syncfusion.Pdf.Grid; using Syncfusion.Pdf.Parsing; //Load the PDF document. -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument doc = new PdfLoadedDocument(docStream); +PdfLoadedDocument doc = new PdfLoadedDocument("Input.pdf"); //Get the first page from a document. PdfLoadedPage page = doc.Pages[0] as PdfLoadedPage; //Create PDF graphics for the page. @@ -440,6 +453,11 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Pdf.Parsing + 'Load a PDF document. Dim doc As New PdfLoadedDocument("input.pdf") 'Get the first page from the document. @@ -602,6 +620,10 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim pdfDocument As New PdfDocument() 'Create the page. @@ -758,6 +780,10 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim pdfDocument As New PdfDocument() 'Add page. @@ -902,6 +928,12 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports System.Data + 'Create a new PDF document. Dim pdfDocument As New PdfDocument() 'Add a page. @@ -1044,6 +1076,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As New PdfDocument() 'Add a page. @@ -1181,6 +1217,9 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -1316,6 +1355,9 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -1447,6 +1489,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As New PdfDocument() 'Add a page. @@ -1579,6 +1625,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Add a new section to the document. @@ -1732,6 +1782,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Add a page. @@ -1885,6 +1939,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Add page to the document. @@ -2023,6 +2082,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument @@ -2153,6 +2216,12 @@ document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Add page to the PdfDocument. @@ -2290,6 +2359,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Add page to the document. @@ -2429,6 +2503,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Create the page. @@ -2557,6 +2636,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Create the page. @@ -2763,6 +2847,11 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim pdfDocument As PdfDocument = New PdfDocument 'Add a page. @@ -2979,6 +3068,11 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim pdfDocument As PdfDocument = New PdfDocument 'Add a page. @@ -3145,6 +3239,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + ' Create a new PDF document. Dim document As New PdfDocument() @@ -3310,6 +3409,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument() @@ -3472,6 +3576,11 @@ private void PdfGrid_BeginPageLayout(object sender, Syncfusion.Pdf.Graphics.Begi {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument() 'Add a page. @@ -3624,6 +3733,12 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Drawing +Imports System.Reflection.Metadata + 'Create a new PDF document. Dim pdfDocument As New PdfDocument() 'Create the page. @@ -3779,6 +3894,12 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Drawing +Imports System.Reflection.Metadata + 'Create a new PDF document. Dim pdfDocument As PdfDocument = New PdfDocument() 'Add a page to the PDF document. @@ -3965,6 +4086,12 @@ private static void PdfGrid_BeginCellLayout(object sender, PdfGridBeginCellLayou {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Drawing +Imports System.Reflection.Metadata + 'Create a new PDF document. Dim pdfDocument As PdfDocument = New PdfDocument() 'Create the page. @@ -4138,6 +4265,12 @@ private static void PdfGrid_BeginCellLayout(object sender, PdfGridBeginCellLayou {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Drawing +Imports System.Reflection.Metadata + 'Create a new PDF document. Dim pdfDocument As PdfDocument = New PdfDocument() 'Create the page. @@ -4334,6 +4467,12 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Drawing +Imports System.Reflection.Metadata + 'Create a new PDF document. Dim pdfDocument As PdfDocument = New PdfDocument() 'Create the page. @@ -4515,6 +4654,11 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Drawing +Imports System.Reflection.Metadata + 'Create a new PDF document. Dim pdfDocument As PdfDocument = New PdfDocument() 'Create the page. @@ -4664,6 +4808,12 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf +Imports Syncfusion.Drawing + 'Creates a new PDF document. Dim document As PdfDocument = New PdfDocument() 'Add a new page. @@ -4795,6 +4945,9 @@ using (PdfDocument document = new PdfDocument()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Pdf + ' Create a new PDF document Using document As New PdfDocument() @@ -4949,6 +5102,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Grid +Imports Syncfusion.Pdf +Imports System.Drawing + ' Create PDF document with default settings Dim document As New PdfDocument() From b1a76a88c8de42af296f004bbadeaeedb40be64f Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Tue, 7 Oct 2025 17:27:09 +0530 Subject: [PATCH 07/11] 985481-1: Added changes in md files. --- .../PDF/PDF-Library/NET/PdfLightTable.md | 250 ++- .../PDF/PDF-Library/NET/Split-Documents.md | 195 +- .../NET/Working-with-Annotations.md | 1690 ++++++++++++----- .../NET/Working-with-Attachments.md | 228 ++- .../PDF-Library/NET/Working-with-Barcode.md | 343 ++-- .../PDF-Library/NET/Working-with-Bookmarks.md | 141 +- .../PDF-Library/NET/Working-with-Brushes.md | 118 +- .../PDF-Library/NET/Working-with-action.md | 366 ++-- 8 files changed, 2260 insertions(+), 1071 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md b/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md index f3f4f628b..54ccf59d1 100644 --- a/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md +++ b/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md @@ -24,6 +24,11 @@ The following code sample illustrates how to create a simple table from a data s {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Create-simple-table-from-data-source/.NET/Create-simple-table-from-data-source/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Tables; +using System.Data; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -42,10 +47,8 @@ pdfLightTable.DataSource = table; //Draw PdfLightTable. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(0, 0)); -//Create the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -53,6 +56,11 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Tables; +using System.Data; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -82,6 +90,11 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Tables +Imports System.Data + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -123,6 +136,11 @@ The following code illustrates how to add the data directly into the [PdfLightTa {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Add-the-data-directly-into-the-PDF-table/.NET/Add-the-data-directly-into-the-PDF-table/Program.cs" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; +using Syncfusion.Pdf; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -144,10 +162,8 @@ pdfLightTable.Rows.Add(new object[] { "111", "Maxim", "III" }); //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -155,6 +171,11 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; +using Syncfusion.Pdf; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -185,6 +206,11 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Tables +Imports Syncfusion.Pdf +Imports System.Reflection.Metadata + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -225,10 +251,14 @@ Create a table using the [PdfLightTable](https://help.syncfusion.com/cr/document {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Creating-the-table-in-an-existing-PDF-document/.NET/Creating-the-table-in-an-existing-PDF-document/Program.cs" %} -//Get stream from an existing PDF document. -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf.Tables; +using Syncfusion.Pdf; +using System.Reflection.Metadata; + //Load the PDF document. -PdfLoadedDocument doc = new PdfLoadedDocument(docStream); +PdfLoadedDocument doc = new PdfLoadedDocument("Input.pdf"); //Get the first page from the document PdfLoadedPage page = doc.Pages[0] as PdfLoadedPage; //Create PDF graphics for the page @@ -248,10 +278,8 @@ pdfLightTable.DataSource = table; //Draw PdfLightTable. pdfLightTable.Draw(graphics, new Syncfusion.Drawing.PointF(0, 0)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -259,6 +287,12 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf.Tables; +using Syncfusion.Pdf; +using System.Reflection.Metadata; + //Load a PDF document. PdfLoadedDocument doc = new PdfLoadedDocument("input.pdf"); //Get the first page from document. @@ -290,6 +324,12 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf.Tables +Imports Syncfusion.Pdf +Imports System.Reflection.Metadata + 'Load a PDF document. Dim doc As New PdfLoadedDocument("input.pdf") 'Get the first page from document. @@ -332,6 +372,12 @@ The following code sample illustrates how to customize the cell properties in `` {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Customize-the-table-cell-in-PDF-document/.NET/Customize-the-table-cell-in-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; +using System.Data.Common; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -365,10 +411,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -376,6 +420,12 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; +using System.Data.Common; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -419,6 +469,12 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports System.Data.Common +Imports Syncfusion.Pdf.Tables +Imports Syncfusion.Pdf +Imports System.Reflection.Metadata + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -473,6 +529,10 @@ The following code example illustrates how to draw the graphics elements in the {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Draw-graphics-element-in-particular-cell/.NET/Draw-graphics-element-in-particular-cell/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -498,10 +558,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -526,6 +584,10 @@ private void pdfLightTable_BeginCellLayout(object sender, BeginCellLayoutEventAr {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -575,6 +637,10 @@ private void pdfLightTable_BeginCellLayout(object sender, BeginCellLayoutEventAr {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Tables +Imports Syncfusion.Pdf + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -632,6 +698,10 @@ You can download a complete working sample from [GitHub](https://github.com/Sync {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Row-customization-of-the-table-in-PDF-document/.NET/Row-customization-of-the-table-in-PDF-document/Program.cs" %} +using Syncfusion.Pdf.Tables; +using Syncfusion.Pdf; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -657,10 +727,8 @@ pdfLightTable.EndRowLayout += pdfLightTable_EndRowLayout; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Create the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to the stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -690,6 +758,10 @@ private void pdfLightTable_BeginRowLayout(object sender, BeginRowLayoutEventArgs {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Tables; +using Syncfusion.Pdf; +using System.Reflection.Metadata; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -752,6 +824,10 @@ private void pdfLightTable_BeginRowLayout(object sender, BeginRowLayoutEventArgs {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Reflection.Metadata +Imports Syncfusion.Pdf.Tables +Imports Syncfusion.Pdf + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -815,6 +891,11 @@ The following code sample illustrates how to customize the column in [PdfLightTa {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Column-customization-of-the-table-in-PDF-document/.NET/Column-customization-of-the-table-in-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; +using System.Data.Common; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page @@ -847,10 +928,8 @@ pdfLightTable.Style.ShowHeader = true; //Draw the PdfLightTable. pdfLightTable.Draw(page, Syncfusion.Drawing.PointF.Empty); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the PDF document to the stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -858,6 +937,11 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; +using System.Data.Common; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -899,6 +983,11 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Tables +Imports System.Data.Common + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -952,6 +1041,10 @@ The following code sample illustrates how to customize the table using [PdfLight {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Customize-the-table-in-a-PDF-document/.NET/Customize-the-table-in-a-PDF-document/Program.cs" %} +using Syncfusion.Pdf.Tables; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -983,16 +1076,18 @@ pdfLightTable.Style = lightTableStyle; //Draw PdfLightTable. pdfLightTable.Draw(page, new PointF(0, 0)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); //Close the document. document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Tables; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -1035,6 +1130,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Tables +Imports Syncfusion.Pdf +Imports Syncfusion.Drawing + 'Create a new PDF document. Dim document As New PdfDocument() 'Add a page. @@ -1096,6 +1195,11 @@ The following code example illustrates how to apply built-in table style using [ {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Create-table-with-built-in-style/.NET/Create-table-with-built-in-style/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Tables; +using System.Data; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -1125,10 +1229,8 @@ pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable4Accent2); //Draw the grid to the page of a PDF document. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(10, 10)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -doc.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. doc.Close(true); @@ -1136,6 +1238,11 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Tables; +using System.Data; + //Create a new PDF document. PdfDocument doc = new PdfDocument(); //Add a page. @@ -1170,6 +1277,11 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Tables +Imports System.Data + 'Create a new PDF document. Dim doc As New PdfDocument() 'Add a page. @@ -1219,6 +1331,10 @@ The following sample illustrates how to allow the ``PdfLightTable`` to flow acro {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Paginate-table-in-a-PDF-document/.NET/Paginate-table-in-a-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -1243,16 +1359,18 @@ layoutFormat.Layout = PdfLayoutType.Paginate; //Draw PdfLightTable. pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(0, 0), layoutFormat); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document as a stream. -document.Save(stream); +//Save the PDF document. +doc.Save("Output.pdf"); //Close the document. document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page. @@ -1288,6 +1406,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf.Tables + 'Create a new PDF document. Dim document As New PdfDocument() 'Add a page. @@ -1336,6 +1458,11 @@ The following code sample explains how to add string formatting for the whole ta {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Add-string-formatting-for-whole-table-in-a-PDF/.NET/Add-string-formatting-for-whole-table-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the document. @@ -1369,15 +1496,20 @@ for (int i = 0; i < lightTable.Columns.Count; i++) //Draw the PdfLightTable on the page. lightTable.Draw(page, new PointF(10, 10)); -//Save a PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); +//Close the document document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the document. @@ -1419,6 +1551,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf.Tables +Imports System.Drawing + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Add page to the document. @@ -1470,6 +1607,11 @@ The following code sample explains how to add string formatting to a column in t {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfLightTable/Add-string-formatting-to-a-column-in-table/.NET/Add-string-formatting-to-a-column-in-table/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add page to the document. @@ -1500,15 +1642,20 @@ lightTable.Columns[1].StringFormat = stringFormat; //Draw the PdfLightTable on the page. lightTable.Draw(page, new PointF(10, 10)); -//Save the PDF to the MemoryStream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the PDF document. +document.Save("Output.pdf"); +//Close the PDF document document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Tables; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page to the document. @@ -1547,6 +1694,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf.Tables +Imports System.Drawing + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument 'Add a page to the document. diff --git a/Document-Processing/PDF/PDF-Library/NET/Split-Documents.md b/Document-Processing/PDF/PDF-Library/NET/Split-Documents.md index aeb7989f1..516fbb1b1 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Split-Documents.md +++ b/Document-Processing/PDF/PDF-Library/NET/Split-Documents.md @@ -23,31 +23,25 @@ Refer to the following code example to split a PDF into individual pages. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/Program.cs" %} -//Due to platform limitations, Essential® PDF supports splitting a PDF file into individual pages only in Windows Forms, WPF, ASP.NET, and ASP.NET MVC platforms. However this can be achieved by using the following code snippet. +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Load the PDF document -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream, true); -for (int i = 0; i < loadedDocument.Pages.Count; i++) -{ - //Creates a new document. - PdfDocument document = new PdfDocument(); - //Imports the pages from the loaded document. - document.ImportPage(loadedDocument, i); - - //Create a File stream. - using (var outputFileStream = new FileStream("Output" + i + ".pdf", FileMode.Create, FileAccess.Write)) { - //Save the document to stream. - document.Save(outputFileStream); - } - //Close the document. - document.Close(true); -} +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +//Set a output path +const string destinationFilePattern = "Output" + "{0}.pdf"; +//Split the pages into separate documents +loadedDocument.Split(destinationFilePattern); +//Close the document +loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Set a output path @@ -61,6 +55,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing + 'Load the PDF document Dim loadedDocument As New PdfLoadedDocument("Input.pdf") 'Set a output path @@ -85,30 +82,24 @@ Refer to the following code example to split a range of pages. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Split-a-Range-of-Pages/.NET/Split-a-Range-of-Pages/Program.cs" %} -{% raw %} +using Syncfusion.Pdf.Parsing; -//Load the existing PDF file. -PdfLoadedDocument loadDocument = new PdfLoadedDocument(new FileStream("Input.pdf", FileMode.Open)); -//Subscribe to the document split event. -loadDocument.DocumentSplitEvent += LoadDocument_DocumentSplitEvent; -void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args) -{ - //Save the resulting document. - FileStream outputStream = new FileStream(Guid.NewGuid().ToString() + ".pdf", FileMode.CreateNew); - args.PdfDocumentData.CopyTo(outputStream); - outputStream.Close(); -} -//Spit the document by ranges. -loadDocument.SplitByRanges(new int[,] { { 0, 5 }, { 5, 10 } }); - -//Close the document. -loadDocument.Close(true); +//Create the values. +int[,] values = new int[,] { { 2, 5 }, { 8, 10 } }; +//Load the PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +//Set a output path +const string destinationFilePattern = "Output" + "{0}.pdf"; +//Split the pages into fixed number +loadedDocument.SplitByRanges(destinationFilePattern, values); +//close the document +loadedDocument.Close(true); -{% endraw %} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -{% raw %} + +using Syncfusion.Pdf.Parsing; //Create the values. int[,] values = new int[,] { { 2, 5 }, { 8, 10 } }; @@ -121,11 +112,11 @@ loadedDocument.SplitByRanges(destinationFilePattern, values); //close the document loadedDocument.Close(true); -{% endraw %} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -{% raw %} + +Imports Syncfusion.Pdf.Parsing 'Create the values. Dim values As Integer(,) = New Integer(,) {{2, 5},{8, 10}} @@ -138,7 +129,6 @@ loadedDocument.SplitByRanges(destinationFilePattern, values) 'Close the document. loadedDocument.Close(True) -{% endraw %} {% endhighlight %} {% endtabs %} @@ -154,27 +144,24 @@ Refer to the following code example to split by a fixed number of pages. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Split-by-FixedNumber/.NET/Split-by-FixedNumber/Program.cs" %} -//Load the existing PDF file. -PdfLoadedDocument loadDocument = new PdfLoadedDocument(new FileStream("Input.pdf", FileMode.Open)); -//Subscribe to the document split event. -loadDocument.DocumentSplitEvent += LoadDocument_DocumentSplitEvent; -void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args) -{ - //Save the resulting document. - FileStream outputStream = new FileStream(Guid.NewGuid().ToString() + ".pdf", FileMode.CreateNew); - args.PdfDocumentData.CopyTo(outputStream); - outputStream.Close(); -} -//Spit the document by a fixed number. -loadDocument.SplitByFixedNumber(2); +using Syncfusion.Pdf.Parsing; -//Close the document. -loadDocument.Close(true); +//Load the PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +//Set a output path +const string destinationFilePattern = "Output" + "{0}.pdf"; +//Split the pages into fixed number +loadedDocument.SplitByFixedNumber(destinationFilePattern, 4); + +//close the document +loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Parsing; + //Load the PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Set a output path @@ -189,6 +176,8 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing + 'Load the PDF document. Dim loadedDocument As New PdfLoadedDocument("Input.pdf") 'Set a output path @@ -214,9 +203,12 @@ Refer to the following code example to split a PDF using bookmarks. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Split-PDF-based-Bookmarks/.NET/Split-PDF-based-Bookmarks/Program.cs" %} +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; + // Load the PDF document -using (FileStream fileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) -using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream)) +using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) { PdfBookmarkBase bookmarks = loadedDocument.Bookmarks; // Iterate all the bookmarks and their page ranges @@ -236,11 +228,8 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream)) } // Import the pages to the new PDF document document.ImportPageRange(loadedDocument, bookmark.Destination.PageIndex, endIndex); - //Save the document as stream - using (MemoryStream stream = new MemoryStream()) - { - document.Save(stream); - } + //Save the document + document.Save("Output.pdf"); } } } @@ -251,6 +240,10 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream)) {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; + // Load the PDF document using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) { @@ -272,7 +265,7 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) } // Import the pages to the new PDF document document.ImportPageRange(loadedDocument, bookmark.Destination.PageIndex, endIndex); - //Save the document as stream + //Save the document document.Save("Output.pdf"); } } @@ -284,6 +277,10 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf.Interactive + Using loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") Dim bookmarks As PdfBookmarkBase = loadedDocument.Bookmarks For Each bookmark As PdfBookmark In bookmarks @@ -315,33 +312,31 @@ The Syncfusion® PDF library enables the splitting of PDF document {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Remove-Unused-Resources-when-Splitting-PDF-Documents/.NET/Remove-Unused-Resources-when-Splitting-PDF-Documents/Program.cs" %} -{% raw %} -//Load the existing PDF file. -PdfLoadedDocument loadDocument = new PdfLoadedDocument(new FileStream("Input.pdf", FileMode.Open)); -//Subscribe to the document split event. -loadDocument.DocumentSplitEvent += LoadDocument_DocumentSplitEvent; -void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args) -{ - //Save the resulting document. - FileStream outputStream = new FileStream(Guid.NewGuid().ToString() + ".pdf", FileMode.CreateNew); - args.PdfDocumentData.CopyTo(outputStream); - outputStream.Close(); -} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + +//Create the values. +int[,] values = new int[,] { { 2, 5 }, { 8, 10 } }; +//Load the PDF document. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +//Set an output file pattern. +const string destinationFilePattern = "Output{0}.pdf"; //Create the split options object. PdfSplitOptions splitOptions = new PdfSplitOptions(); //Enable the removal of unused resources property. splitOptions.RemoveUnusedResources = true; //Split the document by ranges. -loadDocument.SplitByRanges(new int[,] { { 0, 5 }, { 5, 10 } }, splitOptions); +loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions); //Close the document. -loadDocument.Close(true); +loadedDocument.Close(true); -{% endraw %} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -{% raw %} + +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Create the values. int[,] values = new int[,] { { 2, 5 }, { 8, 10 } }; @@ -358,11 +353,12 @@ loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions); //Close the document. loadedDocument.Close(true); -{% endraw %} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -{% raw %} + +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing 'Create the values. Dim values As Integer(,) = New Integer(,) {{2, 5},{8, 10}} @@ -380,7 +376,6 @@ loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions) 'Close the document. loadedDocument.Close(True) -{% endraw %} {% endhighlight %} {% endtabs %} @@ -395,34 +390,32 @@ The Syncfusion® PDF library enables the splitting of PDF document {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Import-tagged-structure-when-splitting-PDF-documents/.NET/Import-tagged-structure-when-splitting-PDF-documents/Program.cs" %} -{% raw %} -//Load an existing PDF file. -PdfLoadedDocument loadDocument = new PdfLoadedDocument(new FileStream("Input.pdf", FileMode.Open)); -//Subscribe to the document split event. -loadDocument.DocumentSplitEvent += LoadDocument_DocumentSplitEvent; -void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args) -{ - //Save the resulting document. - FileStream outputStream = new FileStream(Guid.NewGuid().ToString() + ".pdf", FileMode.CreateNew); - args.PdfDocumentData.CopyTo(outputStream); - outputStream.Close(); -} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + +//Create the values. +int[,] values = new int[,] { { 0, 1 }, { 1, 2 } }; +//Load the PDF document. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +//Set an output file pattern. +const string destinationFilePattern = "Output{0}.pdf"; //Create the split options object. PdfSplitOptions splitOptions = new PdfSplitOptions(); //Enable the Split tags property. splitOptions.SplitTags = true; //Split the document by ranges. -loadDocument.SplitByRanges(new int[,] { { 0, 1 }, { 1, 2 } }, splitOptions); +loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions); //Close the document. -loadDocument.Close(true); +loadedDocument.Close(true); -{% endraw %} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -{% raw %} + +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Create the values. int[,] values = new int[,] { { 0, 1 }, { 1, 2 } }; @@ -440,11 +433,12 @@ loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions); //Close the document. loadedDocument.Close(true); -{% endraw %} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -{% raw %} + +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing 'Create the values. Dim values As Integer(,) = New Integer(,) {{0, 1},{1, 2}} @@ -462,7 +456,6 @@ loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions) 'Close the document. loadedDocument.Close(True) -{% endraw %} {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md index df8cfc11b..d334e74e6 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md @@ -21,6 +21,10 @@ You can add a popup annotation to the page using [PdfPopupAnnotation](https://he {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-popup-annotation-to-the-PDF-document/.NET/Add-a-popup-annotation-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page . @@ -38,9 +42,8 @@ popupAnnotation.Icon = PdfPopupIcon.NewParagraph; //Adds this annotation to the created page. page.Annotations.Add(popupAnnotation); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -48,6 +51,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -73,6 +80,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Creates a new PDF document. Dim document As New PdfDocument() 'Creates a new page @@ -105,9 +116,12 @@ To add [PdfPopupAnnotation](https://help.syncfusion.com/cr/document-processing/S {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-popup-annotation-to-an-existing-PDF-document/.NET/Add-a-popup-annotation-to-an-existing-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Creates a rectangle RectangleF rectangle = new RectangleF(10, 40, 30, 30); @@ -121,9 +135,8 @@ popupAnnotation.Icon = PdfPopupIcon.NewParagraph; //Adds the annotation to loaded page document.Pages[0].Annotations.Add(popupAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -131,6 +144,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfLoadedDocument document = new PdfLoadedDocument("input.pdf"); //Creates a rectangle @@ -154,6 +171,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Creates a new PDF document. Dim document As New PdfLoadedDocument("input.pdf") 'Creates a rectangle. @@ -188,14 +209,17 @@ You can add a 3D annotation in PDF document using [Pdf3DAnnotation](https://help {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-3D-annotation-in-PDF-document/.NET/Add-a-3D-annotation-in-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page PdfPage page = document.Pages.Add(); -FileStream inputStream = new FileStream("3DAnnotation.U3D", FileMode.Open, FileAccess.Read); //Creates a new pdf 3d annotation. -Pdf3DAnnotation pdf3dAnnotation = new Pdf3DAnnotation(new RectangleF(10, 50, 300, 150), inputStream); +Pdf3DAnnotation pdf3dAnnotation = new Pdf3DAnnotation(new RectangleF(10, 50, 300, 150), "3DAnnotation.U3D"); //Handles the activation of the 3d annotation Pdf3DActivation activation = new Pdf3DActivation(); activation.ActivationMode = Pdf3DActivationMode.ExplicitActivation; @@ -204,9 +228,8 @@ pdf3dAnnotation.Activation = activation; //Adds annotation to page page.Annotations.Add(pdf3dAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -214,6 +237,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -237,6 +264,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Creates a new PDF document. Dim document As New PdfDocument() 'Creates a new page @@ -268,22 +299,24 @@ You can add the JavaScript script to the 3D annotation using the [OnInstantiate] {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-the-JavaScript-script-to-the-3D-annotation-in-a-PDF/.NET/Add-the-JavaScript-script-to-the-3D-annotation-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page PdfPage page = document.Pages.Add(); -FileStream inputStream = new FileStream("3DAnnotation.U3D", FileMode.Open, FileAccess.Read); //Creates a new PDF 3D annotation -Pdf3DAnnotation pdf3dAnnotation = new Pdf3DAnnotation(new RectangleF(10, 50, 300, 150), inputStream); +Pdf3DAnnotation pdf3dAnnotation = new Pdf3DAnnotation(new RectangleF(10, 50, 300, 150), "3DAnnotation.U3D"); //Assign JavaScript script pdf3dAnnotation.OnInstantiate = "host.getURL(\"http://www.google.com\")"; //Adds annotation to page page.Annotations.Add(pdf3dAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -291,6 +324,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -312,6 +349,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Creates a new PDF document Dim document As New PdfDocument() 'Creates a new page @@ -349,6 +390,10 @@ The following code example explains how to add a file link annotation in PDF. {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -369,6 +414,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Creates a new PDF document Dim document As New PdfDocument() 'Creates a new page @@ -406,9 +455,14 @@ The following code examples explain how to add a rich media annotation in a PDF {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-rich-media-annotation-to-PDF-document/.NET/Add-rich-media-annotation-to-PDF-document/Program.cs" %} -//Load the PDF document. -FileStream inputStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream); +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + +//Load the PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the page. PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -426,9 +480,8 @@ richMediaAnnotation.Appearance.Normal.Graphics.DrawString("Click here to play vi //Add the annotation to the page. lpage.Annotations.Add(richMediaAnnotation); -//Save the document into the stream. -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document. loadedDocument.Close(true); @@ -436,6 +489,12 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Get the page. @@ -462,6 +521,12 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + 'Load the existing PDF document. Dim loadedDocument As New PdfLoadedDocument("input.pdf") 'Get the page. @@ -497,6 +562,11 @@ The following code example explains how to add a free text annotation in the PDF {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-free-text-annotation-in-the-PDF-document/.NET/Add-a-free-text-annotation-in-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new pdf document PdfDocument document = new PdfDocument(); //Creates a new page @@ -520,9 +590,8 @@ freeText.CalloutLines = points; //Adds the annotation to page page.Annotations.Add(freeText); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -530,6 +599,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new pdf document PdfDocument document = new PdfDocument(); //Creates a new page @@ -561,6 +635,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new pdf document Dim document As New PdfDocument() 'Creates a new page @@ -602,6 +681,11 @@ Line annotation displays a single straight line on the page. When you open it, i {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-line-annotation-to-the-PDF-document/.NET/Add-line-annotation-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -633,9 +717,8 @@ lineAnnotation.CaptionType = PdfLineCaptionType.Inline; //Adds this annotation to a new page. page.Annotations.Add(lineAnnotation); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -643,6 +726,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -682,6 +770,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document. Dim document As New PdfDocument() 'Creates a new page @@ -734,6 +827,11 @@ When opened, it displays a pop-up window containing the text of the associated n {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-rubberstamp-annotation-to-the-PDF-document/.NET/Add-rubberstamp-annotation-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -747,9 +845,8 @@ rubberStampAnnotation.Text = "Text Properties Rubber Stamp Annotation"; //Adds annotation to the page page.Annotations.Add(rubberStampAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -757,6 +854,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -778,6 +880,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document. Dim document As New PdfDocument() 'Creates a new page @@ -812,6 +919,11 @@ When you open it, it displays a pop-up window containing text of the associated {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-ink-annotation-to-the-PDF-document/.NET/Add-ink-annotation-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -825,9 +937,8 @@ inkAnnotation.Color = new PdfColor(Color.Red); //Adds annotation to the page page.Annotations.Add(inkAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -835,6 +946,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -856,6 +972,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document. Dim document As New PdfDocument() 'Creates a new page @@ -885,9 +1006,13 @@ You can get ink list points from the [PdfLoadedInkAnnotation](https://help.syncf {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Get-the-ink-list-points-from-the-existing-PDF-document/.NET/Get-the-ink-list-points-from-the-existing-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Load the PDF document -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Gets the first page from the document PdfLoadedPage page = lDoc.Pages[0] as PdfLoadedPage; //Gets the annotation collection @@ -898,10 +1023,8 @@ PdfLoadedInkAnnotation inkAnnotation = annotations[0] as PdfLoadedInkAnnotation; //Gets the ink points collection List> points = inkAnnotation.InkPointsCollection; -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the document as stream -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Close the document lDoc.Close(true); @@ -909,6 +1032,11 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Gets the first page from the document @@ -930,6 +1058,11 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Loads the document Dim lDoc As New PdfLoadedDocument("Input.pdf") 'Gets the first page from the document @@ -964,6 +1097,11 @@ It typically does not appear alone, but is associated with markup annotation, it {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-popup-annotation-to-the-PDF-document/.NET/Add-a-popup-annotation-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create new PDF document PdfDocument document = new PdfDocument(); //Create a new PDF page @@ -981,9 +1119,8 @@ popupAnnotation.Icon = PdfPopupIcon.NewParagraph; //Adds this annotation to a new page. page.Annotations.Add(popupAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -991,6 +1128,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create new PDF document. PdfDocument document = new PdfDocument(); //Create a new PDF page. @@ -1016,6 +1158,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document. Dim document As New PdfDocument() 'Creates a new page @@ -1051,6 +1198,11 @@ File attachment annotation contains reference to a file that typically is embedd {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-file-attachment-annotation-in-a-PDF-document/.NET/Add-file-attachment-annotation-in-a-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF Document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -1067,9 +1219,8 @@ attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin; //Adds this annotation to a new page. page.Annotations.Add(attachmentAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -1077,6 +1228,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF Document. PdfDocument document = new PdfDocument(); //Creates a new page @@ -1099,6 +1255,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF Document. Dim document As New PdfDocument() 'Creates a new page @@ -1131,6 +1292,11 @@ The following code example explains how to add a sound annotation in a PDF docum {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-sound-annotation-in-a-PDF-document/.NET/Add-a-sound-annotation-in-a-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -1150,9 +1316,8 @@ soundAnnotation.Icon = PdfSoundIcon.Speaker; //Adds this annotation to a new page. page.Annotations.Add(soundAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -1160,6 +1325,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -1185,6 +1355,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document Dim document As New PdfDocument() 'Creates a new page @@ -1221,6 +1396,11 @@ The following code example explains how to add URI annotation in a PDF document {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-URI-annotation-in-a-PDF-document/.NET/Add-URI-annotation-in-a-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -1235,9 +1415,8 @@ uriAnnotation.Text = "Uri Annotation"; //Adds this annotation to a new page page.Annotations.Add(uriAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -1245,6 +1424,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -1267,6 +1451,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document Dim document As New PdfDocument() 'Creates a new page @@ -1299,6 +1488,11 @@ This annotation is used to navigate to a specific destination within the documen {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-document-link-annotation-in-PDF-document/.NET/Add-a-document-link-annotation-in-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -1320,9 +1514,8 @@ documentLinkAnnotation.Destination.Zoom = 5; //Adds this annotation to a new page. page.Annotations.Add(documentLinkAnnotation); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -1330,6 +1523,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -1359,6 +1557,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document Dim document As New PdfDocument() 'Creates a new page @@ -1397,6 +1600,11 @@ The essential® PDF supports removing or redacting the sensitive t {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Removing-the-sensitive-text-and-images-from-PDF-document/.NET/Removing-the-sensitive-text-and-images-from-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page. @@ -1424,9 +1632,8 @@ annot.SetAppearance(true); //Add the annotation to the page. page.Annotations.Add(annot); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1434,6 +1641,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page. @@ -1471,6 +1683,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument() 'Create a new page. @@ -1519,9 +1736,13 @@ The following code example explains how to add a watermark annotation in the PDF {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-watermark-annotation-in-the-PDF-document/.NET/Add-watermark-annotation-in-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the page PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -1534,9 +1755,8 @@ watermark.Appearance.Normal.Graphics.DrawString("Watermark Text", new PdfStandar //Adds the annotation to page lpage.Annotations.Add(watermark); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document loadedDocument.Close(true); @@ -1544,6 +1764,11 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Load the existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Get the page @@ -1566,6 +1791,11 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") 'Get the page @@ -1597,6 +1827,11 @@ You can highlight the Markup Text using the [PdfTextMarkupAnnotationType](https: {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Highlight-text-in-the-newly-created-PDF-document/.NET/Highlight-text-in-the-newly-created-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page. @@ -1619,8 +1854,8 @@ markupAnnotation.TextMarkupAnnotationType = PdfTextMarkupAnnotationType.Highligh //Add this annotation to a new page. page.Annotations.Add(markupAnnotation); -//Save the document to disk. -Save(document, "Output.pdf"); +//Save the document +document.Save("Output.pdf"); //close the document. document.Close(true); @@ -1628,6 +1863,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page. @@ -1659,6 +1899,12 @@ document.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document. Dim document As New PdfDocument() 'Create a new page. @@ -1703,6 +1949,11 @@ The following code sample explains how to add cloud border styled rectangle anno {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-cloud-border-styled-rectangle-annotation-in-the-PDF/.NET/Add-cloud-border-styled-rectangle-annotation-in-the-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page @@ -1727,9 +1978,8 @@ annotation.BorderEffect = bordereffect; // Adds the annotation to the page. page.Annotations.Add(annotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -1737,6 +1987,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument (); //Create a new page @@ -1770,6 +2025,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument() 'Create a new page. @@ -1812,6 +2072,11 @@ The following code sample explains how to add cloud border styled polygon annota {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-cloud-border-styled-polygon-annotation-in-the-PDF/.NET/Add-a-cloud-border-styled-polygon-annotation-in-the-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page @@ -1838,9 +2103,8 @@ annotation.BorderEffect = bordereffect; //Add the annotation to the page. page.Annotations.Add(annotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -1848,6 +2112,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page @@ -1883,6 +2152,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Create a New PDF document. Dim document As PdfDocument = New PdfDocument() 'Create a new page. @@ -1927,6 +2201,11 @@ Cloud border style can be added to the [PdfCircleAnnotation](https://help.syncfu {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/refs/heads/master/Annotation/Add-cloud-border-styled-circle-annotation-in-the-PDF/.NET/Add-cloud-border-styled-circle-annotation-in-the-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Add a new page @@ -1951,9 +2230,8 @@ annotation.BorderEffect = bordereffect; annotation.SetAppearance(true); //Adds the annotation to the page page.Annotations.Add(annotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -1961,6 +2239,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Add a new page @@ -1994,6 +2277,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document Dim document As PdfDocument = New PdfDocument() 'Add a new page @@ -2036,6 +2324,11 @@ Cloud border style can be added to the [PdfEllipseAnnotation](https://help.syncf {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/refs/heads/master/Annotation/Add-cloud-border-styled-ellipse-annotation-in-the-PDF/.NET/Add-cloud-border-styled-ellipse-annotation-in-the-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Add a new page @@ -2060,9 +2353,8 @@ annotation.BorderEffect = bordereffect; annotation.SetAppearance(true); // Adds the annotation to the page. page.Annotations.Add(annotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -2070,6 +2362,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Add a new page @@ -2103,6 +2400,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document Dim document As PdfDocument = New PdfDocument() 'Add a new page. @@ -2153,6 +2455,11 @@ The line measurement annotation is displayed as the straight line in the page. T {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-line-measurement-annotation-to-the-PDF-document/.NET/Add-a-line-measurement-annotation-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -2177,11 +2484,8 @@ lineMeasureAnnotation.Font = font; lineMeasureAnnotation.Color = new PdfColor(Syncfusion.Drawing.Color.Red); //Adds the line measurement annotation to a new page page.Annotations.Add(lineMeasureAnnotation); -MemoryStream stream = new MemoryStream(); - -//Save the PDF document to stream -document.Save(stream); -stream.Position=0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -2189,6 +2493,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document. PdfDocument document= new PdfDocument(); //Creates a new page. @@ -2223,6 +2532,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + //Creates a new PDF document Dim document As PdfDocument = New PdfDocument //Creates a new page @@ -2269,6 +2583,11 @@ The square measurement annotation is displayed as square shape in the page. The {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-square-measurement-annotation-to-PDF-document/.NET/Add-a-square-measurement-annotation-to-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -2288,10 +2607,8 @@ squareMeasureAnnotation.Unit = PdfMeasurementUnit.Centimeter; //Adds the square measurement annotation to a page page.Annotations.Add(squareMeasureAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position=0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -2299,6 +2616,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document= new PdfDocument(); //Creates a new page @@ -2327,6 +2649,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document Dim document As New PdfDocument() 'Creates a new page @@ -2367,6 +2694,11 @@ The circle measurement annotation is displayed as circle shape in the page. The {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-circle-measurement-annotation-to-the-PDF-document/.NET/Add-a-circle-measurement-annotation-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -2388,9 +2720,8 @@ circleMeasureAnnotation.MeasurementType = PdfCircleMeasurementType.Diameter; //Adds the circle measurement annotation to a page page.Annotations.Add(circleMeasureAnnotation); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -2398,6 +2729,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -2428,6 +2764,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document Dim document As New PdfDocument() 'Creates a new page @@ -2476,6 +2817,11 @@ The angle measurement annotation calculates the angle between three points and d {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -2499,6 +2845,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document Dim document As New PdfDocument() 'Creates a new page @@ -2531,9 +2882,14 @@ Essential® PDF allows you to modify the annotation of existing do {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Modifying-annotation-of-existing-PDF-document/.NET/Modifying-annotation-of-existing-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("inputAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Gets the first page from the document PdfLoadedPage page = lDoc.Pages[0] as PdfLoadedPage; //Gets the annotation collection @@ -2548,9 +2904,8 @@ popUp.Text = "Modified annotation"; // Update the appearance so the new content is visible popUp.SetAppearance(true); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document lDoc.Close(true); @@ -2558,6 +2913,12 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("inputAnnotation.pdf"); //Gets the first page from the document @@ -2582,6 +2943,12 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + 'Loads the document Dim lDoc As New PdfLoadedDocument("inputAnnotation.pdf") 'Gets the first page from the document @@ -2619,9 +2986,14 @@ The following code sample explains this. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Modify-the-redaction-annotation-in-PDF-document/.NET/Modify-the-redaction-annotation-in-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open,FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); foreach (PdfAnnotation annot in loadedDocument.Pages[0].Annotations) { //Check for the Redaction annotation @@ -2648,9 +3020,8 @@ redactAnnot.Flatten = true; } loadedDocument.Redact(); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document loadedDocument.Close(true); @@ -2658,6 +3029,12 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf"); //Get the pages @@ -2694,6 +3071,12 @@ ldoc.Close(); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + 'Load the existing PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("output.pdf") 'Get the pages @@ -2744,22 +3127,25 @@ The following code example demonstrates how to retrieve the annotation type from {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Get-annotation-type-from-pdf/.NET/Get-annotation-type-from-pdf/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document using a file stream -using (FileStream inputStream = new FileStream(@"Data/Input.pdf", FileMode.Open, FileAccess.Read)) +using (PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf")) { - using (PdfLoadedDocument document = new PdfLoadedDocument(inputStream)) + //Get the pages of the PDF file + for (int i = 0; i < document.PageCount; i++) { - //Get the pages of the PDF file - for (int i = 0; i < document.PageCount; i++) + Console.WriteLine("Page Number: " + i); + PdfLoadedPage page = document.Pages[i] as PdfLoadedPage; + + //Get the annotation type. + foreach (PdfLoadedAnnotation annotation in page.Annotations) { - Console.WriteLine("Page Number: " + i); - PdfLoadedPage page = document.Pages[i] as PdfLoadedPage; - - //Get the annotation type. - foreach (PdfLoadedAnnotation annotation in page.Annotations) - { - Console.WriteLine("Annotation Type: " + annotation.Type.ToString()); - } + Console.WriteLine("Annotation Type: " + annotation.Type.ToString()); } } } @@ -2767,28 +3153,40 @@ using (FileStream inputStream = new FileStream(@"Data/Input.pdf", FileMode.Open, {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - - //Load the PDF document - using (PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf")) + +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + +// Load the PDF document using a file stream +using (PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf")) +{ + //Get the pages of the PDF file + for (int i = 0; i < document.PageCount; i++) { - //Get the pages of the PDF file - for (int i = 0; i < document.PageCount; i++) + Console.WriteLine("Page Number: " + i); + PdfLoadedPage page = document.Pages[i] as PdfLoadedPage; + + //Get the annotation type. + foreach (PdfLoadedAnnotation annotation in page.Annotations) { - Console.WriteLine("Page Number: " + i); - PdfLoadedPage page = document.Pages[i] as PdfLoadedPage; - - //Get the annotation type. - foreach (PdfLoadedAnnotation annotation in page.Annotations) - { - Console.WriteLine("Annotation Type: " + annotation.Type.ToString()); - } + Console.WriteLine("Annotation Type: " + annotation.Type.ToString()); } } +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + Using document As New PdfLoadedDocument("Input.pdf") ' Iterate through the pages of the PDF file For i As Integer = 0 To document.Pages.Count - 1 @@ -2819,46 +3217,62 @@ The [CreationDate](https://help.syncfusion.com/cr/document-processing/Syncfusion {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Get-annotation-creation-date-from-PDF/.NET/Get-annotation-creation-date-from-pdf/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document -using (FileStream inputStream = new FileStream(@"Data/Input.pdf", FileMode.Open, FileAccess.Read)) +using (PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf")) { - using (PdfLoadedDocument document = new PdfLoadedDocument(inputStream)) - { - //Get the first page from the document - PdfLoadedPage firstPage = document.Pages[0] as PdfLoadedPage; + //Get the first page from the document + PdfLoadedPage firstPage = document.Pages[0] as PdfLoadedPage; - //Get the annotation on that page - PdfLoadedAnnotation annotation = firstPage.Annotations[0] as PdfLoadedAnnotation; + //Get the annotation on that page + PdfLoadedAnnotation annotation = firstPage.Annotations[0] as PdfLoadedAnnotation; - //Get the annotation creation date. - DateTime creationDate = annotation.CreationDate; + //Get the annotation creation date. + DateTime creationDate = annotation.CreationDate; - Console.WriteLine("Annotation Creation Date: " + creationDate); - } + Console.WriteLine("Annotation Creation Date: " + creationDate); } {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - using (PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf")) - { - //Get the first page from the document - PdfLoadedPage firstPage = document.Pages[0] as PdfLoadedPage; +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; - //Get the annotation on that page - PdfLoadedAnnotation annotation = firstPage.Annotations[0] as PdfLoadedAnnotation; +// Load the PDF document +using (PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf")) +{ + //Get the first page from the document + PdfLoadedPage firstPage = document.Pages[0] as PdfLoadedPage; - //Get the annotation creation date. - DateTime creationDate = annotation.CreationDate; + //Get the annotation on that page + PdfLoadedAnnotation annotation = firstPage.Annotations[0] as PdfLoadedAnnotation; - Console.WriteLine("Annotation Creation Date: " + creationDate); - } + //Get the annotation creation date. + DateTime creationDate = annotation.CreationDate; + + Console.WriteLine("Annotation Creation Date: " + creationDate); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + ' Load the PDF document Using document As New PdfLoadedDocument("Input.pdf") ' Get the first page from the document @@ -2896,9 +3310,14 @@ Refer to the code snippet below to retrieve a custom value from an annotation us {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} -// Load the PDF document using a file stream -FileStream docStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + +// Load the PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); // Get the first page of the document PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage; @@ -2933,6 +3352,12 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document using a file stream PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); @@ -2969,9 +3394,14 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -' Load the PDF document using a file stream -Dim docStream As New FileStream("Input.pdf", FileMode.Open, FileAccess.Read) -Dim loadedDocument As New PdfLoadedDocument(docStream) +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + +' Load the PDF document +Dim loadedDocument As New PdfLoadedDocument("Input.pdf") ' Get the first page of the document Dim page As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage) @@ -3013,9 +3443,11 @@ You can remove the annotation from the annotation collection, represented by the {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Removing-annotations-from-an-existing-PDF-document/.NET/Removing-annotations-from-an-existing-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("inputAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Gets the first page of the document PdfLoadedPage page = lDoc.Pages[0] as PdfLoadedPage; //Gets the annotation collection @@ -3023,9 +3455,8 @@ PdfLoadedAnnotationCollection annotations = page.Annotations; //Removes the first annotation annotations.RemoveAt(0); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document lDoc.Close(true); @@ -3033,6 +3464,9 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("inputAnnotation.pdf"); //Gets the first page of the document @@ -3049,6 +3483,9 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Loads the document Dim lDoc As New PdfLoadedDocument("inputAnnotation.pdf") 'Gets the first page from the document @@ -3076,9 +3513,11 @@ This can be achieved by enabling the [Flatten](https://help.syncfusion.com/cr/do {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Flatten-the-annotations-in-an-existing-PDF-document/.NET/Flatten-the-annotations-in-an-existing-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get all the pages foreach (PdfLoadedPage loadedPage in loadedDocument.Pages) { @@ -3086,9 +3525,8 @@ foreach (PdfLoadedPage loadedPage in loadedDocument.Pages) loadedPage.Annotations.Flatten = true; } -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Closes the document loadedDocument.Close(true); @@ -3096,6 +3534,9 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Get all the pages. @@ -3113,6 +3554,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") 'Get all the pages @@ -3136,9 +3580,11 @@ To flatten the specific annotation in the PDF document, use the below code examp {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Flatten-the-specific-annotaiton-in-the-PDF-document/.NET/Flatten-the-specific-annotaiton-in-the-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get all the pages foreach (PdfLoadedPage loadedPage in loadedDocument.Pages) { @@ -3154,9 +3600,8 @@ foreach (PdfLoadedPage loadedPage in loadedDocument.Pages) } } -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Closes the document loadedDocument.Close(true); @@ -3164,6 +3609,9 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Get all the pages @@ -3188,6 +3636,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") 'Get all the pages @@ -3217,9 +3668,11 @@ To flatten pop-up annotation [Flatten](https://help.syncfusion.com/cr/document-p {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Flatten-popup-annotation-in-the-PDF-document/.NET/Flatten-popup-annotation-in-the-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("PopupAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get all the pages foreach (PdfLoadedPage loadedPage in loadedDocument.Pages) { @@ -3235,16 +3688,17 @@ foreach (PdfLoadedPage loadedPage in loadedDocument.Pages) } } -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the document as stream -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("PopupAnnotation.pdf"); //Get all the pages @@ -3271,6 +3725,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("PopupAnnotation.pdf") 'Get all the pages @@ -3303,10 +3760,11 @@ To flatten the redaction annotation in PDF document, use the following code exam {% highlight c# tabtitle="C# [Cross-platform]" %} -//Get stream from an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the annotation from annotation collection. foreach (PdfAnnotation annot in loadedDocument.Pages[0].Annotations) @@ -3323,15 +3781,17 @@ foreach (PdfAnnotation annot in loadedDocument.Pages[0].Annotations) } loadedDocument.Redact(); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document. loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); @@ -3359,6 +3819,9 @@ loadedDocument.Close(); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the existing PDF document. Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/Input.pdf") @@ -3400,16 +3863,17 @@ To flatten the annotation without pop-ups [FlattenAnnotations](https://help.sync {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Flattening-annotations-without-calling-save-method/.NET/Flattening-annotations-without-calling-save-method/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Flatten all the annotations without popups in the document loadedDocument.FlattenAnnotations(); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Closes the document loadedDocument.Close(true); @@ -3417,6 +3881,9 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); @@ -3431,6 +3898,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") @@ -3452,15 +3922,16 @@ To flatten the annotation with pop-ups [FlattenAnnotations](https://help.syncfus {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Flattening-annotations-with-popups-in-PDF/.NET/Flattening-annotations-with-popups-in-PDF/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Flatten all the annotations without popups in the document loadedDocument.FlattenAnnotations(true); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Closes the document loadedDocument.Close(true); @@ -3468,6 +3939,9 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Flatten all the annotations with popups in the document @@ -3480,6 +3954,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") 'Flatten all the annotations without popups in the document @@ -3502,54 +3979,55 @@ To flatten specific types of annotations in a PDF document, use the [FlattenAnno {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Flatten-specific-types-of-annotations/.NET/Flatten-specific-types-of-annotations/Program.cs" %} - // Load the PDF document - using (FileStream docStream = new FileStream(@"input.pdf", FileMode.Open, FileAccess.Read)) +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + +// Load the PDF document +using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) +{ + // Specify the annotation types to flatten + PdfLoadedAnnotationType[] pdfLoadedAnnotationTypes = new PdfLoadedAnnotationType[] { - using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream)) - { - // Specify the annotation types to flatten - PdfLoadedAnnotationType[] pdfLoadedAnnotationTypes = new PdfLoadedAnnotationType[] - { PdfLoadedAnnotationType.PolygonAnnotation - }; + }; - // Flatten the selected annotations - loadedDocument.FlattenAnnotations(pdfLoadedAnnotationTypes); + // Flatten the selected annotations + loadedDocument.FlattenAnnotations(pdfLoadedAnnotationTypes); - // Save the flattened document - using (MemoryStream memoryStream = new MemoryStream()) - { - loadedDocument.Save(memoryStream); - // MemoryStream can be used further as needed - } - } - } + //Save the document + loadedDocument.Save("Output.pdf"); +} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - // Load the PDF document from a file path - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; +// Load the PDF document +using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) +{ // Specify the annotation types to flatten PdfLoadedAnnotationType[] pdfLoadedAnnotationTypes = new PdfLoadedAnnotationType[] { - PdfLoadedAnnotationType.PolygonAnnotation + PdfLoadedAnnotationType.PolygonAnnotation }; // Flatten the selected annotations loadedDocument.FlattenAnnotations(pdfLoadedAnnotationTypes); - // Save the flattened PDF document to a file path - loadedDocument.Save(@"C:\path\to\output.pdf"); - // Close the document instance - loadedDocument.Close(true); + //Save the document + loadedDocument.Save("Output.pdf"); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + ' Load the PDF document from a file path Dim loadedDocument As New PdfLoadedDocument("C:\path\to\input.pdf") @@ -3583,22 +4061,24 @@ FDF stands for Forms Data Format. FDF is a file format for representing annotati {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Importing-annotations-from-FDF-file-to-PDF-document/.NET/Importing-annotations-from-FDF-file-to-PDF-document/Program.cs" %} +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Import annotation data from FDF stream FileStream fdfStream = new FileStream("Annotations.fdf", FileMode.Open, FileAccess.Read); lDoc.ImportAnnotations(fdfStream, AnnotationDataFormat.Fdf) -//Save the document into stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document lDoc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); //Import annotation data from FDF file @@ -3611,6 +4091,8 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing; + 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") 'Import annotation data from FDF file @@ -3633,16 +4115,16 @@ XFDF stands for XML Forms Data Format. XFDF is the XML version of FDF for repres {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Importing-annotations-from-XFDF-file-to-PDF-document/.NET/Importing-annotations-from-XFDF-file-to-PDF-document/Program.cs" %} +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Import annotation data from XFDF stream FileStream xfdfStream = new FileStream("Annotations.xfdf", FileMode.Open, FileAccess.Read); lDoc.ImportAnnotations(xfdfStream, AnnotationDataFormat.XFdf); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document lDoc.Close(true); @@ -3650,6 +4132,8 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); //Import annotation data from XFDF file @@ -3662,6 +4146,8 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing; + 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") 'Import annotation data from XFDF file @@ -3684,16 +4170,16 @@ JSON stands for JavaScript Object Notation. It is a collection of key or value p {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Importing-annotations-from-JSON-file-to-PDF-document/.NET/Importing-annotations-from-JSON-file-to-PDF-document/Program.cs" %} +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Import the annotation data from the JSON stream FileStream jsonStream = new FileStream("Annotations.Json", FileMode.Open, FileAccess.Read); lDoc.ImportAnnotations(jsonStream, AnnotationDataFormat.Json); -//Save the document into the stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document lDoc.Close(true); @@ -3701,6 +4187,8 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); //Import the annotation data from the JSON file @@ -3713,6 +4201,8 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing; + 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") 'Import the annotation data from the JSON file @@ -3738,12 +4228,12 @@ To export annotation data to the FDF file from PDF document, you can use the [Ex {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Exporting-annotation-to-FDF-file-from-PDF-document/.NET/Exporting-annotation-to-FDF-file-from-PDF-document/Program.cs" %} -//Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); -//Export annotation data from FDF stream -Stream fdfStream = new MemoryStream(); -lDoc.ExportAnnotations(fdfStream, AnnotationDataFormat.Fdf) +using Syncfusion.Pdf.Parsing; + +//Loads the document +PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); +//Export annotation data to FDF file +lDoc.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf); //Close the document lDoc.Close(true); @@ -3751,6 +4241,8 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); //Export annotation data to FDF file @@ -3762,6 +4254,8 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing; + 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") 'Export annotation data to FDF file @@ -3783,12 +4277,12 @@ To export annotation data to the XFDF file from PDF document, you can use the [E {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Exporting-annotations-to-XFDF-file-from-PDF-document/.NET/Exporting-annotations-to-XFDF-file-from-PDF-document/Program.cs" %} -//Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); -//Export annotation data from XFDF stream -Stream xfdfStream = new MemoryStream(); -lDoc.ExportAnnotations(xfdfStream, AnnotationDataFormat.XFdf); +using Syncfusion.Pdf.Parsing; + +//Loads the document +PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); +//Export annotation data to XFDF file +lDoc.ExportAnnotations("Annotations.xfdf", AnnotationDataFormat.XFdf); //Close the document lDoc.Close(true); @@ -3796,6 +4290,8 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); //Export annotation data to XFDF file @@ -3807,6 +4303,8 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing; + 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") 'Export annotation data to XFDF file @@ -3828,19 +4326,21 @@ To export annotation data to the JSON file from PDF document, you can use the [E {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Exporting-annotations-to-JSON-file-from-PDF-document/.NET/Exporting-annotations-to-JSON-file-from-PDF-document/Program.cs" %} -//Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); -//Export the annotation data from the JSON stream -Stream jsonStream = new MemoryStream(); -lDoc.ExportAnnotations(jsonStream, AnnotationDataFormat.Json) +using Syncfusion.Pdf.Parsing; + +//Loads the document +PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); +//Export the annotation data to the JSON file +lDoc.ExportAnnotations("Annotations.Json", AnnotationDataFormat.Json); //Close the document -lDoc.Close(true); +lDoc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); //Export the annotation data to the JSON file @@ -3852,6 +4352,8 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing; + 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") 'Export the annotation data to the JSON file @@ -3873,9 +4375,13 @@ To export newly added annotation data from a PDF document to a JSON file, use th {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Exporting-Newly-Added-Annotations-JSON-File/.NET/Exporting-Newly-Added-Annotations-JSON-File/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document from a file stream -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); // Create a PDF free text annotation PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(new RectangleF(10, 0, 50, 50)); @@ -3896,22 +4402,23 @@ freeText.Border = new PdfAnnotationBorder(.5f); // Add the annotation to the first page of the PDF pdfLoadedDocument.Pages[0].Annotations.Add(freeText); -// Create a memory stream to hold the exported annotations in JSON format -Stream jsonStream = new MemoryStream(); -// Export annotations to the JSON format -pdfLoadedDocument.ExportAnnotations(jsonStream, AnnotationDataFormat.Json); +// Export annotations to the JSON format +pdfLoadedDocument.ExportAnnotations("Annotation.json", AnnotationDataFormat.Json); -// Close the loaded PDF document +// Close the loaded PDF document pdfLoadedDocument.Close(true); -// Dispose of the memory stream -jsonStream.Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document from a file stream -PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(“Input.pdf”); +PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); // Create a PDF free text annotation PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(new RectangleF(10, 0, 50, 50)); @@ -3933,7 +4440,7 @@ freeText.Border = new PdfAnnotationBorder(.5f); pdfLoadedDocument.Pages[0].Annotations.Add(freeText); // Export annotations to the JSON format -pdfLoadedDocument.ExportAnnotations(“Annotation.json”, AnnotationDataFormat.Json); +pdfLoadedDocument.ExportAnnotations("Annotation.json", AnnotationDataFormat.Json); // Close the loaded PDF document pdfLoadedDocument.Close(true); @@ -3942,6 +4449,11 @@ pdfLoadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing; + ' Load the PDF document from a file stream Dim pdfLoadedDocument As New PdfLoadedDocument("Input.pdf") ' Create a PDF free text annotation @@ -3984,9 +4496,13 @@ To export newly added annotation data from a PDF document to an FDF (Forms Data {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Exporting-Newly-Added-Annotations-FDF-File/.NET/Exporting-Newly-Added-Annotations-FDF-File/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document from a file stream -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); // Create a PDF free text annotation PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(new RectangleF(10, 0, 50, 50)); @@ -4004,25 +4520,26 @@ freeText.BorderColor = new PdfColor(Color.Red); // Set border thickness freeText.Border = new PdfAnnotationBorder(.5f); -// Add the annotation to the first page of the PDF +// Add the annotation to the first page of the PDF pdfLoadedDocument.Pages[0].Annotations.Add(freeText); -// Create a memory stream to hold the exported annotations in FDF format -Stream fdfStream = new MemoryStream(); -// Export annotations to the FDF format -pdfLoadedDocument.ExportAnnotations(fdfStream, AnnotationDataFormat.Fdf); +// Export annotations to the FDF format +pdfLoadedDocument.ExportAnnotations("Annotation.fdf", AnnotationDataFormat.Fdf); -// Close the loaded PDF document +// Close the loaded PDF document pdfLoadedDocument.Close(true); -// Dispose of the memory stream -fdfStream.Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document from a file stream -PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(“Input.pdf”); +PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); // Create a PDF free text annotation PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(new RectangleF(10, 0, 50, 50)); @@ -4044,7 +4561,7 @@ freeText.Border = new PdfAnnotationBorder(.5f); pdfLoadedDocument.Pages[0].Annotations.Add(freeText); // Export annotations to the FDF format -pdfLoadedDocument.ExportAnnotations(“Annotation.fdf”, AnnotationDataFormat.Fdf); +pdfLoadedDocument.ExportAnnotations("Annotation.fdf", AnnotationDataFormat.Fdf); // Close the loaded PDF document pdfLoadedDocument.Close(true); @@ -4053,6 +4570,11 @@ pdfLoadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing; + ' Load the PDF document from a file stream Dim pdfLoadedDocument As New PdfLoadedDocument("Input.pdf") ' Create a PDF free text annotation @@ -4095,9 +4617,13 @@ To export newly added annotation data from a PDF document to an XFDF (XML Forms {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Exporting-Newly-Added-Annotations-XFDF-File/.NET/Exporting-Newly-Added-Annotations-XFDF-File/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document from a file stream -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); // Create a PDF free text annotation PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(new RectangleF(10, 0, 50, 50)); @@ -4118,22 +4644,23 @@ freeText.Border = new PdfAnnotationBorder(.5f); // Add the annotation to the first page of the PDF pdfLoadedDocument.Pages[0].Annotations.Add(freeText); -// Create a memory stream to hold the exported annotations in JSON format -Stream xfdfStream = new MemoryStream(); -// Export annotations to the XFDF format -pdfLoadedDocument.ExportAnnotations(xfdfStream, AnnotationDataFormat.XFdf); +// Export annotations to the XFDF format +pdfLoadedDocument.ExportAnnotations("Annotation.xfdf", AnnotationDataFormat.XFdf); -// Close the loaded PDF document +// Close the loaded PDF document pdfLoadedDocument.Close(true); -// Dispose of the memory stream -xfdfStream.Dispose(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load the PDF document from a file stream -PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(“Input.pdf”); +PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument("Input.pdf"); // Create a PDF free text annotation PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(new RectangleF(10, 0, 50, 50)); @@ -4155,7 +4682,7 @@ freeText.Border = new PdfAnnotationBorder(.5f); pdfLoadedDocument.Pages[0].Annotations.Add(freeText); // Export annotations to the XFDF format -pdfLoadedDocument.ExportAnnotations(“Annotation.xfdf”, AnnotationDataFormat.XFdf); +pdfLoadedDocument.ExportAnnotations("Annotation.xfdf", AnnotationDataFormat.XFdf); // Close the loaded PDF document pdfLoadedDocument.Close(true); @@ -4165,6 +4692,11 @@ pdfLoadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing; + ' Load the PDF document from a file stream Dim pdfLoadedDocument As New PdfLoadedDocument("Input.pdf") ' Create a PDF free text annotation @@ -4203,7 +4735,7 @@ N> In our PDF library, font resources are embedded into the document during the ## Get and set custom values for PDF annotations -The Syncfusion® PDF library provides robust functionality to manipulate PDF documents, including annotations. This document focuses on using the [GetValues](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Interactive.PdfLoadedAnnotation.html#Syncfusion_Pdf_Interactive_PdfLoadedAnnotation_GetValues_System_String_) and [SetValues](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Interactive.PdfLoadedAnnotation.html#Syncfusion_Pdf_Interactive_PdfLoadedAnnotation_SetValues_System_String_System_String_) methods with PDF annotations to retrieve and set annotation-specific values. +The Syncfusion® PDF library provides robust functionality to manipulate PDF documents, including annotations. This document focuses on using the [GetValues](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Interactive.PdfLoadedAnnotation.html#Syncfusion_Pdf_Interactive_PdfLoadedAnnotation_GetValues_System_String_) and [SetValues](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Interactive.PdfLoadedAnnotation.html#Syncfusion_Pdf_Interactive_PdfLoadedAnnotation_SetValues_System_String_System_String_) methods with PDF annotations to retrieve and set annotation-specific values. The following code example demonstrates how to get values from a PDF annotation. @@ -4211,74 +4743,76 @@ The following code example demonstrates how to get values from a PDF annotation. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Program.cs" %} -// Load the existing PDF document using FileStream -using (FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; + +// Load the PDF document from the input stream +using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) { - // Load the PDF document from the input stream - using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream)) + // Access the first page of the document + PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage; + // Get the collection of annotations from the page + PdfLoadedAnnotationCollection annotations = page.Annotations; + + // Check if at least one annotation exists and it's a popup annotation + if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) { - // Access the first page of the document - PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage; - // Get the collection of annotations from the page - PdfLoadedAnnotationCollection annotations = page.Annotations; + // Get the custom value from the annotation + List customValue = annotation.GetValues("custom"); - // Check if at least one annotation exists and it's a popup annotation - if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) + foreach (string value in customValue) { - // Get the custom value from the annotation - List customValue = annotation.GetValues("custom"); - - foreach (string value in customValue) - { - // Print the custom value to the console - Console.WriteLine("Custom value from annotation: " + value); - } + // Print the custom value to the console + Console.WriteLine("Custom value from annotation: " + value); } - // Close the document and release resources - loadedDocument.Close(true); } + // Close the document and release resources + loadedDocument.Close(true); } {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -// Load the existing PDF document using FileStream -using (FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read)) +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; + +// Load the PDF document from the input stream +using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) { - // Load the PDF document from the input stream - using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream)) + // Access the first page of the document + PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage; + // Get the collection of annotations from the page + PdfLoadedAnnotationCollection annotations = page.Annotations; + + // Check if at least one annotation exists and it's a popup annotation + if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) { - // Access the first page of the document - PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage; - // Get the collection of annotations from the page - PdfLoadedAnnotationCollection annotations = page.Annotations; + // Get the custom value from the annotation + List customValue = annotation.GetValues("custom"); - // Check if at least one annotation exists and it's a popup annotation - if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) + foreach (string value in customValue) { - // Get the custom value from the annotation - List customValue = annotation.GetValues("custom"); - - foreach (string value in customValue) - { - // Print the custom value to the console - Console.WriteLine("Custom value from annotation: " + value); - } + // Print the custom value to the console + Console.WriteLine("Custom value from annotation: " + value); } - // Close the document and release resources - loadedDocument.Close(true); } + // Close the document and release resources + loadedDocument.Close(true); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -' Load the existing PDF document using FileStream -Using inputStream As New FileStream("Input.pdf", FileMode.Open, FileAccess.Read) +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + ' Load the PDF document from the input stream -Using loadedDocument As New PdfLoadedDocument(inputStream) +Using loadedDocument As New PdfLoadedDocument("Input.pdf") ' Access the first page of the document Dim page As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage) @@ -4301,7 +4835,6 @@ End If ' Close the document and release resources loadedDocument.Close(True) End Using -End Using {% endhighlight %} @@ -4314,94 +4847,92 @@ The following code example demonstrates how to set values from a PDF annotation. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Program.cs" %} -// Load the existing PDF document using FileStream -using (FileStream inputStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read)) -{ - // Load the PDF document from the input stream - using (PdfLoadedDocument ldoc = new PdfLoadedDocument(inputStream)) - { - // Access the first page of the document - PdfLoadedPage page = ldoc.Pages[0] as PdfLoadedPage; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; - // Get the collection of annotations from the page - PdfLoadedAnnotationCollection annotations = page.Annotations; +// Load the PDF document from the input stream +using (PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf")) +{ + // Access the first page of the document + PdfLoadedPage page = ldoc.Pages[0] as PdfLoadedPage; - // Check if at least one annotation exists and it's a popup annotation - if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) - { - // Set a custom key-value pair in the annotation's metadata - annotation.SetValues("custom", "This is the custom data for the annotation"); - } + // Get the collection of annotations from the page + PdfLoadedAnnotationCollection annotations = page.Annotations; - // Save the modified document using a new FileStream - using (FileStream outputStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.Write)) - { - // Save changes to a new PDF file - ldoc.Save(outputStream); - } - // Close the document and release resources - ldoc.Close(true); + // Check if at least one annotation exists and it's a popup annotation + if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) + { + // Set a custom key-value pair in the annotation's metadata + annotation.SetValues("custom", "This is the custom data for the annotation"); } + // Save changes to a new PDF file + ldoc.Save("Output.pdf"); + + // Close the document and release resources + ldoc.Close(true); } {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -// Load the existing PDF document using FileStream -using (FileStream inputStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read)) +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; + +// Load the PDF document from the input stream +using (PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf")) { - // Load the PDF document from the input stream - using (PdfLoadedDocument ldoc = new PdfLoadedDocument(inputStream)) - { - // Access the first page of the document - PdfLoadedPage page = ldoc.Pages[0] as PdfLoadedPage; + // Access the first page of the document + PdfLoadedPage page = ldoc.Pages[0] as PdfLoadedPage; - // Get the collection of annotations from the page - PdfLoadedAnnotationCollection annotations = page.Annotations; + // Get the collection of annotations from the page + PdfLoadedAnnotationCollection annotations = page.Annotations; - // Check if at least one annotation exists and it's a popup annotation - if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) - { - // Set a custom key-value pair in the annotation's metadata - annotation.SetValues("custom", "This is the custom data for the annotation"); - } - // Save changes to a new PDF file - ldoc.Save("Output.pdf"); - - // Close the document and release resources - ldoc.Close(true); + // Check if at least one annotation exists and it's a popup annotation + if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) + { + // Set a custom key-value pair in the annotation's metadata + annotation.SetValues("custom", "This is the custom data for the annotation"); } + // Save changes to a new PDF file + ldoc.Save("Output.pdf"); + + // Close the document and release resources + ldoc.Close(true); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} - ' Load the existing PDF document using FileStream - Using inputStream As New FileStream("Input.pdf", FileMode.Open, FileAccess.Read) - ' Load the PDF document from the input stream - Using ldoc As New PdfLoadedDocument(inputStream) - ' Access the first page of the document - Dim page As PdfLoadedPage = TryCast(ldoc.Pages(0), PdfLoadedPage) +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive - ' Get the collection of annotations from the page - Dim annotations As PdfLoadedAnnotationCollection = page.Annotations +Load the PDF document from the file +Using ldoc As New PdfLoadedDocument("Input.pdf") - ' Check if at least one annotation exists and it's a popup annotation - If annotations.Count > 0 AndAlso TypeOf annotations(0) Is PdfLoadedPopupAnnotation Then - Dim annotation As PdfLoadedPopupAnnotation = TryCast(annotations(0), PdfLoadedPopupAnnotation) +' Access the first page of the document +Dim page As PdfLoadedPage = TryCast(ldoc.Pages(0), PdfLoadedPage) - ' Set a custom key-value pair in the annotation's metadata - annotation.SetValues("custom", "This is the custom data for the annotation") - End If +' Get the collection of annotations from the page +Dim annotations As PdfLoadedAnnotationCollection = page.Annotations - ' Save the modified document to a new file - ldoc.Save("Output.pdf") +' Check if at least one annotation exists and it's a popup annotation +If annotations.Count > 0 AndAlso TypeOf annotations(0) Is PdfLoadedPopupAnnotation Then + Dim annotation As PdfLoadedPopupAnnotation = CType(annotations(0), PdfLoadedPopupAnnotation) + + ' Set a custom key-value pair in the annotation's metadata + annotation.SetValues("custom", "This is the custom data for the annotation") +End If + +' Save changes to a new PDF file +ldoc.Save("Output.pdf") - ' Close the document and release resources - ldoc.Close(True) - End Using - End Using +' Close the document and release resources +ldoc.Close(True) +End Using {% endhighlight %} @@ -4411,7 +4942,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Setting transparency for annotations -The Syncfusion® PDF Library enables you to adjust the transparency of annotations using the [Opacity](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Interactive.PdfAnnotation.html#Syncfusion_Pdf_Interactive_PdfAnnotation_Opacity) property. This property defines the annotation's transparency level, where a value of 0 makes it fully transparent, and 1 makes it completely opaque. +The Syncfusion® PDF Library enables you to adjust the transparency of annotations using the [Opacity](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Interactive.PdfAnnotation.html#Syncfusion_Pdf_Interactive_PdfAnnotation_Opacity) property. This property defines the annotation's transparency level, where a value of 0 makes it fully transparent, and 1 makes it completely opaque. The following code example how to add transparency to the PDF annotation. @@ -4419,6 +4950,11 @@ The following code example how to add transparency to the PDF annotation. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Adding-transparency-for-annotations/.NET/Adding-transparency-for-annotations/Program.cs" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + // Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a new page. @@ -4438,12 +4974,9 @@ textAnnotation.Opacity = 0.5F; textAnnotation.AnnotationIntent = PdfAnnotationIntent.FreeTextCallout; //Add this annotation to the PDF page. page.Annotations.Add(textAnnotation); - //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 document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -4451,6 +4984,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf; +using System.Drawing; + // Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a new page. @@ -4479,6 +5017,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + ' Create a new PDF document. Dim document As New PdfDocument() ' Add a new page. @@ -4523,6 +5066,10 @@ The following code example explains how to add comments to the PDF annotation. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-comments-to-the-PDF-annotation/.NET/Add-comments-to-the-PDF-annotation/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Create a new page @@ -4551,9 +5098,8 @@ rectangleAnnotation.Comments.Add(comment); //Add the annotation to the PDF page page.Annotations.Add(rectangleAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -4561,6 +5107,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Create a new page @@ -4598,6 +5148,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new PDF document Dim document As PdfDocument = New PdfDocument 'Create a new page @@ -4643,9 +5197,12 @@ To add comments [PdfPopupAnnotation](https://help.syncfusion.com/cr/document-pro {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-comments-to-the-existing-PDF-annotation/.NET/Add-comments-to-the-existing-PDF-annotation/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Load the PDF document -FileStream docStream = new FileStream("inputAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page PdfLoadedPage lpage = lDoc.Pages[0] as PdfLoadedPage; //Get the existing annotations @@ -4666,9 +5223,8 @@ comment.Subject = "Annotation Comments"; //Add the comments to the annotation loadedRectangleAnnotation.Comments.Add(comment); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document lDoc.Close(true); @@ -4676,6 +5232,10 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Load the PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page @@ -4707,6 +5267,10 @@ ldoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Get the existing PDF page @@ -4789,6 +5353,10 @@ You can add a review status in a newly created PDF annotation using [PdfAnnotati {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-a-review-status-in-a-newly-created-PDF-annotation/.NET/Add-a-review-status-in-a-newly-created-PDF-annotation/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Create a new page @@ -4817,9 +5385,8 @@ rectangleAnnotation.ReviewHistory.Add(review); //Add the annotation to the PDF page page.Annotations.Add(rectangleAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -4827,6 +5394,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Create a new page @@ -4864,6 +5435,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new PDF document Dim document As PdfDocument = New PdfDocument 'Create a new page @@ -4908,9 +5483,12 @@ To add the review status [PdfAnnotationState](https://help.syncfusion.com/cr/do {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-the-review-status-to-the-existing-PDF-annotation/.NET/Add-the-review-status-to-the-existing-PDF-annotation/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Load the PDF document -FileStream docStream = new FileStream("inputAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page PdfLoadedPage lpage = lDoc.Pages[0] as PdfLoadedPage; //Get the existing annotations @@ -4931,9 +5509,8 @@ review.ModifiedDate = DateTime.Now; //Add the review to the annotation loadedRectangleAnnotation.ReviewHistory.Add(review); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document lDoc.Close(true); @@ -4941,6 +5518,10 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Load the PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page @@ -4972,6 +5553,10 @@ ldoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the existing PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Get the existing PDF page @@ -5015,9 +5600,12 @@ The following code example explains how to remove comments using [RemoveAt](http {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Remove-commets-from-the-existing-PDF-annotation/.NET/Remove-commets-from-the-existing-PDF-annotation/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("inputAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page PdfLoadedPage lpage = ldoc.Pages[0] as PdfLoadedPage; //Get the existing annotations @@ -5029,15 +5617,18 @@ PdfLoadedPopupAnnotationCollection commentsCollection = loadedRectangleAnnotatio // Remove comments by index commentsCollection.RemoveAt(0); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -ldoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document ldoc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page @@ -5060,6 +5651,10 @@ ldoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")'Load the PDF page 'Get the existing PDF page @@ -5089,9 +5684,12 @@ To remove review status [RemoveAt](https://help.syncfusion.com/cr/document-proce {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Remove-review-status-to-the-existing-PDF-document/.NET/Remove-review-status-to-the-existing-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("inputAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page PdfLoadedPage lpage = ldoc.Pages[0] as PdfLoadedPage; //Get the existing annotations @@ -5103,9 +5701,8 @@ PdfLoadedPopupAnnotationCollection reviewCollection = loadedRectangleAnnotation. //Remove review status by index reviewCollection.RemoveAt(0); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document ldoc.Close(true); @@ -5113,6 +5710,10 @@ ldoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page @@ -5135,6 +5736,10 @@ ldoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Loaded the PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Get the existing PDF page @@ -5167,9 +5772,12 @@ The following code example explains how to modify comments in the existing PDF a {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Modify-comments-in-the-existing-PDF-annotation/.NET/Modify-comments-in-the-existing-PDF-annotation/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("inputAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Load the PDF document page PdfLoadedPage lpage = ldoc.Pages[0] as PdfLoadedPage; PdfLoadedAnnotationCollection annots = lpage.Annotations; @@ -5182,15 +5790,18 @@ PdfLoadedPopupAnnotation loadedComments = commentsCollection[0]; //Modify the comment Text loadedComments.Text = "This is the modified comments"; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -ldoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document ldoc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page @@ -5215,6 +5826,10 @@ ldoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Load the PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Get the existing PDF page @@ -5246,9 +5861,12 @@ To modify review status [PdfAnnotationState](https://help.syncfusion.com/cr/docu {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Modify-review-status-to-the-existing-PDF-annotation/.NET/Modify-review-status-to-the-existing-PDF-annotation/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("inputAnnotation.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream); +PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page PdfLoadedPage lpage = ldoc.Pages[0] as PdfLoadedPage; //Get the existing annotations @@ -5262,15 +5880,18 @@ PdfLoadedPopupAnnotation loadedReview = reviewCollection[0]; // Modify the review State loadedReview.State = PdfAnnotationState.Rejected; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -lDoc.Save(stream); +//Save the document +lDoc.Save("Output.pdf"); //Closes the document ldoc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page @@ -5295,6 +5916,10 @@ ldoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Loaded the PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Get the existing PDF page @@ -5334,11 +5959,12 @@ You can retrieve the annotation review history from the existing PDF document an {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Retrieve-review-status-from-the-existing-PDF-annotations/.NET/Program.cs" %} -//Get stream from an existing PDF document. -FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page. PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -5369,11 +5995,12 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} -//Get stream from an existing PDF document. -FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page. PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -5403,11 +6030,12 @@ loadedDocument.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Get stream from an existing PDF document. -Dim docStream As New FileStream(Path.GetFullPath("Data/Input.pdf"), FileMode.Open, FileAccess.Read) +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive 'Load the PDF document. -Dim loadedDocument As New PdfLoadedDocument(docStream) +Dim loadedDocument As New PdfLoadedDocument("Input.pdf") 'Get the existing PDF page. Dim loadedPage As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage) @@ -5448,11 +6076,12 @@ The following code example explains how to retrieve the annotation comments from {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Program.cs" %} -//Get stream from the existing PDF document. -FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page. PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -5481,11 +6110,12 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} -//Get stream from the existing PDF document. -FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page. PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -5514,11 +6144,12 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Get stream from the existing PDF document. -Dim docStream As New FileStream(Path.GetFullPath("Data/Input.pdf"), FileMode.Open, FileAccess.Read) +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive 'Load the PDF document. -Dim loadedDocument As New PdfLoadedDocument(docStream) +Dim loadedDocument As New PdfLoadedDocument("Input.pdf") 'Get the existing PDF page. Dim loadedPage As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage) @@ -5560,9 +6191,14 @@ The following code snippet explains how to add custom stamp in an existing PDF d {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Add-custom-stamp-in-an-existing-PDF-document/.NET/Add-custom-stamp-in-an-existing-PDF-document/Program.cs" %} -//Load an existing PDF document -FileStream inputStream = new FileStream("Input.pdf", FileMode.Open); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream); +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + +//Load the PDF document. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the page from loaded PDF document PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -5582,9 +6218,8 @@ rubberStampAnnotation.Text = "Text Properties Rubber Stamp Annotation"; //Add annotation to the page loadedPage.Annotations.Add(rubberStampAnnotation); -//Saving the PDF to the MemoryStream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the instance of PdfLoadedDocument loadedDocument.Close(true); @@ -5620,6 +6255,12 @@ public static PdfPath RoundedRect(RectangleF bounds, int radius) {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load an existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Get the page from loaded PDF document @@ -5678,6 +6319,14 @@ public static PdfPath RoundedRect(RectangleF bounds, int radius) {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + + 'Load an existing PDF document Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Get the page from loaded PDF document @@ -5744,9 +6393,14 @@ You can get the images from the custom rubber stamp annotation appearance using {% highlight c# tabtitle="C# [Cross-platform]" %} -//Load the existing PDF file. -FileStream fileStream = new FileStream("input.pdf", FileMode.Open); -PdfLoadedDocument ldoc = new PdfLoadedDocument(fileStream); +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + +//Load the PDF document. +PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); //Get the existing PDF page. PdfLoadedPage lpage = ldoc.Pages[0] as PdfLoadedPage; //Get the rubber stamp annotation. @@ -5760,6 +6414,12 @@ ldoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf"); //Get the existing PDF page. @@ -5775,6 +6435,13 @@ ldoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + + ' Load an existing document. Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") 'Get the existing PDF page. @@ -5799,6 +6466,11 @@ Refer to the following code example to achieve the same. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Multi-line-text-redaction-using-quad-points/.NET/Multi-line-text-redaction-using-quad-points/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page. @@ -5830,9 +6502,8 @@ annot.RepeatText = true; //Add the annotation to the page. page.Annotations.Add(annot); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -5840,6 +6511,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Create a new page. @@ -5880,6 +6556,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + ' Create a new PDF document. Dim document As New PdfDocument() ' Create a new page. @@ -5931,8 +6612,13 @@ Refer to the following code example to apply the BoundsCollection property to a {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Adding-quad-points-to-existing-redaction-annotations/.NET/Adding-quad-points-to-existing-redaction-annotations/Program.cs" %} -FileStream docStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +using Syncfusion.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + +//Load the PDF document +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Load the existing PdfLoadedRedactionAnnotation PdfLoadedRedactionAnnotation annot = document.Pages[0].Annotations[0] as PdfLoadedRedactionAnnotation; @@ -5956,9 +6642,8 @@ annot.OverlayText = "Redact"; annot.TextAlignment = PdfTextAlignment.Center; annot.RepeatText = true; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -5966,6 +6651,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load an existing document. PdfLoadedDocument document = new PdfLoadedDocument(@"Input.pdf"); //Load the existing PdfLoadedRedactionAnnotation @@ -6000,6 +6690,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics + ' Load an existing document. Dim document As New PdfLoadedDocument("Input.pdf") ' Load the existing PdfLoadedRedactionAnnotation. @@ -6046,6 +6741,10 @@ The following code example illustrates how to print annotation in the PDF docume {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Annotation/Print-annotation-in-the-PDF-document/.NET/Print-annotation-in-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -6060,15 +6759,18 @@ rubberStampAnnotation.AnnotationFlags = PdfAnnotationFlags.Print; //Adds annotation to the page page.Annotations.Add(rubberStampAnnotation); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Creates a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -6092,6 +6794,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Creates a new PDF document Dim document As PdfDocument = New PdfDocument() 'Creates a new page @@ -6221,13 +6927,16 @@ Please refer to the below code example to achieve this on your end. {% highlight c# tabtitle="C# [Cross-platform]" %} -//Load the PDF document -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument lDoc = new PdfLoadedDocument(docStream); -//Import annotation data from XFDF stream -FileStream xfdfStream = new FileStream("Annotations.xfdf", FileMode.Open, FileAccess.Read); -lDoc.ImportAnnotations(xfdfStream, AnnotationDataFormat.XFdf); +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +//Loads the document +PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); +//Import the annotation data from the JSON file +lDoc.ImportAnnotations("Annotations.xfdf", AnnotationDataFormat.XFdf); //Set appearance for all the annotations foreach (PdfLoadedPage page in lDoc.Pages) { @@ -6236,19 +6945,21 @@ foreach (PdfLoadedPage page in lDoc.Pages) annotation.SetAppearance(true); } } -//Create file stream. -using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) -{ - //Save the PDF document to file stream. - lDoc.Save(outputFileStream); -} -//Closes the document + +//Saves the document +lDoc.Save("Annotation.pdf"); lDoc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("input.pdf"); //Import the annotation data from the JSON file @@ -6270,6 +6981,12 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + ' Load the PDF document from the file Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf") @@ -6285,7 +7002,6 @@ For Each pages As PdfLoadedPage In lDoc.Pages Next Next - 'Save the updated document lDoc.Save("Annotation.pdf") diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md index 1b44bac45..eb610a91f 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md @@ -20,6 +20,9 @@ You can add a text file attachment to a PDF document using [PdfAttachment](https {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Adding-attachment-to-a-PDF-document/.NET/Adding-attachment-to-a-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Creates an attachment @@ -31,9 +34,8 @@ attachment.MimeType = "application/txt"; //Adds the attachment to the document document.Attachments.Add(attachment); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -41,6 +43,9 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Create an attachment @@ -59,6 +64,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf + 'Create a new PDF document Dim document As New PdfDocument() 'Create an attachment @@ -85,9 +93,14 @@ Essential® PDF also provides support for adding the attachments t {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Adding-the-attachments-to-an-existing-PDF-document/.NET/Adding-the-attachments-to-an-existing-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Creates an attachment Stream fileStream = new FileStream("Input.txt", FileMode.Open, FileAccess.Read); PdfAttachment attachment = new PdfAttachment("Input.txt", fileStream); @@ -99,9 +112,8 @@ if (loadedDocument.Attachments == null) //Add the attachment to the document loadedDocument.Attachments.Add(attachment); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document loadedDocument.Close(true); @@ -109,6 +121,12 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load an existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Create an attachment @@ -129,6 +147,12 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + 'Load an existing PDF document Dim loadedDocument As New PdfLoadedDocument("Input.pdf") @@ -161,17 +185,17 @@ Essential® PDF allows you to remove the attachments from the exis {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Remove-attachment-from-an-existing-PDF-document/.NET/Remove-attachment-from-an-existing-PDF-document/Program.cs" %} +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Removes an attachment PdfAttachment attachment = document.Attachments[0]; //document.Attachments.Remove(attachment); document.Attachments.RemoveAt(0); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -179,6 +203,8 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Parsing; + //Loads the PDF document PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Removes an attachment @@ -194,6 +220,8 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Parsing + 'Loads the PDF document Dim document As New PdfLoadedDocument("Input.pdf") 'Removes an attachments @@ -219,9 +247,11 @@ Essential® PDF provides support for extracting the attachments an {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Extract-and-saving-an-attachment-to-the-disk/.NET/Extract-and-saving-an-attachment-to-the-disk/Program.cs" %} +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document -FileStream docStream = new FileStream("Output.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Iterates the attachments foreach (PdfAttachment attachment in document.Attachments) { @@ -231,9 +261,8 @@ foreach (PdfAttachment attachment in document.Attachments) s.Dispose(); } -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -241,6 +270,9 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Loads the PDF document PdfLoadedDocument document = new PdfLoadedDocument("Sample.pdf"); //Iterates the attachments @@ -260,6 +292,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + 'Loads the PDF document Dim document As New PdfLoadedDocument("Sample.pdf") 'Iterates the attachments @@ -292,110 +327,123 @@ You can achieve this functionality by using JavaScript actions within Syncfusion {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Attachment/Adding-PDF-Attachments-with-Interactive-Launch-Buttons/.NET/Adding-PDF-Attachments-with-Interactive-Launch-Buttons/Program.cs" %} -//Create FileStream object to read the input PDF file -using (FileStream inputFileStream = new FileStream(@"Data/Input.pdf", FileMode.Open, FileAccess.Read)) -{ - // Load the existing PDF file - PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream); +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; +using Syncfusion.Drawing; +using System.Reflection.Metadata; - // Get the first page of the PDF - PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; +// Load the existing PDF file +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); - // Create a PDF attachment - PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); - attachment.Description = "Attachment"; +// Get the first page of the PDF +PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; - // Create attachments section if it doesn't exist - if (loadedDocument.Attachments == null) - loadedDocument.CreateAttachment(); +// Create a PDF attachment +PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); +attachment.Description = "Attachment"; - // Add the attachment to the document - loadedDocument.Attachments.Add(attachment); +// Create attachments section if it doesn't exist +if (loadedDocument.Attachments == null) + loadedDocument.CreateAttachment(); - // Create a button field on the page - PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); - buttonField.Bounds = new RectangleF(100, 100, 100, 20); - buttonField.BorderColor = new PdfColor(Color.Black); - buttonField.BackColor = new PdfColor(Color.LightGray); - buttonField.Text = "Click Me"; - buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); +// Add the attachment to the document +loadedDocument.Attachments.Add(attachment); - // Add JavaScript action to open the attachment - buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); +// Create a button field on the page +PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); +buttonField.Bounds = new RectangleF(100, 100, 100, 20); +buttonField.BorderColor = new PdfColor(Color.Black); +buttonField.BackColor = new PdfColor(Color.LightGray); +buttonField.Text = "Click Me"; +buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); - // Create a form if it doesn't exist - if (loadedDocument.Form == null) - loadedDocument.CreateForm(); +// Add JavaScript action to open the attachment +buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); - // Add the button field to the form - loadedDocument.Form.Fields.Add(buttonField); +// Create a form if it doesn't exist +if (loadedDocument.Form == null) + loadedDocument.CreateForm(); - // Set default appearance for form fields - loadedDocument.Form.SetDefaultAppearance(false); +// Add the button field to the form +loadedDocument.Form.Fields.Add(buttonField); - //Create file stream. - using (FileStream outputFileStream = new FileStream(@"Output/Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - loadedDocument.Save(outputFileStream); - } +// Set default appearance for form fields +loadedDocument.Form.SetDefaultAppearance(false); - //Close the document. - loadedDocument.Close(true); -} +//Save the document +loadedDocument.Save("Output.pdf"); + +//Close the document. +loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - // Load the existing PDF file - PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; +using System.Drawing; +using System.Reflection.Metadata; - // Get the first page of the PDF - PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; +// Load the existing PDF file +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); - // Create a PDF attachment - PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); - attachment.Description = "Attachment"; +// Get the first page of the PDF +PdfLoadedPage lpage = loadedDocument.Pages[0] as PdfLoadedPage; - // Create attachments section if it doesn't exist - if (loadedDocument.Attachments == null) - loadedDocument.CreateAttachment(); +// Create a PDF attachment +PdfAttachment attachment = new PdfAttachment("Attachment.pdf", System.IO.File.ReadAllBytes(@"Data/Attachment.pdf")); +attachment.Description = "Attachment"; - // Add the attachment to the document - loadedDocument.Attachments.Add(attachment); +// Create attachments section if it doesn't exist +if (loadedDocument.Attachments == null) + loadedDocument.CreateAttachment(); - // Create a button field on the page - PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); - buttonField.Bounds = new RectangleF(100, 100, 100, 20); - buttonField.BorderColor = new PdfColor(Color.Black); - buttonField.BackColor = new PdfColor(Color.LightGray); - buttonField.Text = "Click Me"; - buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); +// Add the attachment to the document +loadedDocument.Attachments.Add(attachment); - // Add JavaScript action to open the attachment - buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); +// Create a button field on the page +PdfButtonField buttonField = new PdfButtonField(lpage, "Button"); +buttonField.Bounds = new RectangleF(100, 100, 100, 20); +buttonField.BorderColor = new PdfColor(Color.Black); +buttonField.BackColor = new PdfColor(Color.LightGray); +buttonField.Text = "Click Me"; +buttonField.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); - // Create a form if it doesn't exist - if (loadedDocument.Form == null) - loadedDocument.CreateForm(); +// Add JavaScript action to open the attachment +buttonField.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: \"Attachment.pdf\", nLaunch: 2 });"); - // Add the button field to the form - loadedDocument.Form.Fields.Add(buttonField); +// Create a form if it doesn't exist +if (loadedDocument.Form == null) + loadedDocument.CreateForm(); - // Set default appearance for form fields - loadedDocument.Form.SetDefaultAppearance(false); +// Add the button field to the form +loadedDocument.Form.Fields.Add(buttonField); - //Save the PDF document to file stream. - loadedDocument.Save("Output.pdf"); +// Set default appearance for form fields +loadedDocument.Form.SetDefaultAppearance(false); - //Close the document. - loadedDocument.Close(true); +//Save the document +loadedDocument.Save("Output.pdf"); + +//Close the document. +loadedDocument.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing +Imports Syncfusion.Pdf +Imports System.Drawing +Imports System.Reflection.Metadata + ' Load the existing PDF file Dim loadedDocument As New PdfLoadedDocument("Input.pdf") diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Barcode.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Barcode.md index 58e5ebff2..db50bab59 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Barcode.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Barcode.md @@ -20,6 +20,10 @@ The below code example shows how to add Code39 barcode using the [PdfCode39Barco {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/One%20dimensional%20barcode/Add-Code39-barcode-to-the-PDF-document/.NET/Add-Code39-barcode-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creating new PDF Document PdfDocument doc = new PdfDocument(); //Adding new page to PDF document @@ -34,23 +38,19 @@ barcode.Text = "CODE39$"; //Printing barcode to the PDF document barcode.Draw(page, new PointF(25, 70)); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -doc.Save(stream); -stream.Position = 0; -//Close the documents. +//Savethe PDF document +doc.Save("Output.pdf"); +//Close the document doc.Close(true); -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = " CODE39.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creating new PDF Document PdfDocument doc = new PdfDocument(); //Adding new page to PDF document @@ -73,6 +73,10 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Creating new PDF Document Dim doc As New PdfDocument() 'Adding new page to PDF document @@ -104,6 +108,10 @@ The below code snippet shows how to add PdfEan13 barcode using the [PdfEan13Barc {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/One%20dimensional%20barcode/Add-PdfEan13-barcode-to-a-PDF-document/.NET/Add-PdfEan13-barcode-to-a-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creates a new PdfEan13 Barcode. PdfEan13Barcode barcode = new PdfEan13Barcode (); //Set height of the barcode. @@ -114,30 +122,24 @@ barcode.Text = "400638133393"; //Creating new PDF document. PdfDocument document = new PdfDocument(); //Adding new page to PDF document. -PdfPage page = document.Pages.Add(); +PdfPage page = document.Pages.Add(); -//Printing barcode to the PDF document. +//Printing barcode to the PDF document. barcode.Draw(page, new PointF(25,70)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -document.Save(stream); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; +//Saving the document. +document.Save("EAN13Barcode.pdf"); //Close the document. -document.Close(true); -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "EAN13Barcode.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); +document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creates a new PdfEan13 Barcode. PdfEan13Barcode barcode = new PdfEan13Barcode (); //Set height of the barcode. @@ -162,6 +164,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Creates a new PdfEan13 Barcode. Dim barcode As New PdfEan13Barcode () 'Set height of the barcode. @@ -194,40 +200,38 @@ The below code example shows how to add PdfEan8 barcode using the [PdfEan8Barcod {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/One%20dimensional%20barcode/Add-PdfEan8-barcode-to-a-PDF-document/.NET/Add-PdfEan8-barcode-to-a-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creates a new PdfEan8 Barcode. PdfEan8Barcode barcode = new PdfEan8Barcode (); //Set height of the barcode. barcode.BarHeight = 50; -//Set the barcode text. +//Set the barcode text barcode.Text = "1234567"; //Creating new PDF document. PdfDocument document = new PdfDocument(); //Adding new page to PDF document. -PdfPage page = document.Pages.Add(); +PdfPage page = document.Pages.Add(); -//Printing barcode to the PDF document. +//Printing barcode to the PDF document. barcode.Draw(page, new PointF(25,70)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -document.Save(stream); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Close the document -document.Close(true); -//Defining the ContentType for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "EAN8Barcode.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); +//Saving the document. +document.Save("EAN8Barcode.pdf"); +//Close the document +document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creates a new PdfEan8 Barcode. PdfEan8Barcode barcode = new PdfEan8Barcode (); //Set height of the barcode. @@ -252,6 +256,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Creates a new PdfEan8 Barcode. Dim barcode As New PdfEan8Barcode () 'Set height of the barcode. @@ -286,6 +294,10 @@ The below code snippet shows how to add a QR code using [PdfQRBarcode](https://h {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/Two%20dimensional%20barcode/Add-a-QRBarcode-to-the-PDF-document/.NET/Add-a-QRBarcode-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Drawing QR Barcode PdfQRBarcode barcode = new PdfQRBarcode(); //Set Error Correction Level @@ -293,33 +305,27 @@ barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High; //Set XDimension barcode.XDimension = 3; barcode.Text = "http://www.syncfusion.com"; -barcode.Text = "http://www.syncfusion.com"; //Creating new PDF Document PdfDocument doc = new PdfDocument(); //Adding new page to PDF document PdfPage page = doc.Pages.Add(); - -//Printing barcode to the PDF +//Printing barcode to the PDF document barcode.Draw(page, new PointF(25, 70)); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); -stream.Position = 0; -//Close the documents +//Saving the document +doc.Save("QRBarcode.pdf"); +//Close the document doc.Close(true); -//Defining the ContentType for PDF file -string contentType = "application/pdf"; -//Define the file name. -string fileName = " QRBarcode.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Drawing QR Barcode PdfQRBarcode barcode = new PdfQRBarcode(); //Set Error Correction Level @@ -344,6 +350,10 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Drawing QR Barcode Dim barcode As New PdfQRBarcode() 'Set Error Correction Level @@ -377,11 +387,15 @@ The below code example shows how to add a Pdf417 barcode code using [Pdf417Barco {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/Two%20dimensional%20barcode/Add-a-Pdf417-barcode-to-the-PDF-document/.NET/Add-a-Pdf417-barcode-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creates a new Pdf417 Barcode. Pdf417Barcode barcode = new Pdf417Barcode(); //Set error correction level. barcode.ErrorCorrectionLevel= Pdf417ErrorCorrectionLevel.Auto; -//Set XDimension. +//Set XDimension barcode.XDimension = 2; //Set the barcode text. barcode.Text = "http://www.syncfusion.com"; @@ -394,25 +408,19 @@ PdfPage page = document.Pages.Add(); //Printing barcode on to the PDF. barcode.Draw(page, new PointF(25,70)); -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -document.Save(stream); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; +//Saving the document. +document.Save("417Barcode.pdf"); //Close the document. -document.Close(true); -//Defining the ContentType for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "417Barcode.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); +document.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creates a new Pdf417 Barcode. Pdf417Barcode barcode = new Pdf417Barcode(); //Set error correction level. @@ -439,6 +447,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Creates a new Pdf417 Barcode. Dim barcode As New Pdf417Barcode() 'Set error correction level. @@ -475,9 +487,13 @@ The following code snippets show how to set [Size](https://help.syncfusion.com/c {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/Set-location-and-size-to-the-barcode-in-a-PDF-document/.NET/Set-location-and-size-to-the-barcode-in-a-PDF-document/Program.cs" %} -//Creating new PDF document +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + +//Creating new PDF document. PdfDocument doc = new PdfDocument(); -//Adding new page to PDF document +//Adding new page to PDF document. PdfPage page = doc.Pages.Add(); //Create new instance for Codabar barcode. @@ -491,23 +507,18 @@ barcode.Text = "123456789$"; //Printing barcode on to the PDF. barcode.Draw(page); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -doc.Save(stream); -stream.Position = 0; -//Close the documents. +//Save and close the document. +doc.Save("CODABAR.pdf"); doc.Close(true); -//Defining the ContentType for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = " CODABAR.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creating new PDF document. PdfDocument doc = new PdfDocument(); //Adding new page to PDF document. @@ -532,6 +543,10 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Creating new PDF document. Dim doc As New PdfDocument() 'Adding new page to PDF document. @@ -566,7 +581,12 @@ To add quiet zones to a barcode in a PDF document, you can use the [PdfBarcodeQu {% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/Adding-quiet-zones-to-a-barcode/.NET/Adding-quiet-zones-to-a-barcode/Program.cs" %} + +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; +using Syncfusion.Pdf.Graphics; //Create a new PDF document. PdfDocument document = new PdfDocument(); @@ -594,12 +614,8 @@ barcode.Draw(page, new PointF(10, 10)); //Draw a rectangle based on the barcode size. page.Graphics.DrawRectangle(PdfPens.Red, new RectangleF(10, 10, barcode.Size.Width, barcode.Size.Height)); -//Create file stream. -using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) -{ - //Save the PDF document to file stream. - document.Save(outputFileStream); -} +//Save the document to disk. +document.Save("PdfBarcode1.pdf"); //Close the document. document.Close(true); @@ -608,6 +624,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Create a new PDF document. PdfDocument document = new PdfDocument(); @@ -644,6 +664,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + ' Create a new PDF document. Dim document As New PdfDocument() @@ -677,7 +701,7 @@ document.Close(True) {% endtabs %} -You can download a complete working sample from GitHub. +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Barcode/Adding-quiet-zones-to-a-barcode/.NET). ## Adding a barcode to the PDF document without displaying the barcode text @@ -687,7 +711,11 @@ The following code example shows how to add a barcode to the PDF document withou {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/Add-a-barcode-to-the-PDF-document-without-displaying-text/.NET/Program.cs" %} -//Creating new PDF document +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + +//Creating a new PDF document PdfDocument doc = new PdfDocument(); //Adding a new page to the PDF document PdfPage page = doc.Pages.Add(); @@ -701,28 +729,22 @@ barcode.Text = "123456789"; //Disable the barcode text barcode.TextDisplayLocation = TextLocation.None; -//Printing barcode on to the Pdf +//Printing barcode on to the PDF barcode.Draw(page); -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the document into stream -doc.Save(stream); -//If the position is not set to '0' then the PDF will be empty -stream.Position = 0; -//Close the document +//Save the PDF document +doc.Save("Output.pdf"); +//Close the PDF document doc.Close(true); -//Defining the ContentType for pdf file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Creating a new PDF document PdfDocument doc = new PdfDocument(); //Adding a new page to the PDF document @@ -749,6 +771,10 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Creating a new PDF document Dim doc As PdfDocument = New PdfDocument() 'Adding a new page to the PDF document @@ -789,6 +815,10 @@ The below code example shows how to convert one dimensional barcode to {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/Export-one-dimensional-barcode-as-image/.NET/Export-one-dimensional-barcode-as-image/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Initialize a new PdfCode39Barcode instance PdfCode39Barcode barcode = new PdfCode39Barcode(); //Set the height and text for barcode @@ -809,6 +839,10 @@ using (FileStream outputFileStream = new FileStream(@"Image.png", FileMode.Creat {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Initialize a new PdfCode39Barcode instance PdfCode39Barcode barcode = new PdfCode39Barcode(); //Set the height and text for barcode @@ -825,6 +859,10 @@ barcodeImage.Save("Image.png", ImageFormat.Png); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Initialize a new PdfCode39Barcode instance Dim barcode As PdfCode39Barcode = New PdfCode39Barcode 'Set the height and text for barcode @@ -849,6 +887,10 @@ Essential® PDF supports converting two-dimensional barcodes such {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Barcode/Export-two-dimensional-barcode-as-image/.NET/Export-two-dimensional-barcode-as-image/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Initialize a new PdfQRBarcode instance PdfQRBarcode barcode = new PdfQRBarcode(); //Set the XDimension and text for barcode @@ -869,6 +911,10 @@ using (FileStream outputFileStream = new FileStream("Output.png", FileMode.Creat {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Initialize a new PdfQRBarcode instance PdfQRBarcode barcode = new PdfQRBarcode(); //Set the XDimension and text for barcode @@ -885,6 +931,10 @@ barcodeImage.Save("Image.png", ImageFormat.Png); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Initialize a new PdfQRBarcode instance Dim barcode As PdfQRBarcode = New PdfQRBarcode 'Set the XDimension and text for barcode @@ -915,6 +965,10 @@ The following code sample explains how to customize the one-dimensional barcode {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page. @@ -930,25 +984,19 @@ code93.BarColor = Color.Blue; //Draws a barcode on the new Page. code93.Draw(page, new PointF(25, 500)); -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the document into stream -document.Save(stream); -//If the position is not set to '0' then the PDF will be empty -stream.Position = 0; -//Close the document +//Save document to disk. +document.Save("Output.pdf"); +//Close the document. document.Close(true); -//Defining the ContentType for pdf file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page. @@ -973,6 +1021,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument() 'Creates a new page. @@ -1003,6 +1055,10 @@ The following code example shows how to customize the two-dimensional barcode su {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Drawing QR Barcode PdfQRBarcode barcode = new PdfQRBarcode(); //Set Error Correction Level @@ -1021,23 +1077,19 @@ PdfPage page = document.Pages.Add(); //Printing barcode on to the PDF. barcode.Draw(page, new PointF(25, 70)); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; -//Close the documents. +//Saving the document +document.Save("QRBarcode.pdf"); +//Close the document document.Close(true); -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = " CODE39.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Drawing QR Barcode PdfQRBarcode barcode = new PdfQRBarcode(); //Set Error Correction Level @@ -1065,6 +1117,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Drawing QR Barcode Dim barcode As PdfQRBarcode = New PdfQRBarcode() 'Set Error Correction Level @@ -1093,6 +1149,7 @@ document.Close(True) {% endtabs %} ## Create QR code with logo + The `QRCodeLogo` class serves as a representation of a logo image that can be utilized in a QR code, and the `Logo` property is employed to set the logo image in the QR barcode. By leveraging these functionalities, users gain the capability to generate QR codes that seamlessly incorporate custom logos or images, resulting in a visually appealing and branded QR code experience. The following code example demonstrates how to generate a QR barcode with a logo positioned at the center of it. @@ -1101,6 +1158,10 @@ The following code example demonstrates how to generate a QR barcode with a logo {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page. @@ -1110,21 +1171,17 @@ PdfPage page = document.Pages.Add(); PdfQRBarcode qrBarcode = new PdfQRBarcode(); //Set the barcode text. qrBarcode.Text = "https://www.syncfusion.com/"; -//Set the logo image to QR barcode. -FileStream imageStream = new FileStream("logo.png", FileMode.Open, FileAccess.Read); //Create QR barcode logo. -QRCodeLogo qRCodeLogo = new QRCodeLogo(imageStream); +QRCodeLogo qRCodeLogo = new QRCodeLogo("logo.png"); //Set the QR barcode logo. qrBarcode.Logo = qRCodeLogo; -//Set the dimention of the barcode. +//Set the dimention of the barcode. qrBarcode.XDimension = 5; //Draw the barcode to PDF page. qrBarcode.Draw(page); -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the document into stream -document.Save(stream); +//Save the document. +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1132,6 +1189,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Barcode; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page. @@ -1159,6 +1220,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Barcode + 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument() 'Creates a new page. diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md index b9bf37b56..76702cc24 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md @@ -20,6 +20,11 @@ To quickly get started with adding, modifying, and removing PDF bookmarks in .NE {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Adding-bookmarks-in-a-PDF-document/.NET/Adding-bookmarks-in-a-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new document. PdfDocument document = new PdfDocument(); //Adds a page. @@ -34,9 +39,8 @@ bookmark.Destination.Location = new PointF(20, 20); bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Color = Syncfusion.Drawing.Color.Red; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document document.Close(true); @@ -44,6 +48,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new document. PdfDocument document = new PdfDocument(); //Adds a page. @@ -66,6 +75,12 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Interactive + + 'Creates a new document. Dim document As New PdfDocument() 'Adds a page. @@ -98,9 +113,12 @@ To add bookmarks to an existing PDF document, use the following code example. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Adding-bookmarks-in-an-existing-PDF-document/.NET/Adding-bookmarks-in-an-existing-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Creates document bookmarks. PdfBookmark bookmark = document.Bookmarks.Add("Page 1"); //Sets the destination page. @@ -111,9 +129,8 @@ bookmark.Color = Color.Red; //Sets the destination location. bookmark.Destination.Location = new PointF(20, 20); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -121,6 +138,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Loads the document. PdfLoadedDocument document = new PdfLoadedDocument("input.pdf"); //Creates document bookmarks. @@ -141,6 +162,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + 'Loads the document. Dim document As New PdfLoadedDocument("input.pdf") 'Creates document bookmarks. @@ -171,6 +196,11 @@ You can add a child bookmark by using [Insert](https://help.syncfusion.com/cr/do {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Adding-a-child-to-the-bookmarks-in-a-PDF/.NET/Adding-a-child-to-the-bookmarks-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new document. PdfDocument document = new PdfDocument(); //Adds a page. @@ -190,9 +220,8 @@ childBookmark.Destination.Zoom = 2F; bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Color = Syncfusion.Drawing.Color.Red; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -200,6 +229,11 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Creates a new document. PdfDocument document = new PdfDocument(); //Adds a page. @@ -227,6 +261,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Interactive + 'Creates a new document. Dim document As New PdfDocument() 'Adds a page. @@ -266,18 +305,20 @@ Each loaded bookmark is represented by the [PdfLoadedBookmark](https://help.sync {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Inserting-bookmarks-in-an-existing-PDF/.NET/Inserting-bookmarks-in-an-existing-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Inserts a new bookmark in the existing bookmark collection. PdfBookmark bookmark = document.Bookmarks.Insert(1, "New Page 2"); //Sets the destination page and location. bookmark.Destination = new PdfDestination(document.Pages[1]); bookmark.Destination.Location = new PointF(0, 300); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -285,6 +326,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Creates a new document. PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Inserts a new bookmark in the existing bookmark collection. @@ -300,6 +345,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + 'Creates a new document. Dim document As New PdfLoadedDocument("Input.pdf") 'Inserts a new bookmark in the existing bookmark collection. @@ -325,9 +374,12 @@ You can also remove bookmarks from the existing PDF document by using [Remove](h {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Remove-bookmarks-from-an-existing-PDF-document/.NET/Remove-bookmarks-from-an-existing-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmarks = document.Bookmarks; //Removes bookmark by bookmark name. @@ -335,9 +387,8 @@ bookmarks.Remove("Page 1"); //Removes bookmark by index. bookmarks.RemoveAt(1); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -345,6 +396,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Loads the PDF document. PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. @@ -362,6 +417,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + 'Loads the PDF document. Dim document As New PdfLoadedDocument("Input.pdf") 'Gets all the bookmarks. @@ -396,9 +455,12 @@ The following code example shows how to modify the [Destination](https://help.sy {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Modify-the-bookmarks-in-an-existing-PDF-document/.NET/Modify-the-bookmarks-in-an-existing-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmarks = document.Bookmarks; //Gets the first bookmark and changes the properties of the bookmark. @@ -408,9 +470,8 @@ bookmark.Color = Syncfusion.Drawing.Color.Green; bookmark.TextStyle = PdfTextStyle.Bold; bookmark.Title = "Changed title"; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); +//Save the document +document.Save("Output.pdf"); //Closes the document. document.Close(true); @@ -418,6 +479,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Loads the PDF document. PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. @@ -438,6 +503,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + 'Loads the PDF document. Dim document As New PdfLoadedDocument("Input.pdf") 'Gets all the bookmarks. @@ -467,17 +536,19 @@ You can get bookmark page index from the existing PDF document using [PageIndex] {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Bookmarks/Get-bookmark-page-index-from-the-existing-PDF-document/.NET/Get-bookmark-page-index-from-the-existing-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document. -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument= new PdfLoadedDocument("Input.pdf"); //Gets all the bookmarks. PdfBookmarkBase bookmark = loadedDocument.Bookmarks; //Get the bookmark page index. int index = bookmark[0].Destination.PageIndex; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); +//Save the document +loadedDocument.Save("Output.pdf"); //Close the document. loadedDocument.Close(true); @@ -485,6 +556,10 @@ loadedDocument.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load the PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Gets all the bookmarks. @@ -501,6 +576,10 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + 'Load the PDF document. Dim loadedDocument As New PdfLoadedDocument("input.pdf") 'Gets all the bookmarks. diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md index 1e171afea..8896c7b9a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Brushes.md @@ -24,6 +24,10 @@ The solid brush is used to fill an object with solid color. Essential®< {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Brushes/Fill-an-object-with-solid-brush-in-a-PDF/.NET/Fill-an-object-with-solid-brush-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -36,14 +40,18 @@ PdfSolidBrush brush = new PdfSolidBrush(Color.Red); //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -63,6 +71,11 @@ doc.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document Dim doc As PdfDocument = New PdfDocument 'Add a page to the document @@ -93,6 +106,10 @@ The gradient brush is used to fill an object with blend of two or more colors. E {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Brushes/Fill-an-object-with-gradient-brush-in-a-PDF/.NET/Fill-an-object-with-gradient-brush-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -105,15 +122,18 @@ PdfLinearGradientBrush brush = new PdfLinearGradientBrush(new PointF(0, 0), new //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -134,6 +154,11 @@ doc.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document Dim doc As PdfDocument = New PdfDocument 'Add a page to the document @@ -166,6 +191,10 @@ The following code example demonstrates how to fill a rectangle with a gradient {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Brushes/Linear-Gradient-Brush-with-Multiple-Colors/.NET/Linear-Gradient-Brush-with-Multiple-Colors/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + // Create a new PDF document using (PdfDocument document = new PdfDocument()) { @@ -204,16 +233,17 @@ using (PdfDocument document = new PdfDocument()) // Draw a rectangle filled with the gradient graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100)); - //Create file stream. - using (FileStream outputFileStream = new FileStream(@"Output/Output.pdf", FileMode.Create, FileAccess.ReadWrite)) - { - //Save the PDF document to file stream. - document.Save(outputFileStream); - } + //Save the PDF document + document.Save("Output.pdf"); } {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + // Create a new PDF document using (PdfDocument document = new PdfDocument()) { @@ -252,12 +282,17 @@ using (PdfDocument document = new PdfDocument()) // Draw a rectangle filled with the gradient graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100)); - //Save the PDF document to file stream. + //Save the PDF document document.Save("Output.pdf"); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics + ' Create a new PDF document Using document As New PdfDocument() ' Add a page to the document @@ -288,7 +323,7 @@ Using document As New PdfDocument() ' Draw a rectangle filled with the gradient graphics.DrawRectangle(brush, New RectangleF(0, 0, 200, 100)) - ' Save the PDF document to a file stream + ' Save the PDF document document.Save("Output.pdf") End Using {% endhighlight %} @@ -305,6 +340,10 @@ The gradient brush is used to fill an object with blend of two or more colors. Y {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Brushes/Draw-shapes-on-PDF-with-radial-gradient-brush/.NET/Draw-shapes-on-PDF-with-radial-gradient-brush/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -317,14 +356,18 @@ PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, //Draw ellipse on the page graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100)); -//Save the PDF document stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -344,6 +387,11 @@ doc.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document Dim doc As PdfDocument = New PdfDocument 'Add a page to the document @@ -374,6 +422,10 @@ The tiling brush is used to draw an object repeatedly. You can draw any shape on {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Brushes/Draw-shape-on-PDF-with-tiling-brush/.NET/Draw-shape-on-PDF-with-tiling-brush/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -388,14 +440,18 @@ brush.Graphics.DrawEllipse(PdfPens.Red, new RectangleF(0, 0, 10, 10)); //Draw ellipse graphics.DrawEllipse(brush, new RectangleF(0, 0, 200, 100)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} + +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -417,6 +473,11 @@ doc.Close(true); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics + 'Create a new PDF document Dim doc As PdfDocument = New PdfDocument 'Add a page to the document @@ -448,6 +509,10 @@ The hatch brush is used to fill an object with hatch patterns. Essential&re {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Brushes/Hatch-brush/.NET/Hatch-brush/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -464,9 +529,8 @@ PdfHatchBrush pdfHatchBrush = new PdfHatchBrush(PdfHatchStyle.Plaid, new PdfColo //Draw rectangle on the page graphics.DrawRectangle(PdfPens.Black, pdfHatchBrush, new Rectangle(100, 100, 300, 200)); -//Save the PDF document to stream -MemoryStream stream = new MemoryStream(); -doc.Save(stream); +//Save the PDF document +doc.Save("Output.pdf"); //Close the Pdf Document doc.Close(true); @@ -474,6 +538,10 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page to the document @@ -499,6 +567,10 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics + ' Create a new PDF document Dim doc As PdfDocument = New PdfDocument ' Add a page to the document diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-action.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-action.md index d768e6d22..ea20665a7 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-action.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-action.md @@ -17,6 +17,9 @@ The below code example illustrates how to add the action to the PDF document usi {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-action-to-the-PDF-document/.NET/Add-action-to-the-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); @@ -24,23 +27,18 @@ PdfDocument document = new PdfDocument(); PdfLaunchAction action = new PdfLaunchAction("logo.png"); document.Actions.AfterOpen = action; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for pdf file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); @@ -57,6 +55,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new PDF document Dim document As New PdfDocument() @@ -95,14 +96,16 @@ The [PdfSoundAction](https://help.syncfusion.com/cr/document-processing/Syncfusi {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-the-sound-action-to-PDF-document/.NET/Add-the-sound-action-to-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add a page PdfPage page = document.Pages.Add(); //Create a sound action -FileStream fileStream = new FileStream("Startup.wav", FileMode.Open, FileAccess.Read); -PdfSoundAction soundAction = new PdfSoundAction(fileStream); +PdfSoundAction soundAction = new PdfSoundAction("Startup.wav"); soundAction.Sound.Bits = 16; soundAction.Sound.Channels = PdfSoundChannels.Stereo; soundAction.Sound.Encoding = PdfSoundEncoding.Signed; @@ -111,23 +114,18 @@ soundAction.Volume = 0.9f; //Set the sound action document.Actions.AfterOpen = soundAction; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for pdf file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add a page @@ -151,6 +149,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new document Dim document As New PdfDocument() 'Add a page @@ -184,6 +185,9 @@ The [PdfJavaScriptAction](https://help.syncfusion.com/cr/document-processing/Syn {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-JavaScript-action-to-the-PDF-document/.NET/Add-JavaScript-action-to-the-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add a page @@ -195,23 +199,18 @@ PdfJavaScriptAction scriptAction = new PdfJavaScriptAction("app.alert(\"Hello Wo //Add the JavaScript action document.Actions.AfterOpen = scriptAction; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for pdf file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add a page @@ -231,6 +230,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new document Dim document As New PdfDocument() 'Add a page @@ -263,6 +265,9 @@ The [PdfUriAction](https://help.syncfusion.com/cr/document-processing/Syncfusion {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-URI-action-to-the-PDF-document/.NET/Add-URI-action-to-the-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document with PDF/A standard PdfDocument document = new PdfDocument(); @@ -272,23 +277,17 @@ PdfUriAction uriAction = new PdfUriAction("http://www.google.com"); //Add the action to the document document.Actions.AfterOpen = uriAction; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); - {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document with PDF/A standard PdfDocument document = new PdfDocument(); @@ -306,6 +305,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new document with PDF/A standard Dim document As New PdfDocument() @@ -333,6 +335,10 @@ The [PdfGoToAction](https://help.syncfusion.com/cr/document-processing/Syncfusio {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-GoTo-action-to-the-PDF-document/.NET/Add-GoTo-action-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add first page @@ -348,23 +354,18 @@ gotoAction.Destination = new PdfDestination(secondPage, new PointF(0, 100)); //Add the action to the document document.Actions.AfterOpen = gotoAction; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); - {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add first page @@ -388,6 +389,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new document Dim document As New PdfDocument() 'Add first page @@ -421,6 +426,9 @@ The [PdfLaunchAction](https://help.syncfusion.com/cr/document-processing/Syncfus {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-lauch-action-to-PDF-document/.NET/Add-lauch-action-to-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document. PdfDocument document = new PdfDocument(); @@ -428,23 +436,18 @@ PdfDocument document = new PdfDocument(); PdfLaunchAction action = new PdfLaunchAction("logo.png"); document.Actions.AfterOpen = action; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for pdf file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); @@ -462,6 +465,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new PDF document Dim document As New PdfDocument() @@ -494,6 +500,9 @@ The [PdfNamedAction](https://help.syncfusion.com/cr/document-processing/Syncfusi {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-named-action-to-PDF-document/.NET/Add-named-action-to-PDF-document/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add the page @@ -506,23 +515,18 @@ PdfNamedAction namedAction = new PdfNamedAction(PdfActionDestination.LastPage); //Add the named action document.Actions.AfterOpen = namedAction; -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document. document.Close(true); -//Defining the ContentType for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add the page @@ -543,6 +547,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new document Dim document As New PdfDocument() 'Add the page @@ -573,6 +580,10 @@ The [PdfSubmitAction](https://help.syncfusion.com/cr/document-processing/Syncfus {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-submit-action-to-the-PDF-document/.NET/Add-submit-action-to-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a PDF document PdfDocument document = new PdfDocument(); //Add a new page @@ -590,23 +601,19 @@ PdfSubmitAction submitAction = new PdfSubmitAction("http://www.syncfusionforms.c submitAction.DataFormat = SubmitDataFormat.Html; submitButton.Actions.GotFocus = submitAction; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a PDF document PdfDocument document = new PdfDocument(); //Add a new page @@ -632,6 +639,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a PDF document Dim document As New PdfDocument() 'Add a new page @@ -667,6 +678,11 @@ The [PdfResetAction](https://help.syncfusion.com/cr/document-processing/Syncfusi {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Reset-form-fields-in-the-PDF-document/.NET/Reset-form-fields-in-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a PDF document PdfDocument document = new PdfDocument(); //Add a new page @@ -690,23 +706,20 @@ clearButton.ToolTip = "Clear"; //Add button field to the form document.Form.Fields.Add(clearButton); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a PDF document PdfDocument document = new PdfDocument(); //Add a new page @@ -742,6 +755,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Interactive + 'Create a PDF document Dim document As New PdfDocument() 'Add a new page @@ -787,6 +805,11 @@ The PdfRemoteGoToAction in a PDF document enables users to navigate to a specifi {% highlight c# tabtitle="C# [Cross-platform]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Create a new page @@ -811,23 +834,20 @@ goToAction.IsNewWindow = true; submitButton.Actions.GotFocus = goToAction; //Add the submit button to a new document document.Form.Fields.Add(submitButton); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -// Defining the ContentType for the PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Create a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Create a new page @@ -852,10 +872,8 @@ goToAction.IsNewWindow = true; submitButton.Actions.GotFocus = goToAction; //Add the submit button to a new document document.Form.Fields.Add(submitButton); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); @@ -863,6 +881,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Interactive + 'Create a new document Dim document As PdfDocument = New PdfDocument 'Create a new page @@ -887,9 +910,9 @@ goToAction.IsNewWindow = true submitButton.Actions.GotFocus = goToAction 'Add the submit button to a new document document.Form.Fields.Add(submitButton) -Dim stream As MemoryStream = New MemoryStream -document.Save(stream) -stream.Position = 0 + +'Save the document +document.Save("Output.pdf") 'Close the document document.Close(true) @@ -907,6 +930,11 @@ Essential® PDF provides support to add various actions to the for {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Adding-an-action-to-the-form-fields-in-PDF-document/.NET/Adding-an-action-to-the-form-fields-in-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -926,23 +954,20 @@ submitButton.Actions.MouseDown = scriptAction; //Add the submit button to the new document document.Form.Fields.Add(submitButton); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document document.Close(true); -//Defining the ContentType for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + //Create a new PDF document PdfDocument document = new PdfDocument(); //Creates a new page @@ -971,6 +996,11 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Interactive + 'Create a new PDF document Dim document As New PdfDocument() @@ -1010,6 +1040,10 @@ Essential® PDF provides support to add the various actions to the {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Adding-an-action-to-the-bookmark-in-the-PDF-document/.NET/Adding-an-action-to-the-bookmark-in-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add a page @@ -1026,23 +1060,19 @@ PdfUriAction uriAction = new PdfUriAction("http://www.google.com"); //Set the Uri action to the bookmark bookmark.Action = uriAction; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document. document.Close(true); -//Defining the ContentType for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; + //Create a new document PdfDocument document = new PdfDocument(); //Add a page @@ -1067,6 +1097,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Interactive + 'Create a new document Dim document As New PdfDocument() 'Add a page @@ -1101,8 +1135,11 @@ To add actions to an existing PDF document, use the following code example. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Add-actions-to-the-existing-PDF-document/.NET/Add-actions-to-the-existing-PDF-document/Program.cs" %} -//Load the PDF document. -FileStream docStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read); PdfLoadedDocument document = new PdfLoadedDocument(docStream); +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + +//Load an existing PDF document. +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); //Create JavaScript action PdfJavaScriptAction scriptAction = new PdfJavaScriptAction("app.alert(\"Hello World!!!\")"); @@ -1110,22 +1147,18 @@ PdfJavaScriptAction scriptAction = new PdfJavaScriptAction("app.alert(\"Hello Wo //Add the JavaScript action document.Actions.AfterOpen = scriptAction; -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); stream.Position = 0; +//Save the document +document.Save("Output.pdf"); //Close the document. document.Close(true); -//Define the ContentType for a pdf file -string contentType = "application/pdf"; -//Define the file name. -string fileName = "output.pdf"; -//Create a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load a document from the disk. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); @@ -1143,6 +1176,9 @@ loadedDocument.Close(); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + 'Create a new PDF document. Dim document As New PdfLoadedDocument("input.pdf") @@ -1176,6 +1212,9 @@ The following example demonstrates how to add document-level JavaScript actions {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Adding-Document-Level%20JavaScript-Actions/.NET/Adding-Document-Level%20JavaScript-Actions/Program.cs" %} +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Create a new PDF document instance. PdfDocument document = new PdfDocument(); // Retrieve the JavaScript collection from the document. @@ -1189,11 +1228,8 @@ javaScriptAction.Name = "Test"; // Add the JavaScript action to the document's JavaScript collection. javaScriptCollection.Add(javaScriptAction); -//Save the document into stream -using(MemoryStream stream = new MemoryStream()) -{ - document.Save(stream); -} +//Save the document +document.Save("Output.pdf"); //Close the document. document.Close(true); @@ -1202,6 +1238,9 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Create a new PDF document instance. PdfDocument document = new PdfDocument(); // Retrieve the JavaScript collection from the document. @@ -1225,6 +1264,9 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive + ' Create a new PDF document instance. Dim document As New PdfDocument() ' Retrieve the JavaScript collection from the document. @@ -1258,9 +1300,12 @@ The following example demonstrates how to retrieve document-level JavaScript act {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Retrieve-Document-Level-JavaScript-Actions/.NET/Retrieve-Document-Level-JavaScript-Actions/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); // Retrieve the JavaScript collection from the loaded document. PdfDocumentJavaScriptCollection javaScriptCollection = document.DocumentJavaScripts; @@ -1282,6 +1327,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load an existing PDF document. PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); @@ -1305,6 +1354,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + ' Load an existing PDF document. Dim document As New PdfLoadedDocument("Input.pdf") @@ -1337,9 +1390,12 @@ The following example demonstrates how to remove document-level JavaScript actio {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Actions/Remove-Document-Level-JavaScript-Actions/.NET/Remove-Document-Level-JavaScript-Actions/Program.cs" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + //Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -PdfLoadedDocument document = new PdfLoadedDocument(docStream); +PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); // Retrieve the JavaScript collection from the document. PdfDocumentJavaScriptCollection javaScriptCollection = document.DocumentJavaScripts; @@ -1357,6 +1413,10 @@ document.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; + // Load an existing PDF document. PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); @@ -1376,6 +1436,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing + ' Load an existing PDF document. Dim document As New PdfLoadedDocument("Input.pdf") From cf887f3bdae648b55e09cba69638dc041419fbd8 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Tue, 7 Oct 2025 18:28:43 +0530 Subject: [PATCH 08/11] 985481-1: Added changes in md files. --- .../NET/Working-with-Colorspace.md | 276 +++++++++++------- .../NET/Working-with-Compression.md | 199 +++++++------ 2 files changed, 284 insertions(+), 191 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Colorspace.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Colorspace.md index a1c2526e6..adce3909a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Colorspace.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Colorspace.md @@ -42,6 +42,11 @@ You can draw a rectangle on new PDF document with **CalGray** brush using [PdfCa {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/ColorSpace/Draw-rectangle-on-new-PDF-with-CalGray-brush/.NET/Draw-rectangle-on-new-PDF-with-CalGray-brush/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Graphics; + //Creates a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Adds a page to the PDF document @@ -62,23 +67,20 @@ RectangleF bounds = new RectangleF(0, 0, 300, 300); //Draws rectangle by using the PdfBrush graphics.DrawRectangle(brush, bounds); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); -stream.Position = 0; +//Save the document +pdfDocument.Save("Output.pdf"); //Closes the document pdfDocument.Close(true); -//Defining the content type for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Graphics; + //Creates a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Adds a page to the PDF document @@ -108,6 +110,11 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.ColorSpace +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document. Dim pdfDocument As New PdfDocument() 'Adds a page to the PDF document @@ -145,9 +152,14 @@ The following code example illustrates how to draw a rectangle with **CalGray** {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/ColorSpace/Draw-rectangle-with-CalGray-brush-in-an-existing-PDF/.NET/Draw-rectangle-with-CalGray-brush-in-an-existing-PDF/Program.cs" %} -//Load the PDF document. -FileStream docStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + +//Loads the existing PDF document. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Loads the page. PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; //Acquires graphics of the page. @@ -166,25 +178,23 @@ RectangleF bounds = new RectangleF(0, 0, 300, 300); //Draws rectangle by using the PdfBrush. graphics.DrawRectangle(brush, bounds); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); -stream.Position = 0; +//Saves the modified document. +loadedDocument.Save("Output.pdf"); //Closes the document. loadedDocument.Close(true); -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + //Loads the existing PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Loads the page. PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; //Acquires graphics of the page. @@ -212,8 +222,14 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.ColorSpace +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + 'Loads the existing PDF document. -Dim loadedDocument As New PdfLoadedDocument(fileName) +Dim loadedDocument As New PdfLoadedDocument("Input.pdf") 'Loads the page Dim loadedPage As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage) 'Acquires graphics of the page. @@ -260,6 +276,11 @@ The following code example illustrates how to set the indexed ICC color space us {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/ColorSpace/Create-PDF-document-with-ICC-color-space/.NET/Create-PDF-document-with-ICC-color-space/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Graphics; + //Creates a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Adds a page to the PDF document. @@ -293,23 +314,20 @@ RectangleF bounds = new RectangleF(0, 0, 300, 300); //Draws rectangle by using the PdfBrush. graphics.DrawRectangle(brush, bounds); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); -stream.Position = 0; +//Save the document +pdfDocument.Save("Output.pdf"); //Closes the document pdfDocument.Close(true); -//Defining the content type for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Graphics; + //Creates a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Adds a page to the PDF document. @@ -352,6 +370,11 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.ColorSpace +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document. Dim pdfDocument As New PdfDocument() 'Adds a page to the PDF document. @@ -400,9 +423,14 @@ The following code example illustrates how to set the indexed ICC color space in {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/ColorSpace/Set-ICC-color-space-in-an-existing-PDF-document/.NET/Set-ICC-color-space-in-an-existing-PDF-document/Program.cs" %} -//Load PDF document as stream. -FileStream docStream = new FileStream(docPath, FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + +//Loads the existing PDF document. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Loads the page. PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; //Acquires graphics of the page. @@ -434,25 +462,23 @@ RectangleF bounds = new RectangleF(0, 0, 300, 300); //Draws rectangle by using the PdfBrush. graphics.DrawRectangle(brush, bounds); -//Save the document into stream. -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); -stream.Position = 0; +//Saves the document. +loadedDocument.Save("Output.pdf"); //Closes the document. -pdfDocument.Close(true); -//Defining the ContentType for pdf file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); +loadedDocument.Close(true); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + //Loads the existing PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Loads the page. PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; //Acquires graphics of the page. @@ -493,6 +519,12 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.ColorSpace +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + 'Loads the existing PDF document. Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(fileName) 'Loads the page. @@ -544,6 +576,12 @@ The following code example illustrates how to draw the graphics elements by usin {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/ColorSpace/Draw-graphics-elements-by-using-Pantone-colors-in-a-PDF/.NET/Draw-graphics-elements-by-using-Pantone-colors-in-a-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Functions; +using Syncfusion.Pdf.Graphics; + //Creates a new document PdfDocument document = new PdfDocument(); //Creates a new page @@ -552,10 +590,8 @@ PdfPage page = document.Pages.Add(); //Creates exponential interpolation function PdfExponentialInterpolationFunction function = new PdfExponentialInterpolationFunction(true); float[] numberArray = new float[4]; -numberArray[0] = 0f; -numberArray[1] = 0.44f; -numberArray[2] = 0.87f; -numberArray[3] = 0.10f; +numberArray[0] = 0.38f; +numberArray[1] = 0.88f; function.C1 = numberArray; //Creates SeparationColorSpace @@ -570,23 +606,21 @@ PdfPen pen = new PdfPen(color); //Draws the rectangle page.Graphics.DrawRectangle(pen, bounds); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -document.Save(stream); -stream.Position = 0; +//Saves the document +document.Save("SeparationColor.pdf"); //Closes the document document.Close(true); -//Defining the content type for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "SeparationColor.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} - + +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Functions; +using Syncfusion.Pdf.Graphics; + //Creates a new document PdfDocument document = new PdfDocument(); //Creates a new page @@ -620,6 +654,12 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.ColorSpace +Imports Syncfusion.Pdf.Functions +Imports Syncfusion.Pdf.Graphics + 'Creates a new document Dim document As PdfDocument = New PdfDocument() 'Creates a page @@ -661,10 +701,16 @@ The following code example illustrates how to draw the graphics elements by usin {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/ColorSpace/Add-graphics-elemets-by-Pantone-color-in-existing-PDF/.NET/Add-graphics-elemets-by-Pantone-color-in-existing-PDF/Program.cs" %} -//Load the PDF document -FileStream docStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); -//Load the page +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Functions; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + +//Loads the document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); +//Load the page PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; //Creates exponential interpolation function @@ -676,7 +722,7 @@ function.C1 = numberArray; //Creates SeparationColorSpace PdfSeparationColorSpace colorSpace = new PdfSeparationColorSpace(); -colorSpace.TintTransform = function; +colorSpace.TintTransform = function colorSpace.Colorant = "PANTONE Orange 021 C"; PdfSeparationColor color = new PdfSeparationColor(colorSpace); color.Tint = 0.7; @@ -686,25 +732,24 @@ PdfPen pen = new PdfPen(color); //Draws the rectangle loadedPage.Graphics.DrawRectangle(pen, bounds); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); -stream.Position = 0; +//Saves the document +loadedDocument.Save("SeparationColor.pdf") //Closes the document loadedDocument.Close(true); -//Defining the content type for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "SeparationColor.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.ColorSpace; +using Syncfusion.Pdf.Functions; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + //Loads the document -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Load the page PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -736,8 +781,15 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.ColorSpace +Imports Syncfusion.Pdf.Functions +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + 'Loads the document -Dim loadedDocument As New PdfLoadedDocument(fileName) +Dim loadedDocument As New PdfLoadedDocument("Input.pdf") 'Load the page Dim loadedPage As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage) @@ -781,6 +833,10 @@ The following code illustrates how to use the color spaces in particular objects {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/ColorSpace/Use-color-space-in-particular-object-in-a-new-PDF/.NET/Use-color-space-in-particular-object-in-a-new-PDF/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Creates a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Adds a page to the PDF document. @@ -791,7 +847,7 @@ PdfGraphics graphics = pdfPage.Graphics; PdfPen pen = new PdfPen(Color.Red); PdfBrush brush = new PdfSolidBrush(Color.Blue); RectangleF rectangle = new RectangleF(0, 0, 100, 100); -//Default color space +//Default color space. graphics.DrawRectangle(pen, brush, rectangle); graphics.Save(); @@ -809,23 +865,19 @@ graphics.DrawRectangle(pen, brush, rectangle); //Draws by using the PdfBrush. graphics.DrawRectangle(brush, rectangle); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -pdfDocument.Save(stream); -stream.Position = 0; +//Saves the document. +pdfDocument.Save("Output.pdf"); //Closes the document pdfDocument.Close(true); -//Defining the content type for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Creates a new PDF document. PdfDocument pdfDocument = new PdfDocument(); //Adds a page to the PDF document. @@ -863,6 +915,10 @@ pdfDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics + 'Creates a new PDF document. Dim pdfDocument As New PdfDocument() 'Adds a page to the PDF document. @@ -908,9 +964,13 @@ The following code illustrates how to use the color spaces in particular objects {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/ColorSpace/Add-color-space-in-particular-object-in-an-existing-PDF/.NET/Add-color-space-in-particular-object-in-an-existing-PDF/Program.cs" %} -//Load the PDF document -FileStream docStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + +//Loads the existing PDF document. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Loads the page PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -937,25 +997,22 @@ graphics.DrawRectangle(pen, brush, rectangle); //Draws by using the PdfBrush. graphics.DrawRectangle(brush, rectangle); -//Save the document into stream -MemoryStream stream = new MemoryStream(); -loadedDocument.Save(stream); -stream.Position = 0; +//Saves the document. +loadedDocument.Save("Output.pdf"); //Closes the document loadedDocument.Close(true); -//Defining the content type for PDF file -string contentType = "application/pdf"; -//Define the file name -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; + //Loads the existing PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Loads the page PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; @@ -991,6 +1048,11 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports System.Drawing +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing + 'Loads the existing PDF document. Dim loadedDocument As New PdfLoadedDocument(fileName) 'Loads the page diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md index fc73b17e2..4ec7a5707 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md @@ -29,7 +29,7 @@ You can compress the existing PDF document by using [PdfLoadedDocument](https:// N> 1.To compress an existing PDF document in .NET Core, you need to add the [Syncfusion.Pdf.Imaging.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Imaging.Net.Core) package from [NuGet.org](https://www.nuget.org/) as a reference in your project. N> 2.To ensure compatibility on **Linux** when performing image-based operations such as compression or rendering using `Syncfusion.Pdf.Imaging.Net.Core`, you must include the `SkiaSharp` library along with the `SkiaSharp.NativeAssets.Linux` package in your project. -N> 3. For Linux environments, refer to the [documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/nuget-packages-required) for detailed information on the additional NuGet packages required. +N> 3.For Linux environments, refer to the [documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/nuget-packages-required) for detailed information on the additional NuGet packages required. ## Compressing images with image quality @@ -41,10 +41,11 @@ The following example code snippet illustrates how to compress the images in exi {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Compression/Compress-the-images-in-an-existing-PDF-document/.NET/Compress-the-images-in-an-existing-PDF-document/Program.cs" %} -//Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); -//Load the existing PDF document -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + +//Load the existing PDF document. +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Create a new compression option. PdfCompressionOptions options = new PdfCompressionOptions(); @@ -54,27 +55,20 @@ options.CompressImages = true; options.ImageQuality = 50; //Assign the compression option to the document. -loadedDocument.Compress(options); +loadedDocument.CompressionOptions = options; -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); -//Close the documents. +//Save the PDF document. +loadedDocument.Save("Output.pdf"); +//Close the document. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); @@ -97,6 +91,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing + 'Load the existing PDF document. Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("input.pdf") @@ -131,10 +128,11 @@ The following example code snippet illustrates how to optimize embedded font in {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Compression/Optimize-embedded-font-in-an-existing-PDF-document/.NET/Optimize-embedded-font-in-an-existing-PDF-document/Program.cs" %} -//Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Create a new compression option. PdfCompressionOptions options = new PdfCompressionOptions(); @@ -142,27 +140,20 @@ PdfCompressionOptions options = new PdfCompressionOptions(); options.OptimizeFont = true; //Assign the compression option to the document. -loadedDocument.Compress(options); +loadedDocument.CompressionOptions = options; -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); -//Close the documents. +//Save the PDF document. +loadedDocument.Save("Output.pdf"); +//Close the document. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); @@ -183,6 +174,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing + 'Load the existing PDF document. Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("input.pdf") @@ -217,10 +211,11 @@ The following example code snippet illustrates how to optimize page contents in {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Compression/Optimize-page-contents-in-an-existing-PDF-document/.NET/Optimize-page-contents-in-an-existing-PDF-document/Program.cs" %} -//Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Create a new compression option. PdfCompressionOptions options = new PdfCompressionOptions(); @@ -228,27 +223,20 @@ PdfCompressionOptions options = new PdfCompressionOptions(); options.OptimizePageContents = true; //Assign the compression option to the document. -loadedDocument.Compress(options); +loadedDocument.CompressionOptions = options; -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); -//Close the documents. +//Save the PDF document. +loadedDocument.Save("Output.pdf"); +//Close the document. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); @@ -269,6 +257,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing + 'Load the existing PDF document. Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("input.pdf") @@ -301,10 +292,11 @@ The following example code snippet illustrates how to optimize page contents in {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Compression/Reduce-PDF-file-size-by-removing-PDF-metadata/.NET/Reduce-PDF-file-size-by-removing-PDF-metadata/Program.cs" %} -//Load an existing PDF document. -FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read); +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. -PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); //Create a new compression option. PdfCompressionOptions options = new PdfCompressionOptions(); @@ -312,27 +304,20 @@ PdfCompressionOptions options = new PdfCompressionOptions(); options.RemoveMetadata = true; //Assign the compression option to the document. -loadedDocument.Compress(options); +loadedDocument.CompressionOptions = options; -//Creating the stream object -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -loadedDocument.Save(stream); -//Close the documents. +//Save the PDF document. +loadedDocument.Save("Output.pdf"); +//Close the document. loadedDocument.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the existing PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); @@ -353,6 +338,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing + 'Load the existing PDF document. Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("input.pdf") @@ -390,6 +378,10 @@ The following code snippet illustrates how to compress the content of the PDF do {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Compression/Compress-the-content-of-the-PDF-document/.NET/Compress-the-content-of-the-PDF-document/Program.cs" %} +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Set the compression level to best. @@ -403,31 +395,26 @@ PdfGraphics graphics = page.Graphics; PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20); string text = "Hello World!!!"; PdfTextElement textElement = new PdfTextElement(text, font); + PdfLayoutResult result = textElement.Draw(page, new RectangleF(0, 0, font.MeasureString(text).Width, page.GetClientSize().Height)); for (int i = 0; i < 1000; i++) { - result = textElement.Draw(result.Page, new RectangleF(0, result.Bounds.Bottom + 10, font.MeasureString(text).Width, page.GetClientSize().Height)); +result = textElement.Draw(result.Page, new RectangleF(0, result.Bounds.Bottom +10, font.MeasureString(text).Width, page.GetClientSize().Height)); } -//Creating the stream object. -MemoryStream stream = new MemoryStream(); -//Save the document into stream. -document.Save(stream); -//Close the documents. +//Save the document. +document.Save("Output.pdf"); +//Close the document. document.Close(true); -//If the position is not set to '0' then the PDF will be empty. -stream.Position = 0; -//Defining the content type for PDF file. -string contentType = "application/pdf"; -//Define the file name. -string fileName = "Output.pdf"; -//Creates a FileContentResult object by using the file contents, content type, and file name. -return File(stream, contentType, fileName); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +using System.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Set the compression level to best. @@ -457,6 +444,10 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing +Imports System.Drawing + 'Create a new PDF document. Dim document As New PdfDocument() 'Set the compression level to best @@ -490,6 +481,9 @@ You can compress the existing PDF document by specifying the [PdfCompressionLeve {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; + //Load the PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); @@ -507,6 +501,9 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing + 'Load the PDF document Dim loadedDocument As New PdfLoadedDocument("Input.pdf") @@ -534,6 +531,14 @@ Essential® PDF allows you to compress/change the quality of the i {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Text; + //Create a new PDF document. PdfDocument document = new PdfDocument(); //Add a page to the document. @@ -557,6 +562,14 @@ document.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports System +Imports System.Collections.Generic +Imports System.Diagnostics +Imports System.Drawing +Imports System.Text + 'Create a new PDF document. Dim document As New PdfDocument() 'Add a page to the document. @@ -588,6 +601,15 @@ You can compress the images in an existing PDF document by extract the images us {% highlight c# tabtitle="C# [Windows-specific]" %} +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Text; + //Load the PDF document with images PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Disable the incremental update @@ -618,6 +640,15 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Graphics +Imports System +Imports System.Collections.Generic +Imports System.Diagnostics +Imports System.Drawing +Imports System.Text +Imports Syncfusion.Pdf.Parsing + 'Load the PDF document which consist of images Dim loadedDocument As New PdfLoadedDocument("Input.pdf") From 008eac0c8ac8b63c222b604a84e760c9980aacb5 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Tue, 7 Oct 2025 18:32:25 +0530 Subject: [PATCH 09/11] 985481-1: Resolved CI failures. --- .../PDF/PDF-Library/NET/Working-with-Bookmarks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md index 76702cc24..0542bde74 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Bookmarks.md @@ -5,7 +5,7 @@ platform: document-processing control: PDF documentation: UG --- -# Working with Bookmarks +# Working with Bookmarks in PDF Essential® PDF provides support to insert, remove and modify the bookmarks in the PDF Document. From 3bd0281646657317f80ee197721ee764ad8bd72e Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Tue, 7 Oct 2025 19:18:27 +0530 Subject: [PATCH 10/11] 985481-1: Resolved given feedback --- .../PDF/PDF-Library/NET/Merge-Documents.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md index 90372a57a..d2a572881 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md +++ b/Document-Processing/PDF/PDF-Library/NET/Merge-Documents.md @@ -157,6 +157,7 @@ Essential® PDF provides support for importing the pages from one {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Importing-pages-from-one-document-another-document/.NET/Importing-pages-from-one-document-another-document/Program.cs" %} using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Load the PDF document. PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); @@ -177,6 +178,7 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Load the PDF document. PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); @@ -196,6 +198,7 @@ lDoc.Close(true) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing 'Load the PDF document Dim lDoc As New PdfLoadedDocument("file1.pdf") @@ -222,6 +225,7 @@ You can import multiple pages from an existing document by using [ImportPageRang {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Import-multiple-pages-from-an-existing-PDF/.NET/Import-multiple-pages-from-an-existing-PDF/Program.cs" %} using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Load the PDF document. PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); @@ -242,6 +246,7 @@ lDoc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Loads PDF document. PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); @@ -261,6 +266,7 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing 'Loads PDF document Dim lDoc As New PdfLoadedDocument("file1.pdf") @@ -287,6 +293,7 @@ You can also import pages from multiple documents and arrange the pages by using {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Merge%20PDFs/Import-pages-from-multiple-documents-and-arrange-pages/.NET/Import-pages-from-multiple-documents-and-arrange-pages/Program.cs" %} using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Loads document. PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); @@ -310,6 +317,7 @@ lDoc2.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Loads document. PdfLoadedDocument lDoc = new PdfLoadedDocument("file1.pdf"); @@ -333,6 +341,7 @@ lDoc2.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing 'Loads a document Dim lDoc As New PdfLoadedDocument("file1.pdf") @@ -374,6 +383,7 @@ You can split a large PDF document into multiple documents using [Split](https:/ {% highlight c# tabtitle="C# [Windows-specific]" %} using Syncfusion.Pdf; +using Syncfusion.Pdf.Parsing; //Loads the PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("large.pdf"); @@ -387,6 +397,7 @@ loadedDocument.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Imports Syncfusion.Pdf +Imports Syncfusion.Pdf.Parsing 'Loads the PDF document Dim loadedDocument As New PdfLoadedDocument("large.pdf") From 2156f8876a32148f34de3410c0206a9e1743bbfd Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Tue, 7 Oct 2025 19:56:40 +0530 Subject: [PATCH 11/11] 985481-1: Resolved given feedback. --- .../PDF/PDF-Library/NET/PdfGrid.md | 14 +----- .../PDF/PDF-Library/NET/PdfLightTable.md | 23 +--------- .../NET/Working-with-Annotations.md | 43 ++++++++++++++----- .../NET/Working-with-Attachments.md | 3 -- .../NET/Working-with-Compression.md | 16 ------- 5 files changed, 35 insertions(+), 64 deletions(-) diff --git a/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md b/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md index d7ab7252d..7d35bd92a 100644 --- a/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md +++ b/Document-Processing/PDF/PDF-Library/NET/PdfGrid.md @@ -29,10 +29,8 @@ The following code sample illustrates how to create a simple table from a data s {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Table/PdfGrid/Create-table-from-data-source-in-a-PDF/.NET/Create-table-from-data-source-in-a-PDF/Program.cs" %} -using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Grid; -using System.Data; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -63,10 +61,8 @@ doc.Close(true); {% highlight c# tabtitle="C# [Windows-specific]" %} -using System.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Grid; -using System.Data; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -97,10 +93,8 @@ doc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Imports Syncfusion.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Grid -Imports System.Data 'Create a new PDF document. Dim doc As PdfDocument = New PdfDocument() @@ -169,7 +163,7 @@ pdfGridRow.Cells[0].Value = "E01"; pdfGridRow.Cells[1].Value = "Clay"; pdfGridRow.Cells[2].Value = "$10,000"; //Draw the PdfGrid. -pdfGrid.Draw(pdfPage, Syncfusion.Drawing.PointF.Empty); +pdfGrid.Draw(pdfPage, PointF.Empty); //Save the PDF document. pdfDocument.Save("Output.pdf"); @@ -266,7 +260,6 @@ Refer to the following code sample to create a table using [PdfGrid](https://hel using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Grid; -using Syncfusion.Pdf.Parsing; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -302,7 +295,6 @@ doc.Close(true); using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Grid; -using Syncfusion.Pdf.Parsing; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -338,7 +330,6 @@ doc.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Graphics Imports Syncfusion.Pdf.Grid -Imports Syncfusion.Pdf.Parsing 'Create a new PDF document. Dim doc As New PdfDocument() @@ -841,7 +832,6 @@ using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Grid; -using System.Data; //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); @@ -887,7 +877,6 @@ using System.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Grid; -using System.Data; //Create a new PDF document. PdfDocument pdfDocument = new PdfDocument(); @@ -932,7 +921,6 @@ Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Graphics Imports Syncfusion.Pdf.Grid -Imports System.Data 'Create a new PDF document. Dim pdfDocument As New PdfDocument() diff --git a/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md b/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md index 54ccf59d1..7b9f4de0c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md +++ b/Document-Processing/PDF/PDF-Library/NET/PdfLightTable.md @@ -27,7 +27,6 @@ The following code sample illustrates how to create a simple table from a data s using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Tables; -using System.Data; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -45,7 +44,7 @@ IEnumerable table = data; //Assign data source. pdfLightTable.DataSource = table; //Draw PdfLightTable. -pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(0, 0)); +pdfLightTable.Draw(page, new PointF(0, 0)); //Save the PDF document. doc.Save("Output.pdf"); @@ -59,7 +58,6 @@ doc.Close(true); using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Tables; -using System.Data; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -93,7 +91,6 @@ doc.Close(true); Imports Syncfusion.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Tables -Imports System.Data 'Create a new PDF document. Dim doc As New PdfDocument() @@ -139,7 +136,6 @@ The following code illustrates how to add the data directly into the [PdfLightTa using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Tables; using Syncfusion.Pdf; -using System.Reflection.Metadata; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -174,7 +170,6 @@ doc.Close(true); using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Tables; using Syncfusion.Pdf; -using System.Reflection.Metadata; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -209,7 +204,6 @@ doc.Close(true); Imports Syncfusion.Pdf.Graphics Imports Syncfusion.Pdf.Tables Imports Syncfusion.Pdf -Imports System.Reflection.Metadata 'Create a new PDF document. Dim doc As New PdfDocument() @@ -255,7 +249,6 @@ using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Parsing; using Syncfusion.Pdf.Tables; using Syncfusion.Pdf; -using System.Reflection.Metadata; //Load the PDF document. PdfLoadedDocument doc = new PdfLoadedDocument("Input.pdf"); @@ -291,7 +284,6 @@ using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Parsing; using Syncfusion.Pdf.Tables; using Syncfusion.Pdf; -using System.Reflection.Metadata; //Load a PDF document. PdfLoadedDocument doc = new PdfLoadedDocument("input.pdf"); @@ -328,7 +320,6 @@ Imports Syncfusion.Pdf.Graphics Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Pdf.Tables Imports Syncfusion.Pdf -Imports System.Reflection.Metadata 'Load a PDF document. Dim doc As New PdfLoadedDocument("input.pdf") @@ -375,8 +366,6 @@ The following code sample illustrates how to customize the cell properties in `` using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Tables; -using System.Data.Common; -using System.Reflection.Metadata; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -423,8 +412,6 @@ doc.Close(true); using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Tables; -using System.Data.Common; -using System.Reflection.Metadata; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -472,8 +459,6 @@ doc.Close(true); Imports Syncfusion.Pdf.Graphics Imports System.Data.Common Imports Syncfusion.Pdf.Tables -Imports Syncfusion.Pdf -Imports System.Reflection.Metadata 'Create a new PDF document. Dim doc As New PdfDocument() @@ -700,7 +685,6 @@ You can download a complete working sample from [GitHub](https://github.com/Sync using Syncfusion.Pdf.Tables; using Syncfusion.Pdf; -using System.Reflection.Metadata; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -760,7 +744,6 @@ private void pdfLightTable_BeginRowLayout(object sender, BeginRowLayoutEventArgs using Syncfusion.Pdf.Tables; using Syncfusion.Pdf; -using System.Reflection.Metadata; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -824,7 +807,6 @@ private void pdfLightTable_BeginRowLayout(object sender, BeginRowLayoutEventArgs {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Imports System.Reflection.Metadata Imports Syncfusion.Pdf.Tables Imports Syncfusion.Pdf @@ -894,7 +876,6 @@ The following code sample illustrates how to customize the column in [PdfLightTa using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Tables; -using System.Data.Common; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -940,7 +921,6 @@ doc.Close(true); using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Tables; -using System.Data.Common; //Create a new PDF document. PdfDocument doc = new PdfDocument(); @@ -986,7 +966,6 @@ doc.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Graphics Imports Syncfusion.Pdf.Tables -Imports System.Data.Common 'Create a new PDF document. Dim doc As New PdfDocument() diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md index d334e74e6..9a436c64c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md @@ -119,6 +119,7 @@ To add [PdfPopupAnnotation](https://help.syncfusion.com/cr/document-processing/S using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf"); @@ -147,6 +148,7 @@ document.Close(true); using System.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Creates a new PDF document. PdfLoadedDocument document = new PdfLoadedDocument("input.pdf"); @@ -173,7 +175,8 @@ document.Close(true); Imports System.Drawing Imports Syncfusion.Pdf -Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf. +Imports Syncfusion.Pdf.Parsing 'Creates a new PDF document. Dim document As New PdfLoadedDocument("input.pdf") @@ -1010,6 +1013,7 @@ using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); @@ -1036,6 +1040,7 @@ using System.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Loads the document PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); @@ -1062,6 +1067,7 @@ Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing 'Loads the document Dim lDoc As New PdfLoadedDocument("Input.pdf") @@ -1740,6 +1746,7 @@ using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); @@ -1768,6 +1775,7 @@ using System.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf"); @@ -1795,6 +1803,7 @@ Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") @@ -3556,6 +3565,7 @@ loadedDocument.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") @@ -3638,6 +3648,7 @@ loadedDocument.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") @@ -3727,6 +3738,7 @@ loadedDocument.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("PopupAnnotation.pdf") @@ -3821,6 +3833,7 @@ loadedDocument.Close(); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing 'Load the existing PDF document. Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/Input.pdf") @@ -3900,6 +3913,7 @@ loadedDocument.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") @@ -3956,6 +3970,7 @@ loadedDocument.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing 'Load the existing PDF document Dim loadedDocument As New PdfLoadedDocument("input.pdf") @@ -4027,6 +4042,7 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing ' Load the PDF document from a file path Dim loadedDocument As New PdfLoadedDocument("C:\path\to\input.pdf") @@ -4201,7 +4217,7 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Imports Syncfusion.Pdf.Parsing; +Imports Syncfusion.Pdf.Parsing 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") @@ -4254,7 +4270,7 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Imports Syncfusion.Pdf.Parsing; +Imports Syncfusion.Pdf.Parsing 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") @@ -4303,7 +4319,7 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Imports Syncfusion.Pdf.Parsing; +Imports Syncfusion.Pdf.Parsing 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") @@ -4352,7 +4368,7 @@ lDoc.Close(true); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Imports Syncfusion.Pdf.Parsing; +Imports Syncfusion.Pdf.Parsing 'Loads the document Dim lDoc As New PdfLoadedDocument("input.pdf") @@ -4452,7 +4468,7 @@ pdfLoadedDocument.Close(true); Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive -Imports Syncfusion.Pdf.Parsing; +Imports Syncfusion.Pdf.Parsing ' Load the PDF document from a file stream Dim pdfLoadedDocument As New PdfLoadedDocument("Input.pdf") @@ -4573,7 +4589,7 @@ pdfLoadedDocument.Close(true); Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive -Imports Syncfusion.Pdf.Parsing; +Imports Syncfusion.Pdf.Parsing ' Load the PDF document from a file stream Dim pdfLoadedDocument As New PdfLoadedDocument("Input.pdf") @@ -4695,7 +4711,7 @@ pdfLoadedDocument.Close(true); Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive -Imports Syncfusion.Pdf.Parsing; +Imports Syncfusion.Pdf.Parsing ' Load the PDF document from a file stream Dim pdfLoadedDocument As New PdfLoadedDocument("Input.pdf") @@ -4809,7 +4825,7 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf")) Imports System.Drawing Imports Syncfusion.Pdf -Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing ' Load the PDF document from the input stream Using loadedDocument As New PdfLoadedDocument("Input.pdf") @@ -4906,7 +4922,7 @@ using (PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf")) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Imports System.Drawing +Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive @@ -5200,6 +5216,7 @@ To add comments [PdfPopupAnnotation](https://help.syncfusion.com/cr/document-pro using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); @@ -5235,6 +5252,7 @@ lDoc.Close(true); using System.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); @@ -5270,6 +5288,7 @@ ldoc.Close(true); Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing 'Load the PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") @@ -5486,6 +5505,7 @@ To add the review status [PdfAnnotationState](https://help.syncfusion.com/cr/do using Syncfusion.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; //Load the PDF document PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf"); @@ -5521,6 +5541,7 @@ lDoc.Close(true); using System.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Interactive; +Using Syncfusion.Pdf.Parsing; //Load the PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf"); @@ -5556,6 +5577,7 @@ ldoc.Close(true); Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive +Imports Syncfusion.Pdf.Parsing 'Load the existing PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf") @@ -6694,6 +6716,7 @@ Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Interactive Imports Syncfusion.Pdf.Graphics +Imports Syncfusion.Pdf.Parsing ' Load an existing document. Dim document As New PdfLoadedDocument("Input.pdf") diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md index eb610a91f..8a6dda589 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Attachments.md @@ -332,7 +332,6 @@ using Syncfusion.Pdf.Interactive; using Syncfusion.Pdf.Parsing; using Syncfusion.Pdf; using Syncfusion.Drawing; -using System.Reflection.Metadata; // Load the existing PDF file PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); @@ -387,7 +386,6 @@ using Syncfusion.Pdf.Interactive; using Syncfusion.Pdf.Parsing; using Syncfusion.Pdf; using System.Drawing; -using System.Reflection.Metadata; // Load the existing PDF file PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); @@ -442,7 +440,6 @@ Imports Syncfusion.Pdf.Interactive Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Pdf Imports System.Drawing -Imports System.Reflection.Metadata ' Load the existing PDF file Dim loadedDocument As New PdfLoadedDocument("Input.pdf") diff --git a/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md b/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md index 4ec7a5707..9adf6900c 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md +++ b/Document-Processing/PDF/PDF-Library/NET/Working-with-Compression.md @@ -533,11 +533,7 @@ Essential® PDF allows you to compress/change the quality of the i using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; -using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; -using System.Text; //Create a new PDF document. PdfDocument document = new PdfDocument(); @@ -564,11 +560,7 @@ document.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Graphics -Imports System -Imports System.Collections.Generic -Imports System.Diagnostics Imports System.Drawing -Imports System.Text 'Create a new PDF document. Dim document As New PdfDocument() @@ -604,11 +596,7 @@ You can compress the images in an existing PDF document by extract the images us using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Parsing; -using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; -using System.Text; //Load the PDF document with images PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); @@ -642,11 +630,7 @@ loadedDocument.Close(true); Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Graphics -Imports System -Imports System.Collections.Generic -Imports System.Diagnostics Imports System.Drawing -Imports System.Text Imports Syncfusion.Pdf.Parsing 'Load the PDF document which consist of images