Adding pdfium.dll to visual studio - c#

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

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:
Install PdfiumViewer NuGet package
Install PdfiumViewer.Native.x86.v8-xfa NuGet package
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!

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:

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.

Related

Setup FFMpegCore in Visual Studio 2019

I am confused on the basics of using a library. I understand that there is a library called FFMpeg and a wrapper called FFMpegCore so we can use FFMpeg with C#, correct? I downloaded both FFMpeg and FFMpegCore and I have them in my project's folder. Although I didn't perceive any class named FFMpegOptions in either of the file's folders.
I am stuck on how to actually set it up so I can use it in my little project, I never downloaded someone's library before. Can somebody please walk me though the motions of connecting the three of them together?
So far I experimented with:
Add a reference to my project, but there doesn't seem to be any .dll, .tlb, .olb, .ocx or .exe files to add
Add an existing project to my solution. There is a project called FFMpegCore.csproj but adding it raises a missing SDK error. Weirdly enough, opening the same project as a standalone doesn't raise any issues which makes me thing the operation I am trying is inadequate.
I am sure this is a silly and easy setup to perform but I just don't know enough to find a solution.
First you must download and install ffmpeg on your machine, (to test that it is working correctly, open a CMD and execute "ffmpeg", it will return the installed version.
Second, create a new project, (I recommend .NETFramework) once your project is created, it is necessary to install the package from NuGet, this function is found in tools> NuGet Package Manager> Manage packages for solutions...>
Then search for FFmpegCore and install it in your project,
The necessary dependencies will be added, now you can start programming with this Framework,
I recommend the FFMpeg.cs class as an example of the documentation, to start with.
Good Luck.

Visual Studio acting like a reference is missing, but it is clearly there,

I am using Visual Studios 2015 Community.
I was given this code to work on and improve, and I cant get any thing from MetroFramework to behave properly. This is my first time using VS, but my research has been extensive, and I am very stuck. Any time I try to open up a design, I am met with many many errors that you can see in the gallery.
So naturally I follow up and check my references. The references in this project clearly show MetroFramework.
And furthermore, Metroframework.Controls clearly shows the components it says are missing. I would post the pictures, but SO only lets me put two links right now.
What am I missing here? This is the first time I've found a problem I cant solve looking at answered questions, and I hope you all can help. Thank you.
Edit: I have metroframework in both my references node and in the header of my code. VS does recommend I remove it from my header, as it says it is not being used, but it is being used, its just throwing the errors.
I also seem to get a setup error, and I am not sure that I had it before. Image in gallery.
All images are in the folowing gallery.
Imgur Link
Visual Studio sometimes acts up. Try any of the following:
Building the solution even with errors. This can get NuGet packages to refresh and that may be your problem.
Cleaning the solution and then building.
Restarting Visual Studio.
You have the wrong project installed. To fix your problem install Metro Modern UI - Metro Framework by Dennis Magno from NuGet (I assume that's the correct one because it has MetroGrid and MetroDateTime). If you use gui search for metromodernui in search box, or execute this
Install-Package MetroModernUI
For the record
Here is original project which you probably had installed (now so that I looked at last screenshot). Installed using:
Install-Package ModernUI
Here is another project you don't want to install (I thought you had this one originally) because it also doesn't have neither of those controls. Installed using:
Install-Package MetroFramework -Version 1.2.0.3
Here is the project you probably want to install to resolve errors.
Install-Package MetroModernUI
"Conveniently", they all use the same namespace MetroFramework, hence the confusion.
Right click on the References folder on your project.
Select Add Reference.
Select the .NET tab (or select the Browse button if it is not a .NET Framework assembly).
Double-click the assembly containing the namespace in the error message.
Press the OK button.
Try this command from your Package Manager Console
Update-Package

The referenced component Mono.Android could not be found

I have the same problem...pls help me...
I just installed the Xamarin and want to use vs2015 . When I create a new Blank App (Android) and I’m getting the following errors. How can I fix this? I reinstalled vs2015 and reinstalled Xamarin but I’m still getting the errors.
The referenced component ‘Mono.Android’ could not be found.
The referenced component ‘mscorlib’ could not be found.
The referenced component ‘System’ could not be found.
The referenced component ‘System.Core’ could not be found.
The referenced component ‘System.Xml’ could not be found.
The referenced component ‘System.Xml.Linq’ could not be found.
For me, I just ran into this trying to build a project pulled from TFS on a new VS 2015 Update 2 install. Not sure what exactly fixed it but this is what I did:
Download Android API 23 and 22 SDK from the SDK Manager and also updated all other items in SDK Manager (had to close and open it twice to get it totally up-to-date).
Nuget Restore packages (this did not fully fix it).
Followed these instructions where you go into all .csproj file in the solution and remove all mentions of nuget. Also do this in the solution file, but mine had nothing.
Use Package Console and run Update-Package -Reinstall (of if you know these package were building just fine before, I ran ``Update-Package -Reinstall -IgnoreDependencies`) and choose the project if you want.
Still had a couple errors from the Android Resource Designer file so did a build and everything was right in the world again.
For me it was a Mono.Android.dll version issue.
I removed the reference, and added a reference to the right version.
These errors most likely point to an installation with missing pieces (or a corrupt install). Try reinstalling Xamarin (again, yes) with admin privileges if you haven't done so already.
If you check your version information via "Help -> About Microsoft Visual Studio -> Copy Info [button]" and Xamarin isn't listed in the bottom, then your install didn't go through correctly.
Additionally, can you double check you have the Android SDK installed? Open up the start menu and type Android SDK Manager. Run it and make sure you've downloaded the build tools and one of the recent API levels.
For me i had to remove the pcl(portable class library) from the solution then added it back then the issue was resolved.

Library dependencies for pdfiumViewer?

i got some troubles to display a pdf using pdfium using c#. I read this other question:
Read a stored PDF from memory stream
i downloaded the pdfiumViewer package, but when i compile it, it says that it can't find the pdfium library. So, I downloaded the package "pdfium.net SDK" so it's working but it's not free, it's limited version. what i was wondering is : do we must have the package "pdfium.net SDK" to have the "pdfiumViewer" working" ?
thx !
The SDK you found, which I guess is Patagames's Pdfium.Net SDK, which is indeed a paid solution.
PdfiumViewer is free, but you have to have pdfium built, which is pretty thoroughly documented.
Pdfium.dll is already integrated into PdfiumViewer. But for it to be loaded, you need when building your project, to copy this file next to your application, either in the root or the x86 or x64 sub directory. The easiest way to accomplish this is by changing the properties of that file, changing the Copy to Output Directory setting to Copy always.
Try the NuGet package "PdfiumViewer". Works like a charm!
In my case*, I needed the NuGet Package PdfiumViewer.Native.x86.v8-xfa, which adds the needed DLL.
Got it running after 10 minutes with this code.
*) Visual Studio 2019 Pro, Windows 10 x64 Pro

Source unreachable when using the NuGet Package Manager Console

We are moving our package management from manually updating files to NuGet. I am trying to install older versions of packages to match the one we already have in source control. There is no way to do this from the UI so I use the command line to get the proper version.
For some reason, Install-Package keeps on telling me that the nuget gallery is unreachable.
The source at nuget.org [https://www.nuget.org/api/v2/] is unreachable. Falling back to NuGet Local Cache
This happens only in one of our solutions. If I create a new solution or use another one in the same repository, packages will install as expected. I can even install the packages in a dummy solution to fill the local cache and then install them successfully in the faulty solution. I have tried to Invoke-WebRequest on the url from the NuGet Console and I get an HTTP 200.
What can cause this? Is there a way to override the package sources on a per solution/project basis?
Even though my Package Source was set to nuget.org in Package Manager Console, explicitly adding the -Source nuget.org argument fixed this for me.
So an example of use would be:
Install-Package Akka.net -Source nuget.org
Akka.net being your package that you want to install, its just an example here.
I had to copy the default NuGet source in Visual Studio's options. With the copied source, I changed the URL from https to http. This resolved the problem for me.
Credit for this suggestion belongs here: https://nuget.codeplex.com/discussions/561075#PostDetailsCell_1354351, to "jpharris4".
You can change NuGet source from UI as well. Just change NuGet source to older version and it should work fine.
There seems to be still few bugs in VS 2015 related to api.nuget.org (v3).
I'm not sure what can cause your issue, but there is indeed a way to override package sources on a per-solution basis, but only if you've enabled NuGet Package Restore on the given solution.
Once a solution has enabled NuGet Package Restore a folder called ".nuget" gets added to the solution. Under this will be a file called "NuGet.targets" that has an ItemGroup whose Condition is " '$(PackageSources)' == '' " like the one you'll see in the attached image.
If the ItemGroup is empty (or completely commented out, as in the illustration) then the solution will use a specific file that should be the same as the sources listed under TOOLS >> OPTIONS. But if you uncomment or add PackageSource items to that ItemGroup the solution will search the package sources listed and ONLY the ones listed.
In my Package Manager Console i could not see any sources
Going to:
Tools -> Options -> Nuget Package Manager -> Package Sources
I found the sources. Unchecking them, and them checking them back made the re-appear in my Package Manager Console
I had to provide the comman along with the full url as Install-Package MySql.Data.Entity -Version 6.9.8 -Source http://www.nuget.org/api/v2
In my case the cause was that the package had an agreement.
Through the UI - "Manage NuGet Packages" dialog you have the option to accept and continue.
The Package Manager Console in VS 2013 seems to have an issue with this.
As others have said restarting VS 2013 might resolve it for the console.
This is worked for me in VS 2015 prof: Tools -> Options -> Nuget Package Manager -> Package Sources
Press Add button
Edit in Name label: nuget.org
Edit in Source label: https://www.nuget.org/api/v2/
Press OK
Hope it helps ;)
I had the same issue with the same message. But the reason of my problem was lost connection to TFS. My TFS server was hosted in other network and I used VPN for access to it. When I tried to install the package without established connection to TFS (VPN was turned off) I got the same problem.
Be aware of this TFS behavior.
Happens because you work offline mode, when you reconnect the network will need to log off and log back. Package manager will smoothly re-initialize.
I have faced this issue VS2013 and wasted 3 hours of time.
Not Sure what was the cause of the issue. But none of the above solutions worked for me.
Re-Installtion of Nuget Package Manager console worked for me.
Tools - > Extensions and Updates -> Under All Look for Nuget Package Manager for Visual Studio and hit uninstall.
Go to https://marketplace.visualstudio.com/items?itemName=NuGetTeam.NuGetPackageManagerforVisualStudio2013 and download the extension.
enter image description hereMay be yours office/home firewall blocking nuget.org so try to connect different internet network for example from your mobile or wifi .I was able to solve through this method.
None of these solutions worked for me with VS2013. Yes I know it's the year 2020.
In the end I downloaded the nuget package to a local folder, added the folder to the nuget settings, and then voila!, was able to install the package.

Categories