首页 > Web开发 > 详细

pechkin 导出https路径的图片

时间:2020-07-09 23:53:29      阅读:136      评论:0      收藏:0      [点我收藏+]

使用Pechkin.Synchronized可以方便导出html为pdf,但是对于https路径的图片并不支持,仅支持http路径下的图片

解决方案:图片使用本地绝对路径(相对于服务器)

以下是我获取本地绝对路径的方法

     #region 获得当前绝对路径
        /// <summary>
        /// 获得当前绝对路径
        /// </summary>
        /// <param name="strPath">指定的路径</param>
        /// <returns>绝对路径</returns>
        public static string GetMapPath(string strPath)
        {
            if (strPath.ToLower().StartsWith("http://")|| strPath.ToLower().StartsWith("https://"))
            {
                return strPath;
            }
            if (HttpContext.Current != null)
            {
                return HttpContext.Current.Server.MapPath(strPath);
            }
            else //非web程序引用
            {
                strPath = strPath.Replace("/", "\\");
                if (strPath.StartsWith("\\") || strPath.StartsWith("~"))
                {
                    strPath = strPath.Substring(strPath.IndexOf(‘\\‘, 1)).TrimStart(‘\\‘);
                }
                return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
            }
        }
        #endregion

  

pechkin 导出https路径的图片

原文:https://www.cnblogs.com/q251458060/p/13276825.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!