免费cad图纸下载网站,学校网站建设规范,网站怎么修改模板内容,望城门户网站需要nuget安装Aspose.PDF插件#xff0c;本文使用23.10.0版本
一、获取PDF文件#xff0c;保存到某个路径#xff1b;再读取返回字符串。
//html文件保存路径
string filePath dirPath xxx.html;
if (!File.Exists(filePath))
{//获取pdf文件流Byte[] pdfBy…需要nuget安装Aspose.PDF插件本文使用23.10.0版本
一、获取PDF文件保存到某个路径再读取返回字符串。
//html文件保存路径
string filePath dirPath xxx.html;
if (!File.Exists(filePath))
{//获取pdf文件流Byte[] pdfByte ……;var document new Aspose.Pdf.Document(new MemoryStream(pdfByte));document.Save(filePath, SaveFormat.Html);
}//读取刚刚保存的文件
string file File.ReadAllText(filePath);
string oldPath xxx_files;
string newPath ConfigurationManager.AppSettings[NurseHtmlIP] / oldPath;
//剔除版权文字替换本地css和图片路径 为 http路径使得在第三方接口可调用
string targetHtml file.Replace(Evaluation Only. Created with Aspose.PDF. Copyright 2002-2023 Aspose Pty Ltd.,).Replace(oldPath, newPath);
return targetHtml;
二、在用Base64加密避免格式错误。
string base64Html System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(targetHtml))); 三、前端显示js方法。
//base64转字符串
function base64ToString(str) {return decodeURIComponent(atob(str).split().map(function (c) {return % (00 c.charCodeAt(0).toString(16)).slice(-2);}).join());
}var showInfo function (htmlStr) {//把html显示到前端$(#ele_target).html(base64ToString(htmlStr));
}