zoukankan      html  css  js  c++  java
  • pechkin 导出https路径的图片

    使用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
    

      

  • 相关阅读:
    线程
    开启程序子进程的方式
    multiprocess模块
    计算机网络小知识
    解决粘包问题
    网络编程相关
    反射与元类
    多态相关
    封装相关与接口
    类的继承和组合
  • 原文地址:https://www.cnblogs.com/q251458060/p/13276825.html
Copyright © 2011-2022 走看看