pechkin 导出https路径的图片


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

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

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

     #region 获得当前绝对路径
        /// 
        /// 获得当前绝对路径
        /// 
        /// 指定的路径
        /// 绝对路径
        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