Thursday, 17 October 2019 07:44

How to Mannually Add Spire.PDF as Dependency in a .NET Core Application

Written by  support iceblue
Rate this item
(0 votes)

Step 1: Download the latest version of Spire.PDF Pack from the link below, unzip it, and you'll get the DLL files for .NET Core in the "netcoreapp2.0" folder. If you already have this folder in your disk, go straight to step two.

How to Mannually Add Spire.PDF as Dependency in a .NET Core Application

Step 2: Create a .NET Core application in your Visual Studio.

How to Mannually Add Spire.PDF as Dependency in a .NET Core Application

Step 3: Add all DLL files under the "netcoreapp2.0" folder as dependencies in your project.

Right-click "Dependencies" – select "Add Reference" – click "Browse" – selcet all DLLs under "netcoreapp2.0" folder – click "Add".

How to Mannually Add Spire.PDF as Dependency in a .NET Core Application

Step 4: Install the other two packages in your project via the NuGet Package Manager. They are System.Drawing.Common and System.Text.Encoding.CodePages.

Right-click "Dependencies" – select "Manage NuGet Packages" – click "Browse" –type the package name – select the package from the search results – click "Install".

Note: If you fail to find these packages in the NuGet Package Manager, check if you have set the "nuget.org" as the "Package source".

How to Mannually Add Spire.PDF as Dependency in a .NET Core Application

Step 5: Now that you’ve added all the dependences successfully, you can start to code. The following code snippet gives you an exmaple of how to create a simple PDF document using Spire.PDF.

using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

namespace SpirePdfCore
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a PdfDocument object
            PdfDocument doc = new PdfDocument();

            //Add a page
            PdfPageBase page = doc.Pages.Add();

            //Draw text on the page at the specified position
            page.Canvas.DrawString("Hello World",
                                    new PdfFont(PdfFontFamily.Helvetica, 13f),
                                    new PdfSolidBrush(Color.Black),
                                    new PointF(50, 50));

            //Save the document
            doc.SaveToFile("Output.pdf");
        }
    }
}

Additional Info

  • tutorial_title: Mannually Add Spire.PDF as Dependency in a .NET Core Application
Last modified on Thursday, 17 October 2019 07:57