简体   繁体   English

DrawingML 中的剪辑

[英]Clipping in DrawingML

I am creating Word DOCX files with embedded vector graphics.我正在创建带有嵌入矢量图形的 Word DOCX 文件。 Apparently DrawingML is now the preferred way of inserting vector graphics.显然,DrawingML 现在是插入矢量图形的首选方式。 I am having trouble working out how to clip a diagram within the drawing canvas.我无法确定如何在绘图 canvas 中剪辑图表。 It seems to keep scaling my shapes within the group shape.它似乎不断在组形状中缩放我的形状。

Is clipping possible in DrawingML, and if so, does anyone have a wee snippet of code or XML to point me in the right direction?在 DrawingML 中是否可以进行剪辑,如果可以,是否有人有一小段代码或 XML 可以为我指明正确的方向?

Cropping in DrawingML is from the <scrRect/> tag. DrawingML 中的裁剪来自<scrRect/>标记。 If it is anything but empty, it means it is cropped.如果它不是空的,则意味着它已被裁剪。 This tag is used for all visual graphics, such as images, shapes, charts, etc.此标签用于所有视觉图形,例如图像、形状、图表等。

Take these two examples of an.EMF inserted in Word:以 Word 中插入的这两个 .EMF 示例为例:

    <w:drawing>
      <wp:inline distT="0" distB="0" distL="0" distR="0">
        <wp:extent cx="5934456" cy="7269480"/>
        <wp:effectExtent l="0" t="0" r="9525" b="7620"/>
        <wp:docPr id="1" name="Picture 1" descr="C:\Users\Todd\Pictures\Dotted_Lines.emf"/>
        <wp:cNvGraphicFramePr>
          <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
        </wp:cNvGraphicFramePr>
        <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
          <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
            <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
              <pic:nvPicPr>
                <pic:cNvPr id="0" name="Picture 1" descr="C:\Users\Todd\Pictures\Dotted_Lines.emf"/>
                <pic:cNvPicPr>
                  <a:picLocks noChangeAspect="1" noChangeArrowheads="1"/>
                </pic:cNvPicPr>
              </pic:nvPicPr>
              <pic:blipFill>
                <a:blip r:embed="rId5">
                  <a:extLst>
                    <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                      <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
                    </a:ext>
                  </a:extLst>
                </a:blip>
                <a:srcRect/>
                <a:stretch>
                  <a:fillRect/>
                </a:stretch>
              </pic:blipFill>
              <pic:spPr bwMode="auto">
                <a:xfrm>
                  <a:off x="0" y="0"/>
                  <a:ext cx="5934456" cy="7269480"/>
                </a:xfrm>
                <a:prstGeom prst="rect">
                  <a:avLst/>
                </a:prstGeom>
                <a:noFill/>
                <a:ln>
                  <a:noFill/>
                </a:ln>
              </pic:spPr>
            </pic:pic>
          </a:graphicData>
        </a:graphic>
      </wp:inline>
    </w:drawing>

and

<w:drawing>
          <wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="779C87CB" wp14:editId="4B126F88">
            <wp:extent cx="3390181" cy="4882551"/>
            <wp:effectExtent l="0" t="0" r="1270" b="0"/>
            <wp:docPr id="2" name="Picture 2" descr="C:\Users\Todd\Pictures\Dotted_Lines.emf"/>
            <wp:cNvGraphicFramePr>
              <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
            </wp:cNvGraphicFramePr>
            <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
              <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                  <pic:nvPicPr>
                    <pic:cNvPr id="0" name="Picture 1" descr="C:\Users\Todd\Pictures\Dotted_Lines.emf"/>
                    <pic:cNvPicPr>
                      <a:picLocks noChangeAspect="1" noChangeArrowheads="1"/>
                    </pic:cNvPicPr>
                  </pic:nvPicPr>
                  <pic:blipFill rotWithShape="1">
                    <a:blip r:embed="rId5">
                      <a:extLst>
                        <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                          <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
                        </a:ext>
                      </a:extLst>
                    </a:blip>
                    <a:srcRect l="23111" r="19768" b="32841"/>
                    <a:stretch/>
                  </pic:blipFill>
                  <pic:spPr bwMode="auto">
                    <a:xfrm>
                      <a:off x="0" y="0"/>
                      <a:ext cx="3389885" cy="4882125"/>
                    </a:xfrm>
                    <a:prstGeom prst="rect">
                      <a:avLst/>
                    </a:prstGeom>
                    <a:noFill/>
                    <a:ln>
                      <a:noFill/>
                    </a:ln>
                    <a:extLst>
                      <a:ext uri="{53640926-AAD7-44D8-BBD7-CCE9431645EC}">
                        <a14:shadowObscured xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main"/>
                      </a:ext>
                    </a:extLst>
                  </pic:spPr>
                </pic:pic>
              </a:graphicData>
            </a:graphic>
          </wp:inline>
        </w:drawing>

Note that they are the same, except for the line <a:srcRect l="23111" r="19768" b="32841"/> in the second one.请注意,它们是相同的,除了第二个中的<a:srcRect l="23111" r="19768" b="32841"/>行。 What this means is that the source rectangle (ie the image's dimensions) is cut/clipped/cropped by 23.111% off the left, 19.768% off the right and 32.841% off the bottom.这意味着源矩形(即图像的尺寸)被剪切/剪裁/裁剪了 23.111% 的左侧,19.768% 的右侧和 32.841% 的底部。 The top has not been cropped.顶部没有裁剪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM