Использование в .NET Core


You can easily use «SautinSoft.Document» 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 SautinSoft.Document 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:

Вы можете добавить ссылку на SautinSoft.Document сборка двумя способами:

1. Nuget (быстрый способ):

(Solution Explorer->щелкните правой кнопкой мыши по "References"->Manage Nuget Packages...->В вкладке "Browse" тип "SautinSoft" и найти "SautinSoft.Document")
Add SautinSoft.Document.dll via Nuget.

2. Старый добрый способ, добавив ссылку:

Прежде всего, скачайте SautinSoft.Document пакет (document_net.zip) из SautinSoft вебсайт.
Распакуйте document_net.zip и найдите файл сборки "SautinSoft.Document.dll".
(At the Solution Explorer->щелкните правой кнопкой мыши по "References"->Add Reference...->Просматривать "SautinSoft.Document.dll")
Add reference to SautinSoft.Document.dll.

Примечание:

SautinSoft.Document.dll скомпилированный для .NET Core находится внутри(document_net.zip->SautinSoft.Document X.X\Bin\.NET Core X.X) папки.

SautinSoft.Document.dll скомпилирован для .NET Framework находится внутри (document_net.zip->SautinSoft.Document X.X\Bin\.NET Framework X.X) папки.

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.Drawing.Common, 4.7.0 or up.
  • System.IO.Packaging, 4.4.0 or up.
  • System.Text.Encoding.CodePages, 4.5.0 or up.
  • System.Xml.XPath.XmlDocument, 4.3.0 or up.

For example, to add "System.IO.Packaging, 4.4.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.4.0")

Полный код

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/help/net/developer-guide/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 demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
        }
    }
}

Скачать

        
            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/help/net/developer-guide/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 demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
    End Sub
End Module

Скачать


Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу [email protected] или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже:



Вопросы и предложения всегда приветствуются!

Мы разрабатываем компоненты .Net с 2002 года. Мы знаем форматы PDF, DOCX, RTF, HTML, XLSX и Images. Если вам нужна помощь в создании, изменении или преобразовании документов в различных форматах, мы можем вам помочь. Мы напишем для вас любой пример кода абсолютно бесплатно.