Unable to load DLL 'pdfium.dll' or one of its dependencies

Yesterday I was experimenting with “headless” printing (i.e. without user interaction) of PDF to a defined printer.
Based on AI advice I used PdfiumViewer
I installed PdfiumViewer package and used the following code:

Using document = PdfDocument.Load(file)
    Using pd = document.CreatePrintDocument()
        pd.PrinterSettings = New System.Drawing.Printing.PrinterSettings()
        pd.PrinterSettings.PrinterName = "Microsoft Print to PDF"
        pd.PrinterSettings.PrintFileName = "new.pdf"
	    pd.PrinterSettings.PrintToFile = True
        pd.Print()
    End Using
End Using		

The code however throwned error “Unable to load DLL ‘pdfium.dll’ or one of its dependencies”

I was therefore searching for a package containing the missing DLL and finally installed bblanchon.PDFiumV8.Win32
It installed the missing library but I was till gettgin the same error.

Finally I copied pdfium.dll into C:\WIndows\Systems32 folder and the error vanished.
Same result I achieved by copying pdfium.dll into UiPath project root folder.

However, I am not sure if this is the right approach.
Can someone advise what I did wrong?

Thx

Hi!

Maybe this thread will help?
Using external dll library in a project - Help - UiPath Community Forum

This is very old thread. The location where UiPath store packages changed several times since then.

Thx

The first post is still relevant.

But not to my case. I am not creating library or custom activity.
Cheers

Sorry, but it makes sense that the above mentioned code would be in a library.

You really want packages and dependencies to be available in your Orchestrator Tenant if you want to be as flexible as possible, that way its possible for robots across different VM’s/environments to fetch it from a central location.

Here’s a link to the nuget package for PdfiumViewer NuGet Gallery | PdfiumViewer 2.13.0, if you upload it to your orchestrator you should be covered.

Well, you did not get the point.

The problem is not lack of PdfiumViewer package and the corresponding PdfiumViewer.dll.
The problem is missing pdfium.dll that is not part of PdfiumViewer package.
I installed package bblanchon.PDFiumV8.Win32 that contains the missing DLL but UiPath can not see the DLL for what ever reason

image

I see now!

Sometimes thursdays feel like mondays!

According to this stack overflow thread c# - Adding pdfium.dll to visual studio - Stack Overflow

They’ve solved the issue of the pdfium.dll not being available in the PdfiumViewer NuGet package by installing these as well:
NuGet Gallery | PdfiumViewer.Native.x86_64.v8-xfa 2018.4.8.256
NuGet Gallery | PdfiumViewer.Native.x86.v8-xfa 2018.4.8.256

So I guess in this instance the issue is not really related to UiPath specifically.
The .dll is simply not included in that package.

But I still don’t know why the .dll in bblanchon.PDFiumV8.Win32 is not showing up…

The problem is the structure of the package - this is I suppose the reason why UiPath can’t see it

I checked some nuget documentation

and it confirms the package has correct structure as it contains native libraries.

It seems UiPath doesn’t support such packages.

Cheers

1 Like