Melvin Winthagen
Melvin Winthagen

Reputation: 347

Adding pdfium.dll to visual studio

For the application that I am making, I need to make use of the Pdfiumviewer package, which in turn requires you to add Pdfium itself, which is made available by Google. There is a "tutorial" on how to add pdfium on the official site but I haven't been able to decipher what exactly it is that I need to do.

At first glance, it appeared that you can get Pdfium via de Nuget Package Manager but it quickly became apparent that nuget doesn't add the actual dll to the project, and simply adding it as a reference doesn't work either. (throws 'reference could not be added' error). After this, I attempted to move the Pdfium dll to the bin/debug folder, but that still gives the same error. After doing some research, I found out that this dll is not supported by visual studio and you have to build/integrate it using the command line.

There are instructions on how to achieve this provided on https://pdfium.googlesource.com/pdfium/ https://github.com/pvginkel/PdfiumViewer/wiki/Building-PDFium

but after a few days of reading into it, I still have no clue what exactly I should and shouldn't do in the tutorial provided by google.

Therefor, I would like to kindly ask if anyone is either able to explain in plain English how to run through these steps, or if anyone knows a more user friendly tutorial to follow.

Upvotes: 19

Views: 31668

Answers (7)

yoni
yoni

Reputation: 191

follow this steps

  1. locate the path of your nuget package in the machine (see here)
  2. add next section (with relevant path) to the .csproj file of project that has reference to PdfiumViewer.dll :

<ItemGroup>
  <None Include="$(USERPROFILE)\.nuget\packages\pdfiumviewer.native.x86_64.v8-xfa\2018.4.8.256\Build\x64\pdfium.dll">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </None>
</ItemGroup>

  1. enjoy and thank the all-mighty

Upvotes: 0

So if you are using Winforms, my solution was installing these two packages

  1. https://www.nuget.org/packages/PdfiumViewer.Native.x86_64.v8-xfa/
  2. https://www.nuget.org/packages/PdfiumViewer.Native.x86.v8-xfa/

And then go to solution explorer, find the x86 where the pdfium.dll is located (bin\debug\x86) and then drag that into the References in the solution explorer in visual studio.

Upvotes: 0

Eric Barr
Eric Barr

Reputation: 4155

I had installed a Nuget package just before receiving this message. It turned out that the missing Pdfium dll was hidden deep in my project's packages folder, but for some reason it didn't get copied to the project's bin folder. After finding the right version (x64) in the folder tree and copying it into the bin folder, it worked.

Upvotes: 0

Edgar Owen
Edgar Owen

Reputation: 11

I had this issue. In my case i was working on a project for a client that would run the application with an IIS identity user.

After installing the packages above (PdfiumViewer,PdfiumViewer.Native.x86.v8-xfa ,PdfiumViewer.Native.x86_64.v8-xfa), it still didn't work.

After all the problem was due to lack of permissons of this user (it needs write, modify permissons). Just to let you know another use case that led to the same problem.

Upvotes: 0

Gabic
Gabic

Reputation: 694

In case anyone still needs help with this, I was having the same problem and solved it using @Jack 's comment on @Paddy 's solution:

  1. Install PdfiumViewer NuGet package
  2. Install PdfiumViewer.Native.x86.v8-xfa NuGet package
  3. Install PdfiumViewer.Native.x86_64.v8-xfa NuGet package

After installing all 3 packages, I published the application (my application is ClickOnce) and executed it, and it worked just fine!

Upvotes: 31

Rafael Ventura
Rafael Ventura

Reputation: 314

I had tremendous grief with this missing dll, until I found the easiest way I found was to go to Nuget Package Manager and install the PDFium.Windows package.

Upvotes: -1

Morphed
Morphed

Reputation: 3619

I assume you're using Winforms?

To get the pdfRenderer control in a WinForm: Add the PdfiumViewer NuGet package to the project; open the projects packages folder in Windows Explorer and drag the PdfiumViewer.dll file onto the Toolbox window; A control called PdfRenderer will be available to add:

Adding PdfRenderer control to WinForms

Upvotes: 3

Related Questions