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 (将#修改为@)