2020-07_python-docx 0.8.10 User Guide_10_Understanding pictures and other shapes

python-docx 0.8.10 User Guide

说明:

  1. 本文的内容来源python-docx官方文档,出于学习的目的借助于有道进行翻译。
  2. 翻译的原则:只有在有道翻译出的内容不通顺或意义有误的情况下才使用个人翻译。

Understanding pictures and other shapes

Conceptually, Word documents have two layers, a text layer and a drawing layer. In the text layer, text objects are flowed from left to right and from top to bottom, starting a new page when the prior one is filled. In the drawing layer, drawing objects, called shapes, are placed at arbitrary positions. These are sometimes referred to as floating shapes.
从概念上讲,Word文档有两个层,一个是文本层,一个是绘图层。在文本层中,文本对象从左到右,从上到下流动,当前面的页面被填充时开始一个新页面。在绘图层中,称为形状的绘图对象被放置在任意位置。这些有时被称为浮动形状。

A picture is a shape that can appear in either the text or drawing layer. When it appears in the text layer it is called an inline shape, or more specifically, an inline picture.
图片是一种可以出现在文本层或绘图层中的形状。当它出现在文本层时,它被称为内联形状,或者更具体地说,内联图片。

Inline shapes are treated like a big text character (a character glyph). The line height is increased to accomodate the shape and the shape is wrapped to a line it will fit on width-wise, just like text. Inserting text in front of it will cause it to move to the right. Often, a picture is placed in a paragraph by itself, but this is not required. It can have text before and after it in the paragraph in which it’s placed.
内联形状被视为大文本字符(字符符号)。行高增加以容纳形状,形状被包装成一条线,它将适合宽度,就像文本一样。在它前面插入文本将使它向右移动。通常,图片被单独放置在段落中,但这不是必需的。它可以在它所在的段落中在它之前和之后有文本。

At the time of writing, python-docx only supports inline pictures. Floating pictures can be added. If you have an active use case, submit a feature request on the issue tracker. The Document.add_picture() method adds a specified picture to the end of the document in a paragraph of its own. However, by digging a little deeper into the API you can place text on either side of the picture in its paragraph, or both.
在撰写本文时,python-docx只支持内联图片。可以添加浮动图片。如果您有一个活动的用例,那么在问题跟踪器上提交一个特性请求。add_picture()方法将指定的图片以自己的段落形式添加到文档的末尾。但是,通过稍微深入一点API,您可以在图片的段落中放置文本,或者在图片的段落中同时放置文本。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值