2024-10-21 02:57:59 +04:00

60 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DocumentFormat.OpenXml.Drawing.Wordprocessing;
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml;
using MyCustomComponents.Helpers;
using MyCustomComponents.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Drawing.Diagrams;
using System.Reflection;
namespace MyCustomComponents
{
public partial class WordWithImages : Component
{
private ImageService creator;
// Конструктор по умолчанию
public WordWithImages()
{
InitializeComponent();
creator = new ImageService();
}
// Конструктор с контейнером для компонентов
public WordWithImages(IContainer container)
{
container.Add(this);
InitializeComponent();
creator = new ImageService();
}
// Метод для создания документа Word с изображениями
public void CreateDoc(WordWithImageConfig config)
{
config.CheckFields();
// Создание заголовка
creator.CreateHeader(config.Header);
// Создание и добавление всех изображений
foreach (byte[] image in config.Images)
{
creator.CreateImage(image);
}
// Сохранение файла
creator.SaveDoc(config.FilePath);
}
}
}