69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using MigraDoc.DocumentObjectModel;
|
|
using MigraDoc.Rendering;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Controls
|
|
{
|
|
public partial class LargeTextComponent : Component
|
|
{
|
|
private Document? _document;
|
|
|
|
private Section? _section;
|
|
|
|
public LargeTextComponent()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public LargeTextComponent(IContainer container)
|
|
{
|
|
container.Add(this);
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
[Obsolete]
|
|
public void CreateDocument(string docPath, string title, string[] rows)
|
|
{
|
|
if (string.IsNullOrEmpty(docPath))
|
|
{
|
|
throw new ArgumentNullException("Введите путь до файла!");
|
|
}
|
|
if (string.IsNullOrEmpty(title))
|
|
{
|
|
throw new ArgumentNullException("Введите заголовок");
|
|
}
|
|
if (rows.Length <= 0)
|
|
{
|
|
throw new ArgumentNullException("Нету данных для сохранения");
|
|
}
|
|
|
|
_document = new Document();
|
|
var style = _document.Styles["Normal"];
|
|
style.Font.Name = "Times New Roman";
|
|
style.Font.Size = 14;
|
|
|
|
_section = _document.AddSection();
|
|
|
|
var paragraph = _section.AddParagraph(title);
|
|
paragraph.Format.SpaceAfter = "0.1cm";
|
|
paragraph.Format.Font.Bold = true;
|
|
foreach (var row in rows)
|
|
{
|
|
_section.AddParagraph(row);
|
|
}
|
|
|
|
var renderer = new PdfDocumentRenderer(true);
|
|
renderer.Document = _document;
|
|
renderer.RenderDocument();
|
|
renderer.PdfDocument.Save(docPath);
|
|
}
|
|
}
|
|
}
|