Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save documentprocessing/9c568f11789e4c68ee2963c70a16595d to your computer and use it in GitHub Desktop.

Select an option

Save documentprocessing/9c568f11789e4c68ee2963c70a16595d to your computer and use it in GitHub Desktop.
PDF Metadata Extraction in .NET
using UglyToad.PdfPig;
class PdfInspector
{
public void Inspect(string filePath)
{
using var document = PdfDocument.Open(filePath);
// Document metadata
Console.WriteLine($"Title: {document.Information.Title}");
Console.WriteLine($"Author: {document.Information.Author}");
Console.WriteLine($"Created: {document.Information.Created}");
// Font analysis
foreach (var page in document.GetPages())
{
var fonts = page.GetFonts();
Console.WriteLine($"Page {page.Number} uses {fonts.Count} fonts:");
foreach (var font in fonts)
{
Console.WriteLine($"- {font.Name} ({font.Type})");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment