Document library for C# and .NET
Document.Net is a .NET assembly that allows developers to programmatically Create, Load, Modify, Merge, Sign digitally, Convert, Rasterize, Mail Merge, Generate Reports, Charts, Combine templates and JSON, Document Properties, Find and Replace, and much more with documents in PDF, DOCX, RTF, HTML, and text formats. It is a standalone library, meaning it does not require any additional software such as Adobe Acrobat or MS Word to function.
Main features:
- Document Creation: Create documents from scratch in various formats such as DOCX, PDF, RTF, HTML, and Text.
- Load Documents: Load existing documents for reading or modification.
- Modify Documents: Edit the content, structure, and properties of documents.
- Convert Documents: Convert documents from one format to another, for example, from DOCX to PDF.
- Merge Documents: Combine multiple documents into one document.
- Digital Signatures: Add digital signatures to documents for security and authenticity.
- Find and Replace: Search for specific text in documents and replace it.
- Mail Merge: Create personalized documents by merging templates with data.
- Charts and Reports: Create dynamic charts and reports within documents.
- Document Properties: Access document properties such as title, author, etc.
The advantages of Using SautinSoft.Document:
- Wide Range of Supported Formats: SautinSoft.Document supports various document formats, including PDF, DOCX, RTF, HTML, and text files. This allows developers to work with multiple types of documents in a single application.
- No Dependencies: The library is completely standalone and does not require the installation of Microsoft Office or Adobe Acrobat. This simplifies deployment and reduces dependency on third-party software.
- Multilingual Support: Supports documents in various languages, including Latin, Chinese, Japanese, Korean, Devanagari, Thai, Cyrillic, Mongolian, and others. This makes the library versatile for international projects.
- Full .NET Support: The library supports development for any .NET platform or major operating systems using a single code base. This includes .NET Framework, Mono, and others.
- Powerful Document Handling Capabilities: SautinSoft.Document provides an API for creating, loading, modifying, converting, merging, digitally signing, finding and replacing, generating reports, rasterizing to images, and performing many other actions with documents.
- High Performance: The latest versions of the library are optimized to increase the speed of loading and saving documents in PDF and DOCX formats, as well as to reduce the size of the resulting files.
- Ease of Use: The library has a simple and intuitive API, making it easy for developers to integrate and use in their applications.
- Support and Documentation: SautinSoft provides extensive documentation and code examples, as well as developer support, which helps quickly resolve any questions and issues.
Licensing and Support:
SautinSoft offers three types of licenses, including free technical support and free updates for one year. Technical support includes assistance via web chat, email, and Skype group chats.Conclusion:
Thus, in the field of software development, working with various document formats such as DOCX, PDF, HTML, and RTF is a common requirement. Whether you need to create, load, parse, or manipulate these documents, having a reliable document library can significantly simplify the development process. Document.Net from SautinSoft is one such powerful library, providing a comprehensive API for working with documents in C# and .NET.
Create new DOCX and PDF documents in C#
Software for creating formats such as DOCX, PDF, RTF, HTML and Image in C# can be efficiently performed using Document from the SautinSoft.Document library. To create a DOCX document with text content, you can use the Documentscorel and DocumentBuilder classes provided by SautinSoft.Document library. Pay attention to a simple example demonstrating how to create a DOCX and/or PDF document with formatted text.
using SautinSoft.Document;
DocumentCore dc = new DocumentCore();
DocumentBuilder db = new DocumentBuilder(dc);
Section section = db.Document.Sections[0];
section.PageSetup.PaperType = PaperType.A4;
db.CharacterFormat.FontName = "Verdana";
db.CharacterFormat.Size = 16;
db.CharacterFormat.FontColor = Color.Orange;
db.Write("This is the first paragraph!");
dc.Save("Document.docx", new DocxSaveOptions());
dc.Save("Document.pdf", new PdfSaveOptions());
public static void ViceVersa()
{
string inpFile = @"Start.html";
string outFile = String.Empty;
const int count = 10;
string templateFileName = Path.GetFileNameWithoutExtension(inpFile);
string dirName = Path.GetDirectoryName(inpFile);
for (int i = 0; i < count; i++)
{
DocumentCore dc = DocumentCore.Load(inpFile);
// To RTF
if (Path.GetExtension(inpFile) == ".html" || Path.GetExtension(inpFile) == ".htm")
{
outFile = Path.Combine(dirName, $"{templateFileName}{i + 1}.rtf");
dc.Save(outFile);
inpFile = outFile;
}
else // To HTML
{
outFile = Path.Combine(dirName, $"{templateFileName}{i + 1}.html");
dc.Save(outFile, new HtmlFlowingSaveOptions());
inpFile = outFile;
}
}
}
Convert HTML to RTF and vice versa in C#
Conversion between HTML and RTF formats is a common requirement in many applications, especially those related to document processing and web content management. Documentation the SautinSoft.Net library provides a reliable solution for such transformations. In addition, you can find the conversion of other formats: DOCX to PDF, DOCX to Text, RTF to PDF and others.
To convert HTML to RTF, you can use the `DocumentCore` class to load HTML content and then save it as an RTF file. Pay attention to a simple example demonstrating this transformation. Similarly, converting RTF to HTML involves downloading RTF content.
Find and Replace text in DOCX using C#
Finding and replacing text in DOCX documents is a common back in document processing. Using SautinSoft.Document, you can easily find and replace text in DOCX documents with just a few lines of code. This powerful library simplifies document processing tasks and offers a wide range of features for working with various document formats.
Look a simple example demonstrating how to find and replace text in a DOCX document using C# and this SDK.
using SautinSoft.Document;
string loadPath = @"sample.docx";
DocumentCore dc = DocumentCore.Load(loadPath);
string findText = "old text";
string replaceText = "new text";
foreach (ContentRange item in dc.Content.Find(findText).Reverse())
{
item.Replace(replaceText);
}
string savePath = @"result.docx";
dc.Save(savePath, new DocxSaveOptions());
using SautinSoft.Document;
using System.IO;
using System.Linq;
DocumentCore result = Directory.GetFiles(@"d:\directory\", "*.*")
.Where(file => new[] { ".docx", ".pdf", ".txt", ".html", ".rtf" }.Contains(Path.GetExtension(file).ToLower()))
.Select(DocumentCore.Load)
.Aggregate(new DocumentCore(), (acc, dc) => {
ImportSession session = new ImportSession(dc, acc, StyleImportingMode.KeepSourceFormatting);
dc.Sections.ToList().ForEach(sourceSection => {
Section importedSection = acc.Import(sourceSection, true, session);
if (dc.Sections.IndexOf(sourceSection) == 0)
importedSection.PageSetup.SectionStart = SectionStart.NewPage;
acc.Sections.Add(importedSection);
});
return acc;
});
result.Save("Result.pdf");
Merge DOCX, PDF, RTF and HTML documents to one in C#
Combining different types of documents into a single file can be useful for creating reports, collections of documents, or other purposes. The SautinSoft.Document provides a powerful and easy-to-use API for this task. You can combine both one file type and several.
An example code is provided that demonstrates how to combine documents in DOCX, PDF, RTF and/or HTML formats into a single file in C# using Document.Net.
Do Reporting and Mail Merge in C#
Reporting and Mail Merge are essential features in many business applications, allowing users to generate documents populated with data from various sources. Mail Merge and Reporting are powerful features that can save time and effort in generating personalized documents.
Mail Merge is a process that allows you to create a batch of documents that are personalized for each recipient. For example, you can use Mail Merge to create a set of letters, emails, or labels that include personalized information such as names and addresses.
using System.Data.SqlClient;
using SautinSoft.Document;
DocumentCore dc = DocumentCore.Load(@"template.docx");
string connectionString = "your_connection_string";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
string query = "SELECT Name, Address FROM Customers";
SqlCommand command = new SqlCommand(query, connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
DocumentCore doc = dc.Clone();
doc.Content.Replace("{{Name}}", reader["Name"].ToString());
string outputPath = "result.docx";
doc.Save(outputPath, new DocxSaveOptions());
}
}
using SautinSoft.Document;
class Program
{
static void Main(string[] args)
{
// Loading the HTML document
DocumentCore dc = DocumentCore.Load("example.html");
// Parsing the document content
foreach (Element element in dc.Content)
{
Console.WriteLine(element.Content.ToString());
}
}
}
Load and Parse DOCX, PDF, HTML, RTF in C#
Working with various document formats such as DOCX, PDF, HTML, and RTF is an important task for many developers. So, you can use the SautinSoft.Document .Net library load and parse, for example, content manipulation.
For example, HTML is used to create web pages and can contain text, images, links, and other elements. See the sample code for loading and parsing an HTML document.
Rasterize (convert to image) DOCX to image in C#
Rasterizing a document means converting each page of a document into an image. This can be useful for various purposes, such as creating thumbnails, previewing, or simply converting a document to a format that is not editable.
Using the "Paginator" class provided by the SautinSoft.Document .Net library can convert each page of a DOCX, HTML, RTF, PDF, or Text documents into an image and then save each page as an image.
using SautinSoft.Document;
string filePath = @"..\..\..\example.docx";
string folderPath = Path.GetFullPath(@"Result-files");
DocumentCore dc = DocumentCore.Load(filePath);
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
for (int i = 0; i < dc.GetPaginator().Pages.Count; i++)
{
DocumentPage page = dc.GetPaginator().Pages[i];
string pngPath = Path.Combine(folderPath, $"Page-{i + 1}.png");
page.Rasterize(new ImageSaveOptions() { Format = SaveOptions.ImageFormat.Png, Resolution = 300 }).Save(pngPath);
}
Why choose SautinSoft.Document?
API to do everything with documents
Document .Net gives API to your Apps to: Create, Load, Modify, Convert, Merge, Sign Digitally, Find and Replace, Do Reporting, Rasterize to Image and a lot of actions with a document.
All Popular Formats & no Dependencies
Document .Net supports documents in PDF, PDF/A, DOCX, DOC, RTF, HTML and Text formats. The component is completely standalone and has no dependencies of Microsoft Office or Adobe Acrobat.
Multilingual Support
Multilingual documents support: Latin, Chinese, Japanese, Korean, Devanagari, Thai, Cyrillic, Mongolian and so forth.
Full .NET Support for Windows, Linux, and Mac
Develop for any .NET platform or major operating systems with a single code base. Use in your apps for .NET Framework, Mono, Xamarin.iOS, and Xamarin.Android.
Single DOM (Document Object Model)
Single DOM for all formats. The Document Object Model is based on MS Word. It allows to easily manipulate with Sections, Paragraphs, Tables, Lists, Text, Forms and Fields, Shapes, Pictures, Formatting, Document Properties, etc.
Reporting and Mail Merge
You can easily use the Document .Net as a fully featured Reporting Solution. Design your reports in Microsoft Word and then allow Document .Net to populate documents with data from a different data sources.
Top Features
Create a document from scratch
You can easily create a new document from scratch. Next add sections, paragraphs, tables, images and formatted text and save it to any of desired formats: PDF, DOCX, RTF, HTML or Image.
Load & Modify existing documents
Load an existing document and modify content, text formatting, change page properties, add or edit header and footer, remove or copy paragraphs, add page numbering and much more.
Merge and Split documents
Merge and split documents even in different formats, for example, DOCX with PDF. The Document Paginator splits document by pages and provides you (x,y) coordinates of each content element.
Sign digitally
Create digitally signed PDF documents. You can also add a handwritten picture for the digital signature. Supports certificate (*.pfx) with its characteristics: Password, Contact Info, etc.
Convert
Load documents in PDF, DOCX, XLSX, DOC, RTF, HTML and Text formats. Save a document to PDF, DOCX, RTF, HTML, Text, Image, XML formats. Thus, we offer you more than 40 converting directions.
Rasterize to image
Provides API to rasterize document pages to image. In other words, it's process of converting the document or its pages into raster images: PNG, JPEG, multipage TIFF or animated GIF.
Mail Merge and Reporting
Provides API to do Mail Merge, generate Reports based on .docx template and custom data source from JSON, XML, DataBase, DataSet etc. Generate Charts: pie, column, bar, line etc.
Find and Replace
Find and Replace text, content, any elements of document on specific or all pages. Replace pictures, paragraphs, tables, header and footer, anything in document.
Content Manipulation
Replace paragraphs, pictures, edit or add headers & footers, add page numbering. Take content of one document and insert to another. Edit form fields, add or remove hyperlinks.
Insert, Modify, and Remove Document Elements
Insert, edit, and remove paragraphs, text, sections, images, tables, headers, footers, footnotes, endnotes, comments, bullet lists, numbered lists, fields, hyperlinks, bookmarks, and page breaks.
Tables
Work with tables that contain grid spans, alternative rows, conditional styles, and simple or nested groups.
Generate PDF Report from JSON Data
how to dynamically generate PDF report with pictures and table based on JSON data and .docx template under .NET platform.
Save a document in PDF format
You can save the created or manipulated PDF document to file system using.
Сombining different formats into a file
Here we'll show you how to merge: PDF, DOCX, Txt in single PDF file.
Load a HTML document
The dc object represents a document loaded into memory. The file format is detected automatically from the file extension: ".Html".
After loading you'll get the document presented as the Tree Of Objects, where the root node is DocumentCore class.
Explore the Advanced Features
Actually the component can do anything you want with a document. Even to operate with BookMarks, Revisions and Track Changes, Table of Contents, Forms and Fields and a lot of more depending of your task. See the Developer Guide to find out simple, advanced and complex examples, it contains more than 200 examples.