I try to use a C# script to extract text from PDF (yeah again, my python script works but not in OB2 but outside, it’s not convenient, I would like to manage everything from OB2).
Here the script : Parsing PDF Files using iTextSharp (C#, .NET) | Square PDF .NET
It uses [iTextSharp](iText® 5 .NET, a .NET PDF library download | SourceForge.net.
I downloaded the NUGET file, unzipped it, and copied/pasted itextsharp.dll to OB2 exe file’s directory.
Here the code :
BLOCK:ConstantString
LABEL:path
value = "Factures\\20200926004520200GNXXSDCFAEAU00027920\\20191108225218000ARCHSCCFAEAU06819713.pdf"
=> VAR @path
ENDBLOCK
public static string ExtractTextFromPdf(string path)
{
using (PdfReader reader = new PdfReader(path))
{
StringBuilder text = new StringBuilder();
for (int i = 1; i <= reader.NumberOfPages; i++)
{
text.Append(PdfTextExtractor.GetTextFromPage(reader, i));
}
return text.ToString();
}
}
string pdftext = ExtractTextFromPdf(path);
I typed this in the “namespace” fields :
using itextsharp.text.pdf;
using itextsharp.text.pdf.parser;
(I deleted uppercases because DLL’s name has no ones, but even keeping them it still not works !)
And I got this error :
[IDLE] CompilationErrorException: error CS0246: The type or namespace name 'using itextsharp' could not be found (are you missing a using directive or an assembly reference?)