简体   繁体   English

如何在C#中添加PDFsharp lib?

[英]How to add PDFsharp lib in C#?

I am new to C#.net, I downloaded PDFsharp lib. 我是C#.net的新手,我下载了PDFsharp lib。 But how to add this lib to our project? 但是如何将这个lib添加到我们的项目中呢?
My project is to create a PDF file. 我的项目是创建一个PDF文件。 Please provide me step by step instructions. 请给我一步一步的说明。 After unziping it has 32 folders. 解压后它有32个文件夹。
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?)" 无法找到类型或命名空间名称'PdfSharp'(您是否缺少using指令或程序集引用?)”

If you wish to use this library you need to add a reference to the assembly (dll) that contains the library. 如果要使用此库,则需要添加对包含库的程序集(dll)的引用。 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. 要添加引用,只需右键单击解决方案资源管理器中的项目并选择添加引用,然后您将有一个选项卡式对话框,允许您在GAC中添加对dll的引用,解决方案中的其他项目或浏览到位于您的任何位置的dll 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. 如果打开包含在代码目录根目录中的“BuildAll-PdfSharp.sln”,您将能够构建PDFSharp并获取dll。 It will be in the folder user code PdfSharp\\bin 它将在文件夹用户代码PdfSharp \\ bin中

Once you have the dll you can add it to your solution by browsing to the location of the dll on disc. 获得该DLL后,您可以通过浏览光盘上的dll位置将其添加到您的解决方案中。 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. 当我将第三方库添加到我的项目时,我在我的工作文件夹的根目录下有一个lib文件夹,其中放置了所有dll。 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. 然后,项目文件中对这些文件的引用会使用相对路径,当项目从源存储库获取最新信息时,可供项目的其他任何人使用。

我还发现PdfSharp可以通过Nuget包管理器控制台作为附件提供。

You can add the existing projects (*.csproj) that come with the PDFsharp source code to your solution and then reference these projects. 您可以将PDFsharp源代码附带的现有项目(* .csproj)添加到解决方案中,然后引用这些项目。 If you do so, you can jump into the PDFsharp source code and IntelliSense will also work. 如果这样做,您可以跳转到PDFsharp源代码,IntelliSense也可以工作。 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. 所有必需的程序集将自动复制到应用程序的bin / debug或bin / release文件夹中。

If you only downloaded the binaries, add references to the DLL files. 如果只下载了二进制文件,请添加对DLL文件的引用。

Update: You can find PDFsharp and MigraDoc on NuGet. 更新:您可以在NuGet上找到PDFsharp和MigraDoc。 The NuGet Package Manager will then add the project references for you. 然后,NuGet包管理器将为您添加项目引用。

从此URL下载Assemblies版本: http//pdfsharp.codeplex.com/releases/view/37054

you have to add the dll as a reference to your Visual Studio solution. 您必须添加该DLL作为Visual Studio解决方案的参考。 In the project explorer, in the Reference node, right click and add reference. 在项目资源管理器中,在“引用”节点中,右键单击并添加引用。 Search for that dll and add it to the project. 搜索该dll并将其添加到项目中。

I think you have downloaded the source files. 我想你已经下载了源文件。 Open the file BuildAll-PdfSharp.sln in visual studio and build the project. 在visual studio中打开BuildAll-PdfSharp.sln文件并构建项目。 Then it will generate the dll files that you have to reference in your own project. 然后它将生成您必须在自己的项目中引用的dll文件。

Hope this helps. 希望这可以帮助。

/Klaus /克劳斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM