13

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.

Many thanks in advance! ~Melvin

Melvin Winthagen
  • 277
  • 1
  • 2
  • 9

3 Answers3

18

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!

Gabic
  • 484
  • 1
  • 6
  • 15
  • 2
    [Combined with Ralfs answer](https://stackoverflow.com/a/43046814/591285), this was the only thing that worked for me. These two additional packages will add `x86` and `x64` folders each with their own `pdfium.dll`. Now we can just use Ralfs solution to load the proper library. – clamchoda May 05 '21 at 20:30
3

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

Morphed
  • 3,527
  • 2
  • 29
  • 55
  • 5
    For me to get this to work on winforms, I had to install the packages https://www.nuget.org/packages/PdfiumViewer.Native.x86_64.v8-xfa/ and https://www.nuget.org/packages/PdfiumViewer.Native.x86.v8-xfa/ and then copy the /bin/debug/x86 and /bin/debug/x64 folders to the root folder, as per the discussion here: https://github.com/pvginkel/PdfiumViewer/issues/83 – Jack Jun 16 '20 at 02:46
-1

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.

Rafael Ventura
  • 284
  • 3
  • 13