Detect if a PDF File is a Portfolio in C#/VB.NET

A PDF Portfolio can combine a wide range of file types such as Word, Excel, PDF and Image files, compared with merging files into a single PDF file, PDF Portfolio remains the individual identities of the files, and you can easily open, read, edit, and format each of them independently of the other files in the PDF Portfolio.

Spire.PDF allows developers to detect if a PDF file is a Portfolio programmatically using c# and vb.net. The following example uses a PDF Portfolio consists of an image, a PDF document and a Word file:

Detect if a PDF File is a Portfolio in C#, VB.NET

Detail steps:

Step 1: Instantiate a PdfDocument object and load the PDF file.

PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Portfolio.pdf");

Step 2: Detect if the PDF file is a Portfolio.

bool isPortfolio = pdf.IsPortfolio;
if (isPortfolio)
{
    Console.WriteLine("It's a Portfolio!");
}

Screenshot:

Detect if a PDF File is a Portfolio in C#, VB.NET

Full code:

[C#]
using System;
using Spire.Pdf;

namespace Detect_if_a_PDF_is_a_Portfolio
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile("Portfolio.pdf");

            bool isPortfolio = pdf.IsPortfolio;
            if (isPortfolio)
            {
                Console.WriteLine("It's a Portfolio!");
            }
            Console.ReadKey();
        }
    }
}
[VB.NET]
Imports Spire.Pdf

Namespace Detect_if_a_PDF_is_a_Portfolio
	Class Program
		Private Shared Sub Main(args As String())
			Dim pdf As New PdfDocument()
			pdf.LoadFromFile("Portfolio.pdf")

			Dim isPortfolio As Boolean = pdf.IsPortfolio
			If isPortfolio Then
				Console.WriteLine("It's a Portfolio!")
			End If
			Console.ReadKey()
		End Sub
	End Class
End Namespace