How to add PDFsharp lib in C#?
Asked Answered
A

6

28

I am new to C#.net, I downloaded PDFsharp lib. But how to add this lib to our project?
My project is to create a PDF file. Please provide me step by step instructions. After unziping it has 32 folders.
I tried by coping it in my project folder, but same errors come.

"The type or namespace name 'PdfSharp' could not be found (are you missing a using directive or an assembly reference?)"

Adjutant answered 2/12, 2009 at 9:41 Comment(5)
Rahul add the dll to ur bin folder.... Dll will be in bin folder of ur downloaded fileUgrian
may i suggest that if pdfsharp isn't working out for you, that you may try out itextsharp. it's also a free dll for making pdf's. you need to add a reference in visual studio to the compiled dll of pdfsharpMaize
you can install PDFSharp from Nuget -> PM> Install-Package PdfSharpShylashylock
Can you please tell what to do after installing? I'm using VS2015, and found PdfSharp.Migradoc package, but after install, I still can't use from my project (no reference for it in references). I'm using Visual Basic, but it doesn't matter. Thanks for any help!Knowlton
I was adding a completely different PDFsharp-MigraDoc package, take care to use the one from empira Software GmbH.Knowlton
B
24

If you wish to use this library you need to add a reference to the assembly (dll) that contains the library. To add references simply right click on your project in solution explorer and select add reference, you will then have a tabbed dialog box that allows you to add references to dlls in the GAC, other projects in your solution or browse to dlls located anywhere on your PC.

All the folders you see are the source code and sample projects that show you how to use the library. If you open the "BuildAll-PdfSharp.sln" which is contained in the root of the code directory you will be able to build PDFSharp and get the dll. It will be in the folder user code PdfSharp\bin

Once you have the dll you can add it to your solution by browsing to the location of the dll on disc. When I add third party libraries to my project I have a lib folder at the root of my working folder where all the dlls are placed. References to these in the project files then use relative paths and will be available to anyone else working on the project when they get the latest from your source repository.

Batha answered 2/12, 2009 at 9:53 Comment(1)
One can either add a reference to the assembly (DLL) or include the project (*.csproj) in the solution and reference the project. I recommend referencing the project (it's open source so take advantage of the source code).Canzona
E
20

I've also found that PdfSharp is available as an add on through the Nuget Package Manager Console.

Ear answered 19/8, 2015 at 8:32 Comment(2)
Easiest solution. I don't know why people are not reading this solutionGoahead
Yes, at the end this is the easiest solution. :-)Baler
C
16

You can add the existing projects (*.csproj) that come with the PDFsharp source code to your solution and then reference these projects. If you do so, you can jump into the PDFsharp source code and IntelliSense will also work. Check the samples to see which references you need.

All required assemblies will automatically be copied to the bin/debug or bin/release folder respectively of your application.

If you only downloaded the binaries, add references to the DLL files.

Update: You can find PDFsharp and MigraDoc on NuGet. The NuGet Package Manager will then add the project references for you.

Canzona answered 2/12, 2009 at 12:57 Comment(1)
@PDFsharpExpert Thanks, but can you tell what to do when NuGet manager won't add the references to the project? Many thanks!Knowlton
R
2

Download the Assemblies version from this URL: http://pdfsharp.codeplex.com/releases/view/37054

Raffo answered 16/5, 2010 at 18:31 Comment(0)
D
1

I think you have downloaded the source files. Open the file BuildAll-PdfSharp.sln in visual studio and build the project. Then it will generate the dll files that you have to reference in your own project.

Hope this helps.

/Klaus

Derision answered 2/12, 2009 at 9:48 Comment(1)
i did this but i don't get dll file. where it is?Adjutant
D
1

you have to add the dll as a reference to your Visual Studio solution. In the project explorer, in the Reference node, right click and add reference. Search for that dll and add it to the project.

Dorcasdorcea answered 2/12, 2009 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.