| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- # import docx
- # from flask import flash, render_template, url_for
- # from flask import current_app as app
- #from docx2pdf import convert
- # @app.route('/shownoteInfo')
- # def showdoc():
- # doc=docx.Document('upload/docx/TNIS.docx')
- #
- # #读取文本内容
- # paragraphs = [para.text for para in doc.paragraphs]
- #
- # # 读取表格内容
- # table = []
- # for tbl in doc.tables:
- # for row in tbl.rows:
- # table.append([cell.text for cell in row.cells])
- # # 读取公式
- # formulas = []
- # for para in doc.paragraphs:
- # for run in para.runs:
- # if run.element.xml.startswith('<w:fldchar w:fldcharType="begin">'):
- # formulas.append(run.text)
- #
- # # 读取图片
- # images =[]
- # # for i, image in enumerate(doc.inline_shapes):
- # # image_name = f'image_{i}.png'
- # # image_url = url_for ('static', filename=image_name)
- # # image.width, image.height = image.width // 6, image.height // 6 # 缩小图片
- # # image.inline.graphic.graphicData.pic.nvPicPr.cNvPr.name = image_name # 修改图片名称
- # # image.inline.graphic.graphicData.pic.blipfil1.blip.embed =None # 删除原有的图片内容
- # # image.inline.graphic.graphicData.pic.blipfill.blip = doc.part.add_image(image.blob, image.part.content_type) # 添加新image.blob =None #删除图片内容
- # # images.append({'filename': image_name, 'width': image.width, 'height': image.height, 'alt': image.alt})
- # return render_template('web/showword.html',doc =doc, paragraphs=paragraphs, table=table, formulas=formulas, images=images)
- #
- #
- # @app.route('/shownoteInfo2')
- # def adminlogin2():
- # return render_template('admin/a_adminlogin.html')
|