如何在 C# 中添加 PDFsharp 库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1831794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 21:13:20  来源:igfitidea点击:

How to add PDFsharp lib in C#?

c#pdfpdfsharp

提问by Royson

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.

我是 C#.net 的新手,我下载了 PDFsharp lib。但是如何将这个库添加到我们的项目中呢?
我的项目是创建一个PDF文件。请向我提供分步说明。解压后有32个文件夹。
我尝试在我的项目文件夹中处理它,但出现了同样的错误。

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

找不到类型或命名空间名称‘PdfSharp’(您是否缺少 using 指令或程序集引用?)”

采纳答案by Priyank Bolia

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.

如果您希望使用此库,则需要添加对包含该库的程序集 (dll) 的引用。要添加引用,只需在解决方案资源管理器中右键单击您的项目并选择添加引用,您就会有一个选项卡式对话框,允许您添加对 GAC 中的 dll、解决方案中的其他项目的引用,或浏览到位于您的任何位置的 dll个人电脑。

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

您看到的所有文件夹都是向您展示如何使用该库的源代码和示例项目。如果您打开包含在代码目录根目录中的“BuildAll-PdfSharp.sln”,您将能够构建 PDFSharp 并获取 dll。它将在文件夹用户代码 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.

获得 dll 后,您可以通过浏览到光盘上 dll 的位置将其添加到您的解决方案中。当我将第三方库添加到我的项目时,我的工作文件夹的根目录中有一个 lib 文件夹,其中放置了所有 dll。项目文件中对这些的引用然后使用相对路径,并且当他们从您的源存储库获取最新的项目时,其他任何人都可以使用这些路径。

回答by Klaus Byskov Pedersen

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.

我想你已经下载了源文件。在 Visual Studio 中打开文件 BuildAll-PdfSharp.sln 并构建项目。然后它将生成您必须在自己的项目中引用的 dll 文件。

Hope this helps.

希望这可以帮助。

/Klaus

/克劳斯

回答by Priyank Bolia

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.

您必须添加 dll 作为对 Visual Studio 解决方案的引用。在项目资源管理器的参考节点中,右键单击并添加参考。搜索该 dll 并将其添加到项目中。

回答by I liked the old Stack Overflow

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.

您可以将 PDFsharp 源代码附带的现有项目 (*.csproj) 添加到您的解决方案,然后引用这些项目。如果这样做,您可以跳转到 PDFsharp 源代码,IntelliSense 也将起作用。检查示例以查看您需要哪些参考。

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. The NuGet Package Manager will then add the project references for you.

更新:您可以在 NuGet 上找到 PDFsharp 和 MigraDoc。然后,NuGet 包管理器将为您添加项目引用。

回答by RichC

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

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

回答by Mike Upjohn

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

我还发现 PdfSharp 可通过 Nuget 包管理器控制台作为附加组件使用。