Created
February 12, 2025 22:05
-
-
Save bjoerntx/f944f6c55e4e7b04b79e31f25eb696a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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