Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ N> 1. The .NET Standard assemblies are available at the following Essential Stud
{Installed directory}\Syncfusion<sup>&reg;</sup>\Essential Studio{Product version}\precompiledassemblies\{Product version}\
N> 2. Syncfusion<sup>&reg;</sup> components are also available on [nuget.org](https://www.nuget.org/packages?q=syncfusion).
N> 3. Starting with **v16.2.0.x**, if you reference Syncfusion<sup>&reg;</sup> assemblies from the trial setup or from the NuGet feed, you must also include a license key in your projects. Refer to the [licensing overview](https://help.syncfusion.com/common/essential-studio/licensing/overview) to learn how to register the Syncfusion<sup>&reg;</sup> license key in your application.
N> 4. For .NET Core, .NET 5+, .NET MAUI, WinUI, and Blazor, Syncfusion recommends using the NuGet packages for easier version management and dependency resolution.

## Converting HTML to PDF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords: maui os save pdf, maui os load pdf, c# save pdf, c# load pdf
The [.NET MAUI PDF library](https://www.syncfusion.com/document-sdk/net-pdf-library) is used to create, read, and edit PDF documents programmatically without the dependency on Adobe Acrobat. Using this library, you can **open and save a PDF document in .NET MAUI**.

**Prerequisites:**
To create .NET Multi-platform App UI (.NET MAUI) apps, you need the latest versions of Visual Studio 2022 and .NET 6. For more details, refer [here](https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-7.0&tabs=vswin).
To create .NET Multi-platform App UI (.NET MAUI) apps, you need the latest versions of Visual Studio 2022 and .NET 8. For more details, refer [here](https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-7.0&tabs=vswin).

## Steps to open and save PDF documents programmatically in .NET MAUI

Expand Down Expand Up @@ -219,6 +219,4 @@ Download the helper files from this [link](https://www.syncfusion.com/downloads/
</tr>
</table>

Click [here](https://www.syncfusion.com/document-sdk/net-pdf-library) to explore the rich set of Syncfusion<sup>&reg;</sup> PDF library features.


Click [here](https://www.syncfusion.com/document-sdk/net-pdf-library) to explore the rich set of Syncfusion<sup>&reg;</sup> PDF library features.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ The [Blazor PDF library](https://www.syncfusion.com/document-sdk/net-pdf-library

**Prerequisites:**

* Visual Studio 2019 Preview
* Install the [.NET Core SDK 3.1 Preview](https://dotnet.microsoft.com/en-us/download/dotnet/3.1)
* Visual Studio 2022 Preview
* Install the [.NET Core SDK](https://dotnet.microsoft.com/en-us/download/dotnet)

**Creating a Blazor project**

* Enable Visual Studio to use preview SDKs.
* Open Tools > Options in the menu bar.
* Open the Projects and Solutions node. Open the .NET Core tab.
* Check the box for Use previews of the .NET Core SDK and click OK.
* Restart the Visual Studio 2019.
* Restart the Visual Studio 2022.

## Server app

Expand Down Expand Up @@ -404,6 +404,6 @@ By executing the program, you will get the **PDF document** as follows.

N> Even though PDF library works in WASM app, it is recommended to use server deployment. Since the WASM app deployment increases the application payload size.

Kindly explore the [supported and unsupported features of PDF library in Blazor](https://www.syncfusion.com/document-processing/pdf-framework/blazor/pdf-library).
Kindly explore the [supported and unsupported features of PDF library](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/supported-and-unsupported-features).

Click [here](https://www.syncfusion.com/document-processing/pdf-framework/blazor) to explore the rich set of Syncfusion<sup>&reg;</sup> PDF library features.
Click [here](https://www.syncfusion.com/document-sdk/net-pdf-library) to explore the rich set of Syncfusion<sup>&reg;</sup> PDF library features.
94 changes: 48 additions & 46 deletions Document-Processing/PDF/PDF-Library/NET/Open-PDF-file.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
title: Open PDF file in C# and VB.NET | Syncfusion
description: This page describes how to open PDF file from or to file system, and stream in C# and VB.NET using Syncfusion .NET PDF library.
description: This page describes how to open a PDF file from the file system, a stream, or a byte array in C# and VB.NET using the Syncfusion .NET PDF library.
platform: document-processing
control: PDF
documentation: UG
---
# Open PDF file in C# and VB.NET

## Namespace required
The following namespaces of Essential<sup><sup>&reg;</sup></sup> PDF need to be included in your application to load the PDF document.
## Namespaces required

The following namespace of the Essential<sup>&reg;</sup> PDF library must be included in your application to load a PDF document.

{% tabs %}

Expand All @@ -34,116 +35,116 @@ Imports Syncfusion.Pdf.Parsing

## Opening an existing PDF document

You can open an existing PDF document by using the [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html) class. The following example shows how to load an existing document from physical path.
You can open an existing PDF document by using the [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html) class. The following example shows how to load an existing document from a physical path on the file system.

{% tabs %}

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an existing PDF document from stream through constructor of `PdfLoadedDocument` class.
//Open an existing PDF document from a file path through the `PdfLoadedDocument` constructor.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf");

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//Open an existing document from file system.
//Open an existing document from the file system.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Open an existing document from file system.
'Open an existing document from the file system.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")

{% endhighlight %}

{% endtabs %}

## Opening an existing PDF document from Stream
## Opening an existing PDF document from a stream

You can open an existing document from stream by using [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html) class as shown below.
You can open an existing document from a stream by using the [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html) class as shown below.

{% tabs %}

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an existing PDF document from stream through constructor of `PdfLoadedDocument` class.
//Open an existing PDF document from a stream through the `PdfLoadedDocument` constructor.
FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream);

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}
{% highlight c# tabtitle="C# [Windows-specific]" %}

//Opens an existing document from stream.
//Open an existing document from a stream.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream);

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Opens an existing document from stream.
'Open an existing document from a stream.
Dim loadedDocument As New PdfLoadedDocument(inputPDFStream)

{% endhighlight %}

{% endtabs %}

## Opening an existing PDF document from byte array
## Opening an existing PDF document from a byte array

You can open an existing document from byte array by using [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html) class as shown in the below code example.
You can open an existing document from a byte array by using the [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html) class as shown in the following code example.

{% tabs %}

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an existing document from byte array.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFByteArray);
//Open an existing document from a byte array.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFByteArray);

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//Open an existing document from byte array.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFByteArray);
//Open an existing document from a byte array.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFByteArray);

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Opens an existing document from byte array.
'Open an existing document from a byte array.
Dim loadedDocument As New PdfLoadedDocument(inputPDFByteArray)

{% endhighlight %}

{% endtabs %}

## Opening an Encrypted PDF document
## Opening an encrypted PDF document

You can open an existing encrypted PDF document from either the file system or the stream or the byte array using [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html#Syncfusion_Pdf_Parsing_PdfLoadedDocument__ctor_System_Byte___System_String_) class as shows in the below code example.
You can open an existing encrypted PDF document from the file system, a stream, or a byte array using the [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html#Syncfusion_Pdf_Parsing_PdfLoadedDocument__ctor_System_Byte___System_String_) class, as shown in the following code examples.

{% tabs %}

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an encrypted PDF document from stream through constructor of `PdfLoadedDocument` class.
//Open an encrypted PDF document from a file path through the `PdfLoadedDocument` constructor.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf", "password");

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//Open an existing encrypted document from disk.
//Open an existing encrypted document from the file system.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf", "password");

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Open an existing encrypted document from disk.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf","password")
'Open an existing encrypted document from the file system.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf", "password")

{% endhighlight %}

Expand All @@ -153,23 +154,23 @@ Dim loadedDocument As New PdfLoadedDocument("Input.pdf","password")

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an encrypted PDF document from stream through constructor of `PdfLoadedDocument` class.
//Open an encrypted PDF document from a stream through the `PdfLoadedDocument` constructor.
FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream, "password");

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//Open an existing encrypted document from byte array.
//Open an existing encrypted document from a stream.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream, "password");

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Open an existing encrypted document from stream.
Dim loadedDocument As New PdfLoadedDocument(inputPDFStream,"password")
'Open an existing encrypted document from a stream.
Dim loadedDocument As New PdfLoadedDocument(inputPDFStream, "password")

{% endhighlight %}

Expand All @@ -179,50 +180,50 @@ Dim loadedDocument As New PdfLoadedDocument(inputPDFStream,"password")

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an existing encrypted document from byte array.
//Open an existing encrypted document from a byte array.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFByteArray, "password");

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//Open an existing encrypted document from byte array.
//Open an existing encrypted document from a byte array.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFByteArray, "password");

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Open an existing encrypted document from byte array.
Dim loadedDocument As New PdfLoadedDocument(inputPDFByteArray,"password")
'Open an existing encrypted document from a byte array.
Dim loadedDocument As New PdfLoadedDocument(inputPDFByteArray, "password")

{% endhighlight %}

{% endtabs %}

## Opening a corrupted PDF document

You can open a corrupted PDF document from either the file system or the stream or the byte array using the [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html#Syncfusion_Pdf_Parsing_PdfLoadedDocument__ctor_System_Byte___System_String_System_Boolean_) as shown below.
You can open a corrupted PDF document from the file system, a stream, or a byte array using the [PdfLoadedDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedDocument.html#Syncfusion_Pdf_Parsing_PdfLoadedDocument__ctor_System_Byte___System_String_System_Boolean_) class, as shown below. The `OpenAndRepair` constructor enables repair mode so that the library can attempt to recover the document's structure.

{% tabs %}

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an existing corrupted PDF document from stream through constructor of `PdfLoadedDocument` class.
//Open an existing corrupted PDF document from a file path through the `PdfLoadedDocument` constructor (OpenAndRepair overload).
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"Input.pdf", true);

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//Open an existing corrupted document from disk.
//Open an existing corrupted document from the file system.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf", true);

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Open an existing corrupted document from disk.
'Open an existing corrupted document from the file system.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf", True)

{% endhighlight %}
Expand All @@ -233,22 +234,22 @@ Dim loadedDocument As New PdfLoadedDocument("Input.pdf", True)

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an existing corrupted PDF document from stream through constructor of `PdfLoadedDocument` class.
//Open an existing corrupted PDF document from a stream through the `PdfLoadedDocument` constructor (OpenAndRepair overload).
FileStream inputPDFStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream, true);

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//Open an existing corrupted document from stream.
//Open an existing corrupted document from a stream.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFStream, true);

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Open an existing corrupted document from stream.
'Open an existing corrupted document from a stream.
Dim loadedDocument As New PdfLoadedDocument(inputPDFStream, True)

{% endhighlight %}
Expand All @@ -259,26 +260,27 @@ Dim loadedDocument As New PdfLoadedDocument(inputPDFStream, True)

{% highlight c# tabtitle="C# [Cross-platform]" %}

//Open an existing corrupted document from byte array.
//Open an existing corrupted document from a byte array.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFByteArray, true);

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//Open an existing corrupted document from byte array.
//Open an existing corrupted document from a byte array.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputPDFByteArray, true);

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Open an existing corrupted document from byte array.
'Open an existing corrupted document from a byte array.
Dim loadedDocument As New PdfLoadedDocument(inputPDFByteArray, True)

{% endhighlight %}

{% endtabs %}

N> 1. The OpenAndRepair overload is capable of resolving basic cross reference offset issues and cannot repair complex document corruption.
N> 2. Using this overload may cause performance delay when compared with other overloads, due to the repairing process.
N> 1. The OpenAndRepair overload can resolve basic cross-reference offset issues and cannot repair complex document corruption.
N> 2. Using this overload may cause a performance delay when compared with other overloads, due to the repair process.
N> 3. If the document is encrypted, supply the password as an additional constructor argument: `new PdfLoadedDocument("Input.pdf", "password", true)`.
Loading