zoukankan      html  css  js  c++  java
  • C# word 图片大小

    通过Office自带的类库word文档中插入图片,图片大小的单位为磅

    而文档中,图片的大小已经固定,为CM。

    实际工作中,首先将图片插入到word中,根据目前的大小,计算转换为目标大小的比率,将长宽按照目标大小进行缩放即可。

    msword.InlineShape spa = oOperateDoc.Tables[oOperateDoc.Tables.Count].Cell(1, 1).Range.InlineShapes.AddPicture(jietuA);
    float yuanwidth = spa.Width;
    float yuanheidht = spa.Height;
    double bilv = GetChangepicSizeRation(yuanwidth,yuanheidht, targetW, targetH);
    spa.Width = (float)(yuanwidth * bilv);
    spa.Height = (float)(yuanheidht * bilv);
    

      

    private double GetChangepicSizeRation(double width_pt, double height_pt, double targetWidthCM, double targetHeightCM)
            {
                //CM转pt
                double p = 0.03527;// 0.03759;  //1pt=0.3759mm
                double TargetWdithPt = targetWidthCM / p;
                double TargetHeightPt = targetHeightCM / p;
                double[] bilv = new double[2];
                bilv[0] = TargetWdithPt / width_pt;
                bilv[1] = TargetHeightPt / height_pt;
                return (bilv[0] > bilv[1] ? bilv[1] : bilv[0]);
            }
    

       

  • 相关阅读:
    购物车升级版本
    python购物车-基础版本
    ubuntu制作离线包
    记录:一次数据库被恶意修改配置文件的问题
    kafka监控
    python基础day3
    python基础day1
    openstack部署之Horizon
    openstack部署之创建第一个实例
    openstack部署之neutron
  • 原文地址:https://www.cnblogs.com/DayDreamEveryWhere/p/7723133.html
Copyright © 2011-2022 走看看