• WPS的JS宏实现图片正文在同一段落的分离方法


    当图片处于正文的行尾时,有时候人眼很难判断出来。但是在编辑格式时又很容易出错,图片需要居中处理,正文需要左对齐。

    如下JS代码实现了:图文分离

    let rangShapes = Documents.Item(filepath).Range(startP,endP).InlineShapes;
        while(i<=count)
        {
            rangShapes.Item(i).Select();
            if(rangShapes.Item(i).Height >= Selection.Font.Size*2)
            {//图片高度大于正文字体高度的两倍,进行居中处理。否则判定为正文描述内容。            
                rangShapes.Item(i).Select();            
                ActiveW.Selection.MoveLeft(wdCharacter, 2, wdExtend);
                if(ActiveW.Selection.Paragraphs.Count == 1)
                {//图文在同一段落中,在图片前增加回车换行。
                    rangShapes.Item(i).Select();
                    ActiveW.Selection.MoveLeft(wdCharacter, 1, wdMove);
                    ActiveW.Selection.TypeParagraph();
                    ActiveW.Selection.Style =  "正文";
                }
                rangShapes.Item(i).Select();
                ActiveW.Selection.ParagraphFormat.CharacterUnitFirstLineIndent = 0;
                ActiveW.Selection.ParagraphFormat.FirstLineIndent = 0;
                ActiveW.Selection.ParagraphFormat.CharacterUnitLeftIndent = 0;
                ActiveW.Selection.ParagraphFormat.LeftIndent = 0;
                ActiveW.Selection.ParagraphFormat.CharacterUnitRightIndent = 0;
                ActiveW.Selection.ParagraphFormat.RightIndent = 0;
                ActiveW.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter;//图片居中      
            }                        
            i++;
        }

  • 相关阅读:
    CI/CD --git版本控制系统
    viewport 视口
    高级深入--day29
    果园自主跟随碎枝机器人
    汇编语言(第三版)第二章 寄存器 笔记
    基于JAVA商超销售系统计算机毕业设计源码+数据库+lw文档+系统+部署
    【机器学习】聚类算法Kmeans
    【老生谈算法】matlab实现图像滤波处理算法源码——图像滤波处理算法
    Spring MVC组件之HandlerMapping
    0基础学习VR全景平台篇第110篇:源图像导入和镜头预设 - PTGui Pro教程
  • 原文地址:https://blog.csdn.net/qq_27866305/article/details/125417646