using Hotline.Application.ExportWord;
using Hotline.Share.Enums.Article;

namespace Hotline.Application.Tools;
public static class StringExtensions
{
    public static Stream HtmlToWord(this string value)
    {
        return WordHelper.ConvertHtmlToWord(value);
    }

    public static Stream HtmlToPDF(this string value)
    {
        return WordHelper.ConvertHtmlToPdf(value);
    }

    public static Stream HtmlToStream(this string value, EFileType fileType)
    {
        if (fileType == EFileType.pdf) return value.HtmlToPDF();
        if (fileType == EFileType.word) return value.HtmlToWord();
        throw new NotImplementedException($"无效的 fileType 入参: {fileType}");
    }
}
