Document .Net - Using in .Net Core

Using in .Net Core

You can easily use «Document .Net» in .Net Core 2.0, 2.1 or higher. It's completely written in C# managed code and compiled under .Net Framework and .Net Core.

Let us say, you have just created a .Net Core project. To configure Document .Net in your project, make these steps:

  1. Add the reference to SautinSoft.Document.dll.
  2. Add dependencies through Nuget (optional).

1. Add the reference to SautinSoft.Document.dll:

You may add the reference to the SautinSoft.Document assembly by two ways:

1. Nuget (fast way):

(Solution Explorer->right click by "References"->Manage Nuget Packages...->In the tab "Browse" type "SautinSoft" and find the "SautinSoft.Document")
Add SautinSoft.Document.dll via Nuget.

2. Old good way by adding the reference:

First of all, download the Document .Net package (document_net.zip) from the SautinSoft website.
Unzip document_net.zip and find the assembly file "SautinSoft.Document.dll".
(At the Solution Explorer->right click by "References"->Add Reference...->Browse "SautinSoft.Document.dll")
Add reference to SautinSoft.Document.dll.

Note:

SautinSoft.Document.dll compiled for .Net Core is located inside (document_net.zip->Document .Net X.X\Bin\Net Core X.X) folder.

SautinSoft.Document.dll compiled for .Net Framework is located inside (document_net.zip->Document .Net X.X\Bin\Net X.X) folder.

2. Add dependencies through Nuget (optional):

If you have added the SautinSoft.Document.dll into your project in previous step 1 through Nuget, all dependencies are already installed automatically and therefore simply skip this step.

In case of you have added the reference to the SautinSoft.Document.dll by the old way (Solution Explorer->right click by "References"->Add Reference...), please add these dependencies using Nuget:

  • System.IO.Packaging, 4.5.0.
  • System.Text.Encoding.CodePages, 4.5.0.
  • System.Xml.XPath.XmlDocument, 4.3.0.
  • ZKWeb.System.Drawing, 4.0.1.

For example, to add "System.IO.Packaging, 4.5.0:
(Solution Explorer->right click by "References"->Manage Nuget Packages...->In the tab "Browse" type "System.IO.Packaging" and find the "System.IO.Packaging", select version "4.5.0")

Complete code

using SautinSoft.Document;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            ExampleHelloWorld();
        }
		
        /// <summary>
        /// Create file with Hello World.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/examples/using-in-netcore.php
        /// </remarks>
        static void ExampleHelloWorld()
        {
            DocumentCore dc = new DocumentCore();
            dc.Content.End.Insert("Hello World!", new CharacterFormat() { FontName = "Verdana", Size = 65.5d,FontColor = Color.DarkBlue });
			
            // Save a document to a file in DOCX format.
            string filePath = @"Result.docx";
            dc.Save(filePath);

            // Open the result for demonstation purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
        }
    }
}

Download.

        
            Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        ExampleHelloWorld()
    End Sub

    ''' <summary>
    ''' Create file with Hello World.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/examples/using-in-netcore.php
    ''' </remarks>
    Sub ExampleHelloWorld()
        Dim dc As New DocumentCore()
        dc.Content.End.Insert("Hello World!", New CharacterFormat() With {
                .FontName = "Verdana",
                .Size = 65.5R,
                .FontColor = Color.DarkBlue
            })

        ' Save a document to a file in DOCX format.
        Dim filePath As String = "Result.docx"
        dc.Save(filePath)

        ' Open the result for demonstation purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
    End Sub
End Module

Download.

© SautinSoft 2002 - 2019