Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding pdfium.dll to visual studio

Tags:

c#

pdfium

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

like image 828
Melvin Winthagen Avatar asked Apr 12 '19 07:04

Melvin Winthagen


2 Answers

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!

like image 75
Gabic Avatar answered Nov 06 '22 22:11

Gabic


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

like image 20
Morphed Avatar answered Nov 06 '22 21:11

Morphed