Skip to content

Instantly share code, notes, and snippets.

@juanonsoftware
Last active December 23, 2024 18:33
Show Gist options
  • Select an option

  • Save juanonsoftware/49002c57fa54448e70216981718936ab to your computer and use it in GitHub Desktop.

Select an option

Save juanonsoftware/49002c57fa54448e70216981718936ab to your computer and use it in GitHub Desktop.
C# How to get text from PDF file with iTextSharp
// source is a byte array
using (var reader = new PdfReader(source))
{
using (var output = new StringWriter())
{
for (int i = 1; i <= reader.NumberOfPages; i++)
{
output.WriteLine(PdfTextExtractor.GetTextFromPage(reader, i));
}
return output.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment