Extract info about PDF file in ASP.NET, C#, VB.NET with PDF Extractor SDK

The samples below show how to extract metadata from PDF files in Visual C# and Visual Basic .NET with PDF Extractor SDK. You can extract information about file author, file description, number of pages, protection status, and more.

ASP.NET

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Bytescout.PDFExtractor;
 
namespace ExtractInfo
{
	public partial class _Default : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			// This test file will be copied to the project directory on the pre-build event (see the project properties).
			String inputFile = Server.MapPath("sample1.pdf");
 
			// Create Bytescout.PDFExtractor.InfoExtractor instance
			InfoExtractor extractor = new InfoExtractor();
			extractor.RegistrationName = "demo";
			extractor.RegistrationKey = "demo";
 
			// Load sample PDF document
			extractor.LoadDocumentFromFile(inputFile);
 
			Response.Clear();
			Response.ContentType = "text/html";
 
			Response.Write("Author: " + extractor.Author + "
");
			Response.Write("Creator: " + extractor.Creator + "
");
			Response.Write("Producer: " + extractor.Producer + "
");
			Response.Write("Subject: " + extractor.Subject + "
");
			Response.Write("Title: " + extractor.Title + "
");
			Response.Write("CreationDate: " + extractor.CreationDate + "
");
			Response.Write("Keywords: " + extractor.Keywords + "
");
			Response.Write("Bookmarks: " + extractor.Bookmarks + "
");
			Response.Write("Encrypted: " + extractor.Encrypted + "
");
 
			Response.End();
		}
	}
}

 

C#

using System;
using Bytescout.PDFExtractor;
 
namespace ExtractInfo
{
class Program
{
static void Main(string[] args)
{
// Create Bytescout.PDFExtractor.InfoExtractor instance
InfoExtractor extractor = new InfoExtractor();
extractor.RegistrationName = "demo";
extractor.RegistrationKey = "demo";
 
// Load sample PDF document
extractor.LoadDocumentFromFile("sample1.pdf");
 
Console.WriteLine("Author: " + extractor.Author);
Console.WriteLine("Creator: " + extractor.Creator);
Console.WriteLine("Producer: " + extractor.Producer);
Console.WriteLine("Subject: " + extractor.Subject);
Console.WriteLine("Title: " + extractor.Title);
Console.WriteLine("CreationDate: " + extractor.CreationDate);
Console.WriteLine("Keywords: " + extractor.Keywords);
Console.WriteLine("Bookmarks: " + extractor.Bookmarks);
Console.WriteLine("Encrypted: " + extractor.Encrypted);
 
Console.WriteLine();
Console.WriteLine("Press any key to continue...");
Console.ReadLine();
}
}
}

 

VB.NET

Imports Bytescout.PDFExtractor
 
Class Program
Friend Shared Sub Main(args As String())
 
' Create Bytescout.PDFExtractor.InfoExtractor instance
Dim extractor As New InfoExtractor()
extractor.RegistrationName = "demo"
extractor.RegistrationKey = "demo"
 
' Load sample PDF document
extractor.LoadDocumentFromFile("sample1.pdf")
 
Console.WriteLine("Author: " + extractor.Author)
Console.WriteLine("Creator: " + extractor.Creator)
Console.WriteLine("Producer: " + extractor.Producer)
Console.WriteLine("Subject: " + extractor.Subject)
Console.WriteLine("Title: " + extractor.Title)
Console.WriteLine("CreationDate: " + extractor.CreationDate)
Console.WriteLine("Keywords: " + extractor.Keywords)
Console.WriteLine("Bookmarks: " + extractor.Bookmarks)
Console.WriteLine("Encrypted: " + extractor.Encrypted.ToString)
 
Console.WriteLine()
Console.WriteLine("Press any key to continue...")
Console.ReadLine()
 
End Sub
End Class
Filed in: PDF Extractor SDK