Quick Start for .NET Core

Quick Start for .NET Core (2)

Step 1: Download the latest version of Spire.Doc 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.Doc as Dependency in a .NET Core Application

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

How to Mannually Add Spire.Doc 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.Doc as Dependency in a .NET Core Application

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

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.Doc 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 Word document using Spire.Doc.

using Spire.Doc;
using Spire.Doc.Documents;

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

            //Add a section
            Section section = doc.AddSection();

            //Add a paragrah
            Paragraph paragraph = section.AddParagraph();

            //Append text to the paragraph
            paragraph.AppendText("This article shows you how to mannually add Spire.Doc as dependency in a .NET Core application.");

            //Save to file
            doc.SaveToFile("Output.docx", FileFormat.Docx2013);
        }
    }
}

This program guide focus on helping you how to make Spire.Doc workable on Windows and Linux.

Starts from V 6.7.4, Spire.Doc supports .NET Core 2.0. Spire.Doc uses System.Drawing.Common, which depends on Libgdiplus library. So when you use Spire.Doc on .NET core, you need to install Libgdiplus library.

On Windows, we recommend you to get Spire.Doc package via Nuget. The Libgdiplus library will be installed automatically.

How to use Spire.Doc on .NET Core

On Linux, you need to install Libgdiplus library independently. Please follow the below three steps to install it successfully.

Step1: Open xxxx.csproj file and write the code snippet into it.

<ItemGroup>
<PackageReference Include=”Spire.Doc” Version=”6.7.13”/>
</ItemGroup>

How to use Spire.Doc on .NET Core

Step 2. Execute "dotnet build" command on terminal window of Visual Studio Code. It will install Spire.Doc package.

How to use Spire.Doc on .NET Core

Step 3. Open terminal window on Linux and execute Libgdiplus library installation command, for example, the command on Linux Ubuntu is "sudo apt-get install libgdiplus".

How to use Spire.Doc on .NET Core

Then you can use Spire.Doc on .NET core.

If you have any question, please feel free to contact us.

page