专业网站建设品牌,十四年专业建站经验,服务6000+客户--广州京杭网络
免费热线:400-683-0016      微信咨询  |  联系我们

Aspose.Pdf pdf转Html,并设置保存路径,图片路径

当前位置:网站建设 > 技术支持
资料来源:网络整理       时间:2023/2/14 0:36:31       共计:3677 浏览
using System.IO; using System.Text; using Aspose.Pdf; namespace System.Extensions
{ public static class PdfConverter
    { public static string Read(Stream stream, string fullPath)
        { if (Directory.Exists(fullPath))
            {
                Directory.Delete(fullPath, true);
            }
            Directory.CreateDirectory(fullPath); try { var doc = new Document(stream); var saveOptions = new HtmlSaveOptions()
                {
                    FixedLayout = true,
                    SplitIntoPages = false,
                    SplitCssIntoPages = false,
                    RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground,
                    SpecialFolderForAllImages = fullPath
                }; var path = Path.Combine(fullPath, "i.html");
                doc.Save(path, saveOptions); string html; using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                { var reader = new StreamReader(fileStream, Encoding.UTF8);
                    html = reader.ReadToEnd();
                    reader.Close();
                }
                File.Delete(path); return html;
            } catch (Exception e)
            {
                Console.WriteLine(e); throw;
            }
        }
    }
}
版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。
·上一条:C# + OpenXML 生成 Word 文档(VS2015) | ·下一条:c# 将PPT转换成HTML

Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有    粤ICP备16019765号 

广州京杭网络科技有限公司 版权所有