I have been using the free version for reading the text from pdf files. It worked OK with a few pdf files except a particular one (please see attachment).
The Code I used:
- Code: Select all
var sb = new StringBuilder();
var doc = new PdfDocument();
doc.LoadFromFile(filePath);
foreach (PdfPageBase page in doc.Pages)
{
sb.Append(page.ExtractText()); //it throws exception here
}
doc.Close();
The exception I got:
- Code: Select all
System.ArgumentException
HResult=0x80070057
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Drawing2D.GraphicsPath.GetLastPoint()
at Spire.Pdf.General.Render.Font.Type1CFont.ᜀ(ᜀ A_0, GraphicsPath A_1, FlPoint A_2)
at Spire.Pdf.General.Render.Font.Type1CFont.ᜀ(Int32 A_0, Int32 A_1)
at Spire.Pdf.General.Render.Font.OutlineFont.GetGlyph(Char src, String name, TypeEncodingCmap type)
at Spire.Pdf.General.Render.Font.PDFFontViewer.GetCachedGlyph(Char src, String name, TypeEncodingCmap type)
at Spire.Pdf.General.Render.Font.PDFFontEncoding.GetGlyphs(PDFFontViewer font, String text)
at Spire.Pdf.General.Render.Font.PDFFontViewer.GetGlyphs(String text)
at sprᷧ.ᜀ(String A_0, Single A_1, Single A_2)
at Spire.Pdf.PdfPageBase.ᜀ(sprᩘ A_0, PdfPageResources A_1, Boolean A_2)
at Spire.Pdf.PdfPageBase.ExtractText(Boolean keepWhiteSpace)
Thanks,
Steve