Home > other >  How in docx insert a fluctuation type images in python, which attributes or modify
How in docx insert a fluctuation type images in python, which attributes or modify

Time:09-17

 
# doc document module
The from docx import Document
The from docx. Shared import Inches, Cm # 914400 Inches (didn't get here, only look up to 914400 um=1 yards
The from docx. Oxml. Ns import qn

The from docx. Shared import Cm, Pt
The from docx. Enum. The text import WD_PARAGRAPH_ALIGNMENT

The from docx. Shared import RGBColor

# # the from PPTX. Enum. Shapes import MSO_SHAPE_TYPE type PIP python - PPTX

MyDocument=Document (' test1. Docx)

Inline_shape=myDocument. Add_picture (' temp1. JPG) insert # 111 JPG images, and obtain the shape object
Inline_shape. Height=Cm (# 4) set the picture height is 4 Cm
Inline_shape. Width=Cm (4) # set image width is 4 Cm

# can insert images in the run, but not in paragraphs insertion picture
# inline_shape=document. Paragraphs. [1] add_run () add_picture (' 111 JPG)
Inline_shape=myDocument. Paragraphs. [1] add_run () add_picture (' temp2. JPG)
Inline_shape. Height=Cm (# 6) set the picture height is 4 Cm
Inline_shape. Width=Inches (6) # set image width is 4 cm
# inline_shape. Type=1 # type the inline graphics as docx. Enum. Shape. WD_INLINE_SHAP enumeration members, such as LINKED_PICTURE, read-only

Print (dir (inline_shape))
Print (inline_shape inline_shape. Height, width, inline_shape. Type)
MyDocument. Save (' test1. Docx)


In code can be inserted into a picture, but when I used to other documents, are embedded type, want to be up and down type text around images, how to change?
  • Related