微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python-pptx如何将页面上边距设置为0

如何解决python-pptx如何将页面上边距设置为0

我需要在PPTX页面的顶部放置文本。
总会有3/8的上边距。下面的代码将字段设置为零,但文本从顶部开始3/8英寸。

库:python-pptx 0.6.18

ppt = Presentation()

ppt.slide_width = Inches(8.5)

ppt.slide_height = Inches(11)

left = top = Inches(0.0)

width = height = Inches(3.0)

txBox = slide.shapes.add_textBox(left,top,width,height)   

//# creating textFrames 
//# https://python-pptx.readthedocs.io/en/latest/user/text.html

tf = txBox.text_frame 

tf.word_wrap = False

tf.margin_top = Inches(0.0)     

tf.margin_bottom = Inches(0.0)

tf.margin_left = Inches(0.0)

tf.margin_right = Inches(0.0)   
                                
tf.vertical_anchor = MSO_ANCHOR.TOP                                        

p = tf.add_paragraph()  
p.alignment = PP_ALIGN.LEFT

寻求帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。