This could be a problem when you don't have the rights to access Blue Prism root folder, so with the great Antonio Durante, we find a way to solve this problem using another forgotten beauty: the reflection.
Here you can download a little project in Visual Studio, which is composed of some lines of code which simply get the content of a editable PDF and return as a DataTable containing as many rows as lines of text found in the PDF.
This piece of code uses iTextSharp.dll to do the work so we have a depencency here.
public class Program { public Program(string blablabla) { // This is a fake constructor } public static DataTable LoadPdf(string path) { Listdata = PdfHelper.ExtractTextFromInvoice(path); DataTable table = new DataTable(); table.Columns.Add("Row", typeof(string)); DataRow row11 = table.NewRow(); row11["Row"] = "Yeah 1.1 version as well"; table.Rows.Add(row11); foreach (string item in data) { DataRow row = table.NewRow(); row["Row"] = item; table.Rows.Add(row); } return table; } static void Main(string[] args) { DataTable t = LoadPdf(@"C:\Users\v.valrosso\Downloads\test1.pdf"); } }
The code here is very simple, but just to see again how reflection work, i write also this code to test everything. As you can see i load only the assembly in a folder where you can find also the referenced DLL (i've used directly the Debug output folder of the dummy project)
class Program { static void Main(string[] args) { string assemblyPath = @"C:\TFS\Test\Code\Poc.ReferencingCode\bin\Debug\Poc.ReferencingCode.dll"; Assembly asm = Assembly.LoadFrom(assemblyPath); //Assembly asm = Assembly.Load(File.ReadAllBytes(assemblyPath)); Type t = asm.GetType("Poc.ReferencingCode.Program"); var methodInfo = t.GetMethod("LoadPdf", new Type[] { typeof(string) }); if (methodInfo == null) { // never throw generic Exception - replace this with some other exception type throw new Exception("No such method exists."); } object o = Activator.CreateInstance(t); object[] parameters = new object[1]; parameters[0] = @"C:\Users\v.valrosso\Downloads\test1.pdf"; DataTable r = (DataTable)methodInfo.Invoke(o, parameters); Console.WriteLine(r); } }
After that we can just play with BP creating a new VBO just pasting the code and ... les jeux sont faits.
Just a warning, BP locks the DLL so you have think something more smart (Antonio and I have developed something very very smart but sadly i cannot show you because of it's top secret).
As usual thanks to my colleague and friend Antonio Durante for the wonderful work we make together everyday.
Hi,
ReplyDeletethanks for your help.
I just wonder if BluePrism can use the dll after inserting it into the folder even without permission of use of data in this folder?
So usually I don't have permission, someone with permission inserts the dll and afterwards BluePrism is supposed to use the dll.
Thanks you
Best regards,
Harald
Hi Harald, thank you for your message.
DeleteIf you have at least read permissions, i don't see any problems ;)
An automation anywhere also load a dll that createby java classes....
ReplyDeleteI create a dll file of jar file but when i loaded into automation anywhere it can not show the classes and mehtod of that dll in automation anywhere...but .net dll work properly ...can you solve my problem,
How is this being accomplished in v6.3? I'd love to see a sample project in BP, rather than vs.
ReplyDeleteHi Vesnak, if needed i can provide you an example. It depends on how many people ask me this kind of post :)
DeleteHey Valerio. Sorry for the late reply, i was monitoring skype for your response. I would love fo ryou to send me an example.
Delete