Hi there
I would like to read pdf Invoices. With catchwords it‘s possible to get InvoiceNo, Date and Invoice total. Now i try to fetch the positions.
Did you have an tip how to realize it?
// Create a new PdfDocument object
PdfDocument pdf = new PdfDocument();
// Load the PDF file from the specified path
pdf.LoadFromFile(@"..\SpirePDF.pdf");
// Iterate through each page in the PDF document
foreach (PdfPageBase page in pdf.Pages)
{
// Create a new PdfTextFinder object for the current page
PdfTextFinder finder = new PdfTextFinder(page);
// Create a new PdfTextFindOptions object to specify search options
PdfTextFindOptions options = new PdfTextFindOptions();
// Set the search parameter to ignore case
options.Parameter = TextFindParameter.IgnoreCase;
// Set the search options for the finder
finder.Options = options;
// Search for the specified keyword "keywords" in the text of the current page
var fragments = finder.Find("keywords");
// Iterate through each found fragment
foreach (PdfTextFragment fragment in fragments)
{
// Get the position of the first occurrence of the keyword in the fragment
PointF found = fragment.Positions[0];
// Print the position of the keyword to the console
Console.WriteLine(found);
}
}
// Create a new PdfDocument object
PdfDocument pdf = new PdfDocument();
// Load the PDF file from the specified path
pdf.LoadFromFile(@"..\SpirePDF.pdf");
// Get the first page of the PDF document
PdfPageBase page = pdf.Pages[0];
// Get the actual size of the page
var centerPosition = page.ActualSize;
// Calculate the center position of the page
double centerX = centerPosition.Width / 2;
double centerY = centerPosition.Height / 2;
// Print the center position to the console
Console.WriteLine("Center position:({0}, {1})", centerX, centerY);