Spire.pdf library does not recognise text in attached file using method ExtractText().
Can you check?
This is entire action in ASP.NET that works on other pdfs:
- Code: Select all
public ActionResult Post([FromQuery] IFormFile file)
{
if (file == null || file.Length == 0)
{
return NoContent();
}
byte[] fileBytes = null;
using (var ms = new MemoryStream())
{
file.CopyTo(ms);
fileBytes = ms.ToArray();
}
StringBuilder content = new StringBuilder();
PdfDocument document = new PdfDocument();
if (fileBytes != null)
{
document.LoadFromBytes(fileBytes);
foreach (PdfPageBase page in document.Pages)
{
string pageText = page.ExtractText();
if (!string.IsNullOrEmpty(pageText) && !pageText.Equals(Environment.NewLine))
{
content.Append(pageText);
}
}
}
return Ok(content.ToString());
}
Best regards,
Filip