First, use the Document Reader module to read the PDF file and store the extracted content in a string variable (for example $PdfText).
Next, normalize the line breaks in the text, because PDF files can contain different line-ending formats. Replace all \r\n with \n, and then replace any remaining \r with \n. Store the result in a new string varaible, such as $NormalizedText.
After normalization, split the text into individual lines using String split with \n as the separator. This will give you a list of strings where each item represents one line from the PDF.
Then, loop over this list of lines. Inside the loop, trim each line and check whether it starts with the expected prefix, for examle Record No., using the startsWith function.
When a matching line is found, store it in a variable and exit the loop. If you only need the number itself, remove the Record No. prefix using replace and apply trim to get the final value.
This sounds like a job for a regular expression.
So, if you just want to extract the String "Record No. 54321" from the extracted text, I would use the RegexReplaceAll action from the Community Commons module.
For the Haystack, use the extracted text from your PDF
For the Replacement use '$1'
For the Needle Regex use
'^(?s).*?(Record No\. \d+).*$'
The string "Record No. 12345" or whatever the match is in your document will be returned in $vRecordNumber
I wrote a blog post on this technique a few years ago.
Extracting text in Mendix using RegexReplaceAll
I hope this helps.