Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 12, 2025 22:05
Show Gist options
  • Save bjoerntx/f944f6c55e4e7b04b79e31f25eb696a5 to your computer and use it in GitHub Desktop.
Save bjoerntx/f944f6c55e4e7b04b79e31f25eb696a5 to your computer and use it in GitHub Desktop.
using TXTextControl.DocumentServer.PDF.Contents;
try
{
string pdfFilePath = "FormW9.pdf";
// Check if the file exists before processing
if (!File.Exists(pdfFilePath))
{
Console.WriteLine($"Error: File '{pdfFilePath}' not found.");
return;
}
// Load PDF lines
var pdfLines = new Lines(pdfFilePath);
// Find the target text
var trainLines = pdfLines.Find("Text Control, LLC");
// Check if any lines were found before accessing the index
if (trainLines.Count > 0)
{
Console.WriteLine(trainLines[0].Rectangle.ToString());
}
else
{
Console.WriteLine("Text not found in the PDF.");
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment