

背景需求:
每年元宵、中秋、国庆都会带大班、中班孩子做简易灯笼。用python对"对折灯笼“的纸模进行不同图案的填充(区分物权)
【教学类-39】A4红纸-国旗灯笼纸模(庆祝中华人民共和国成立74周年)_a4 打印 灯笼-CSDN博客文章浏览阅读1.1k次。【教学类-39】A4红纸-国旗灯笼纸模(庆祝中华人民共和国成立74周年)_a4 打印 灯笼
https://blog.csdn.net/reasonsummer/article/details/133420000?sharetype=blogdetail&sharerId=133420000&sharerefer=PC&sharesource=reasonsummer&spm=1011.2480.3001.8118

但是大班孩子剪灯笼纸模水平不一,即使是有线条得”钢琴对称剪”,也有很多剪断情况。


“剪的我手都酸了!”

线条多,孩子们做出来的不少灯笼,外圈的一根根线也不是完全”圆圈状“,而是几根一簇并排的样式。



这里就有两个问题:
1、十几根的线条,对部分手指肌群发展不灵活的孩子来说有难度,容易剪断、撕裂,老师补救感觉费劲——是否可以少剪几根线条。设计4-10等分的线条
2、剪“钢琴键黑线时,不少线条并没有剪到底,需要2-3刀才能到底,有些孩子说纸张遮挡继续剪的路,所以他们看不见,就没剪——裁剪线条长度短一点,剪一刀就可以的那种。3-5CM,就是非常小的灯笼呢
2、如果内部不是“圆柱”,而是“棱柱”,边线的环形弯曲效果是不是更好。——制作多边形灯笼。4-10棱柱灯笼
思路一:在word里手动做了3-8边形

做一个三变形的模板,然后复制四边形,手动拆分表格,一个一个平均列……7个模板做了很长时间



然后用把6个做成pdf(第1次没有考虑3边形,从4-8,圆形)
'''
元宵节多边形灯笼word手工制作,转打印PDF
星火讯飞、阿夏
20251202
'''
import os,time
from docx import Document
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
from docx.shared import Cm # Import Cm here
import pikepdf
import os
from docx import Document
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
from pdf2image import convert_from_path
import pikepdf
# 定义文件夹路径
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
folder_123 = path + r'\图纸'
temp_folder = path + r'\零时'
output_folder = os.path.dirname(folder_123)
os.makedirs(temp_folder, exist_ok=True)
# 获取所有docx文件
docx_files = [f for f in os.listdir(folder_123) if f.endswith('.docx')]
print(docx_files)
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(folder_123, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(2)
print(f"所有PDF文件已合并并转换为图片,保存在 {images_folder}")
import shutil
shutil.rmtree(temp_folder)
# # 合并所有的PDF文件
# pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# merger = PdfFileMerger()
# for pdf_file in pdf_files:
# pdf_path = os.path.join(temp_folder, pdf_file)
# merger.append(pdf_path)
# output_pdf_path = os.path.join(path, f'元宵节灯笼{docx_files}张.pdf')
# merger.write(output_pdf_path)
# merger.close()
# time.sleep(5)
#




打印出来我随机挑了,两个纸膜制作。并给中班孩子展示制作过程。并提到
“可以选四边形、五边形、六边形”
“这个是立体的很难!”
出生牛犊的孩子们就热烈讨论“我要四边形的!”我要三边形的“。”好难啊!“”什么时候做?“
















考虑到之前几次的大班”元宵灯“制作的情况:
孩子们初次做根本不理解制作的复杂方法(裁剪、折叠、黏贴,塑形、提手)最后都是吵着嚷着”老师帮我!”,每次做灯笼都让老师本人手忙脚乱,疲于奔命(浪费老师)。
为了给我自己减少麻烦,我决定把图纸变小,从一页A4一个灯笼变成1页2个灯笼。
这时我就明显看到“word人工制作的多边形”很难快速修改成一页两张。
于是我只能把docxz转jpg
'''
元宵节多边形灯笼word手工制作,转打印PDF
星火讯飞、阿夏
20251202
'''
import os,time
from docx import Document
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
from docx.shared import Cm # Import Cm here
import pikepdf
import os
from docx import Document
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
from pdf2image import convert_from_path
import pikepdf
# 定义文件夹路径
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
folder_123 = path + r'\图纸'
temp_folder = path + r'\零时'
output_folder = os.path.dirname(folder_123)
os.makedirs(temp_folder, exist_ok=True)
# 获取所有docx文件
docx_files = [f for f in os.listdir(folder_123) if f.endswith('.docx')]
print(docx_files)
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(folder_123, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(2)
print(f"所有PDF文件已合并并转换为图片,保存在 {images_folder}")
import shutil
shutil.rmtree(temp_folder)
# # 合并所有的PDF文件
# pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# merger = PdfFileMerger()
# for pdf_file in pdf_files:
# pdf_path = os.path.join(temp_folder, pdf_file)
# merger.append(pdf_path)
# output_pdf_path = os.path.join(path, f'元宵节灯笼{docx_files}张.pdf')
# merger.write(output_pdf_path)
# merger.close()
# time.sleep(5)
#

因为是整页截图,所以白边也在里面(实际我不需要)

插入空白word,把然后边距改成0,打印时选一页两张。勉强打印了一页两图的小灯笼。




给孩子再次示范后,并问:觉得自己不行的,举手,
2/3的孩子都要最简单。老师给他们发3边形和4边形。
1/3的孩子没有举手,发现的确是一批手艺好的。
我按照经验给这些孩子5-8变形的图纸。
操作中,果然孩子们眼睛看会了,操作还是“老师帮帮我!”
求助声音从开始就此起彼伏。代做过程中,听孩子们叫嚷,真心感觉“自己在自讨苦吃”,孩子们等得都不耐烦了。所以最初照片也没有拍。
最后没有人喊了,我拍了几张,一些能干的孩子找不到老师解决(老师忙死,不理他们),就自己研究或和同伴商议了。最后还真的做出来了。
此时拍的都是装饰照片了(安装提手、涂色装饰)


























孩子们的难点:
1、第一步是什么——把纸张剪成两张(这里的白色缝隙可以不要,两张连在一起)


2、最后一步怎么粘
三位手艺好的孩子困在最后一步“最后怎么做”。我感觉是黏贴条宽度(1CM)太窄了,可以改成2CM。


3、内部直筒的右侧空边还是不要了(实际操作中幼儿前面的步骤都搞不清楚,所以两张纸互相贴边重叠后,发现根本没黏贴的位置了。我代做时都把这条剪了)

本来想让孩子们把这个条中间的白色剪下来做提手,两个灰色保留做最后的黏贴固定。(防止连接处粘不住,翘起来)


基于实操作中的问题。我认为用word手工做不行
1、全部手工调整,无法获取不同大小——如果想让孩子先练习体验了解制作流程,就需要一页1张、2张、4张
2、手工制作,无法实现很多的”X边形“——我费了一小时,也就做了3-8边形。因为需要反复的拆分、分布列,制作粗线条边框。
实验二——python做word表格
因此,回到python,用它来制作word表格单元格
from docx import Document
from docx.shared import Cm, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_ROW_HEIGHT_RULE # Import the WD_ROW_HEIGHT_RULE enumeration
# 创建一个新的Word文档
doc = Document()
# 设置上下左右边距为0.7厘米
sections = doc.sections
for section in sections:
section.top_margin = Cm(0.7)
section.bottom_margin = Cm(0.7)
section.left_margin = Cm(0.7)
section.right_margin = Cm(0.7)
# 添加一个6行5列的表格
table = doc.add_table(rows=6, cols=5)
# 设置表格样式
table.style = 'Table Grid'
# 设置行高(通过设置单元格的最小高度)
row_heights = [Cm(1.5), Cm(10), Cm(1.5), Cm(1.5), Cm(7), Cm(1.5)]
for i, height in enumerate(row_heights):
row = table.rows[i]
for cell in row.cells:
cell.height_rule = WD_ROW_HEIGHT_RULE.AT_LEAST # Use the correct enumeration value
cell.height = height
# 设置列宽
col_widths = [Cm(4), Cm(4), Cm(4), Cm(4), Cm(1.5)]
for i, width in enumerate(col_widths):
for row in table.rows:
row.cells[i].width = width
# 保存文档
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
doc.save(path + r'\123.docx')
可以生成6行5列表格,可以实现列宽,但是无论怎么调整,行高无法实现,它永远是默认的一倍行距,无法变成我想要的6个单元格高度,

实验三——python做图片(from PIL import Image, ImageDraw)
最后就只剩下做图片了。
把手动word里面3边形模板修改,上下左右边距0,然后做一份连在一起的。顶天立地、全页面的灯笼基础图纸

代码展示(默认制作A4大小210*297,黏贴边2CM)
'''
元宵灯笼X变形3-50边型(插入WORD,一页2张一样的)
星火讯飞、阿夏
2025年2月21日
'''
from docx import Document
from docx.shared import Cm
import os
# import matplotlib.cm as cm
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
image_folder = os.path.join(path, '00多边形图片')
temp_folder = os.path.join(path, '临时')
os.makedirs(temp_folder, exist_ok=True)
# 一页2图(横板)
t = 2
# # 创建一个新的Word文档
# doc = Document()
# # 设置页面方向为横向
# section = doc.sections[0]
# new_width, new_height = section.page_height, section.page_width
# section.orientation = 1 # 1表示横向
# section.page_width = new_width
# section.page_height = new_height
# # 设置页面边距
# section.top_margin = Cm(0.7)
# section.bottom_margin = Cm(0.7)
# section.left_margin = Cm(0.7)
# section.right_margin = Cm(0.7)
# # 添加一个表格
# table = doc.add_table(rows=1, cols=2)
# # 计算列宽
column_width = (29.7 - 0.7 * 2) / 2
# # 设置列宽
# for row in table.rows:
# for cell in row.cells:
# cell.width = Cm(column_width)
# # 保存文档
# doc.save(os.path.join(path, f'{t}图.docx'))
import os
from docx import Document
from docx.shared import Cm
from docx.shared import Cm # Import Cm here
import os,time
from docx import Document
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
from docx.shared import Cm # Import Cm here
import pikepdf
# 获取123文件夹下所有图片文件名列表
image = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif'))]
image_files = []
for i in image:
for z in range(2):
# 一图复制2次
image_files.append(i)
# 将图片列表拆分成每组2个
grouped_images = [image_files[i:i + 2] for i in range(0, len(image_files), 2)]
print(grouped_images)
# 打开1.docx文件
for i in range(len(grouped_images)):
doc = Document(os.path.join(path, f'2图.docx'))
table = doc.tables[0]
for j in range(0,2):
cell = table.cell(0, j) # 0,2,4
# if image_path:
run = cell.paragraphs[0].add_run()
run.add_picture(os.path.join(image_folder,grouped_images[i][j]), width=Cm(13.26),height=Cm(20.1))
#
cell.vertical_alignment = WD_CELL_VERTICAL_ALIGNMENT.CENTER
# 保存修改后的文档
doc_path = os.path.join(temp_folder, f"{i+1:02}.docx")
doc.save(doc_path)
import os
from docx import Document
from reportlab.pdfgen import canvas
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
# 获取所有docx文件
docx_files = [f for f in os.listdir(temp_folder) if f.endswith('.docx')]
# 获取所有docx文件
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(temp_folder, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(3)
# 合并所有的PDF文件
# 获取所有生成的PDF文件
pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# 创建PdfFileMerger对象
merger = PdfFileMerger()
# 将所有PDF文件添加到合并器中
for pdf_file in pdf_files:
pdf_path = os.path.join(temp_folder, pdf_file)
merger.append(pdf_path)
# 输出合并后的PDF文件
output_pdf_path = os.path.join(path, f'元宵节灯笼3-50共{len(image)}种一页{t}张.pdf')
# output_pdf_path = os.path.join(path, f'九叠篆篆章_中2班_幼儿姓名{len(images_123)}人{int(len(images_123)/12)}张.pdf')
merger.write(output_pdf_path)
time.sleep(10)
merger.close()
print(f"所有PDF文件已合并到 {output_pdf_path}")
import shutil
shutil.rmtree(temp_folder)
虽然这段代码是一句一句的测试,观看图片效果,很费精力,但是完成后,随便多少边形都能快速实现

3边形灯笼纸膜

4边形灯笼纸膜
5边形灯笼纸膜
6边形灯笼纸膜
7边形灯笼纸膜
8边形灯笼纸膜

9边形灯笼纸膜

10变形灯笼纸模

(超过10边形的灯笼已经近似圆形灯笼了),此时内部直筒的折痕线就没有必要折叠了)

11边形纸膜
30边形纸膜
50边形纸膜
然后就是制作一个横版一页两张图的WOR模型(0.7CM的页边距)


为了便于打印,我是一页2张,都是同一个X变形模版。

代码:
'''
元宵灯笼X变形3-50边型(插入WORD,一页2张一样的)
星火讯飞、阿夏
2025年2月21日
'''
from docx import Document
from docx.shared import Cm
import os
# import matplotlib.cm as cm
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
image_folder = os.path.join(path, '01多边形图片')
temp_folder = os.path.join(path, '临时')
os.makedirs(temp_folder, exist_ok=True)
# 一页2图(横板)
t = 2
# # 创建一个新的Word文档
# doc = Document()
# # 设置页面方向为横向
# section = doc.sections[0]
# new_width, new_height = section.page_height, section.page_width
# section.orientation = 1 # 1表示横向
# section.page_width = new_width
# section.page_height = new_height
# # 设置页面边距
# section.top_margin = Cm(0.7)
# section.bottom_margin = Cm(0.7)
# section.left_margin = Cm(0.7)
# section.right_margin = Cm(0.7)
# # 添加一个表格
# table = doc.add_table(rows=1, cols=2)
# # 计算列宽
column_width = (29.7 - 0.7 * 2) / 2
# # 设置列宽
# for row in table.rows:
# for cell in row.cells:
# cell.width = Cm(column_width)
# # 保存文档
# doc.save(os.path.join(path, f'{t}图.docx'))
import os
from docx import Document
from docx.shared import Cm
from docx.shared import Cm # Import Cm here
import os,time
from docx import Document
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
from docx.shared import Cm # Import Cm here
import pikepdf
# 获取123文件夹下所有图片文件名列表
image = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif'))]
image_files = []
for i in image:
for z in range(2):
# 一图复制2次
image_files.append(i)
# 将图片列表拆分成每组2个
grouped_images = [image_files[i:i + 2] for i in range(0, len(image_files), 2)]
print(grouped_images)
# 打开1.docx文件
for i in range(len(grouped_images)):
doc = Document(os.path.join(path, f'{t}图.docx'))
table = doc.tables[0]
for j in range(0,2):
cell = table.cell(0, j) # 0,2,4
# if image_path:
run = cell.paragraphs[0].add_run()
run.add_picture(os.path.join(image_folder,grouped_images[i][j]), width=Cm(13.26),height=Cm(20.1))
#
cell.vertical_alignment = WD_CELL_VERTICAL_ALIGNMENT.CENTER
# 保存修改后的文档
doc_path = os.path.join(temp_folder, f"{i+1:02}.docx")
doc.save(doc_path)
import os
from docx import Document
from reportlab.pdfgen import canvas
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
# 获取所有docx文件
docx_files = [f for f in os.listdir(temp_folder) if f.endswith('.docx')]
# 获取所有docx文件
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(temp_folder, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(3)
# 合并所有的PDF文件
# 获取所有生成的PDF文件
pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# 创建PdfFileMerger对象
merger = PdfFileMerger()
# 将所有PDF文件添加到合并器中
for pdf_file in pdf_files:
pdf_path = os.path.join(temp_folder, pdf_file)
merger.append(pdf_path)
# 输出合并后的PDF文件
output_pdf_path = os.path.join(path, f'元宵节灯笼一页{t}张3-50边形共{len(image)}种.pdf')
# output_pdf_path = os.path.join(path, f'九叠篆篆章_中2班_幼儿姓名{len(images_123)}人{int(len(images_123)/12)}张.pdf')
merger.write(output_pdf_path)
time.sleep(10)
merger.close()
print(f"所有PDF文件已合并到 {output_pdf_path}")
import shutil
shutil.rmtree(temp_folder)

一页2图,因为有0.7CM白边,所以实际上黏贴边小于2CM。
回到第一个代码,把200的黏贴边,改成250


差不多2CM白边了。
做成PDF






同理制作1图word模板、4图word模板。

1图模板(图片大小)

2图模板(图片大小)

4图模板(图片大小)

我做了三个代码(可以合并的)

合并1图
'''
元宵灯笼X变形3-50边型(插入WORD,一页1张一样的)
星火讯飞、阿夏
2025年2月21日
'''
from docx import Document
from docx.shared import Cm
import os
# import matplotlib.cm as cm
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
image_folder = os.path.join(path, '01多边形图片')
temp_folder = os.path.join(path, '临时')
os.makedirs(temp_folder, exist_ok=True)
# 一页2图(横板)
t = 1
# # 计算列宽
column_width = (29.7 - 0.7 * 2) / t
import os
from docx import Document
from docx.shared import Cm
from docx.shared import Cm # Import Cm here
import os,time
from docx import Document
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
from docx.shared import Cm # Import Cm here
import pikepdf
# 获取123文件夹下所有图片文件名列表
image = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif'))]
image_files = []
for i in image:
for z in range(1):
# 一图复制2次
image_files.append(i)
# 将图片列表拆分成每组2个
grouped_images = [image_files[i:i + 1] for i in range(0, len(image_files), 1)]
print(grouped_images)
# 打开1.docx文件
for i in range(len(grouped_images)):
doc = Document(os.path.join(path, f'{t}图.docx'))
table = doc.tables[0]
for j in range(0,1):
cell = table.cell(0, j) # 0,1,4
# if image_path:
run = cell.paragraphs[0].add_run()
run.add_picture(os.path.join(image_folder,grouped_images[i][j]), width=Cm(20.2),height=Cm(26.45))
#
cell.vertical_alignment = WD_CELL_VERTICAL_ALIGNMENT.CENTER
# 保存修改后的文档
doc_path = os.path.join(temp_folder, f"{i+1:02}.docx")
doc.save(doc_path)
import os
from docx import Document
from reportlab.pdfgen import canvas
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
# 获取所有docx文件
docx_files = [f for f in os.listdir(temp_folder) if f.endswith('.docx')]
# 获取所有docx文件
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(temp_folder, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(3)
# 合并所有的PDF文件
# 获取所有生成的PDF文件
pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# 创建PdfFileMerger对象
merger = PdfFileMerger()
# 将所有PDF文件添加到合并器中
for pdf_file in pdf_files:
pdf_path = os.path.join(temp_folder, pdf_file)
merger.append(pdf_path)
# 输出合并后的PDF文件
output_pdf_path = os.path.join(path, f'元宵节灯笼一页{t}张3-50边形共{len(image)}种.pdf')
# output_pdf_path = os.path.join(path, f'九叠篆篆章_中2班_幼儿姓名{len(images_123)}人{int(len(images_123)/12)}张.pdf')
merger.write(output_pdf_path)
time.sleep(10)
merger.close()
print(f"所有PDF文件已合并到 {output_pdf_path}")
import shutil
shutil.rmtree(temp_folder)
合并2图
'''
元宵灯笼X变形3-50边型(插入WORD,一页2张一样的)
星火讯飞、阿夏
2025年2月21日
'''
from docx import Document
from docx.shared import Cm
import os
# import matplotlib.cm as cm
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
image_folder = os.path.join(path, '01多边形图片')
temp_folder = os.path.join(path, '临时')
os.makedirs(temp_folder, exist_ok=True)
# 一页2图(横板)
t = 2
# # 创建一个新的Word文档
# doc = Document()
# # 设置页面方向为横向
# section = doc.sections[0]
# new_width, new_height = section.page_height, section.page_width
# section.orientation = 1 # 1表示横向
# section.page_width = new_width
# section.page_height = new_height
# # 设置页面边距
# section.top_margin = Cm(0.7)
# section.bottom_margin = Cm(0.7)
# section.left_margin = Cm(0.7)
# section.right_margin = Cm(0.7)
# # 添加一个表格
# table = doc.add_table(rows=1, cols=2)
# # 计算列宽
column_width = (29.7 - 0.7 * 2) / 2
# # 设置列宽
# for row in table.rows:
# for cell in row.cells:
# cell.width = Cm(column_width)
# # 保存文档
# doc.save(os.path.join(path, f'{t}图.docx'))
import os
from docx import Document
from docx.shared import Cm
from docx.shared import Cm # Import Cm here
import os,time
from docx import Document
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
from docx.shared import Cm # Import Cm here
import pikepdf
# 获取123文件夹下所有图片文件名列表
image = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif'))]
image_files = []
for i in image:
for z in range(2):
# 一图复制2次
image_files.append(i)
# 将图片列表拆分成每组2个
grouped_images = [image_files[i:i + 2] for i in range(0, len(image_files), 2)]
print(grouped_images)
# 打开1.docx文件
for i in range(len(grouped_images)):
doc = Document(os.path.join(path, f'{t}图.docx'))
table = doc.tables[0]
for j in range(0,2):
cell = table.cell(0, j) # 0,2,4
# if image_path:
run = cell.paragraphs[0].add_run()
run.add_picture(os.path.join(image_folder,grouped_images[i][j]), width=Cm(13.26),height=Cm(20.1))
#
cell.vertical_alignment = WD_CELL_VERTICAL_ALIGNMENT.CENTER
# 保存修改后的文档
doc_path = os.path.join(temp_folder, f"{i+1:02}.docx")
doc.save(doc_path)
import os
from docx import Document
from reportlab.pdfgen import canvas
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
# 获取所有docx文件
docx_files = [f for f in os.listdir(temp_folder) if f.endswith('.docx')]
# 获取所有docx文件
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(temp_folder, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(3)
# 合并所有的PDF文件
# 获取所有生成的PDF文件
pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# 创建PdfFileMerger对象
merger = PdfFileMerger()
# 将所有PDF文件添加到合并器中
for pdf_file in pdf_files:
pdf_path = os.path.join(temp_folder, pdf_file)
merger.append(pdf_path)
# 输出合并后的PDF文件
output_pdf_path = os.path.join(path, f'元宵节灯笼一页{t}张3-50边形共{len(image)}种.pdf')
# output_pdf_path = os.path.join(path, f'九叠篆篆章_中2班_幼儿姓名{len(images_123)}人{int(len(images_123)/12)}张.pdf')
merger.write(output_pdf_path)
time.sleep(10)
merger.close()
print(f"所有PDF文件已合并到 {output_pdf_path}")
import shutil
shutil.rmtree(temp_folder)
合并4图
'''
元宵灯笼X变形3-50边型(插入WORD,一页4张一样的)
星火讯飞、阿夏
2025年2月21日
'''
from docx import Document
from docx.shared import Cm
import os
# import matplotlib.cm as cm
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
image_folder = os.path.join(path, '01多边形图片')
temp_folder = os.path.join(path, '临时')
os.makedirs(temp_folder, exist_ok=True)
# 一页2图(横板)
t = 4
# # 计算列宽
column_width = (29.7 - 0.7 * 2) / 2
import os
from docx import Document
from docx.shared import Cm
from docx.shared import Cm # Import Cm here
import os,time
from docx import Document
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
from docx.shared import Cm # Import Cm here
import pikepdf
# 获取123文件夹下所有图片文件名列表
image = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif'))]
image_files = []
for i in image:
for z in range(4):
# 一图复制2次
image_files.append(i)
# 将图片列表拆分成每组2个
grouped_images = [image_files[i:i + 4] for i in range(0, len(image_files), 4)]
print(grouped_images)
# 打开1.docx文件
for i in range(len(grouped_images)):
doc = Document(os.path.join(path, f'{t}图.docx'))
table = doc.tables[0]
for j in range(0,2):
for k in range(0,2) :
cell = table.cell(k, j) # 0,4,4
# if image_path:
run = cell.paragraphs[0].add_run()
run.add_picture(os.path.join(image_folder,grouped_images[i][j]), width=Cm(10.1),height=Cm(13.23))
#
cell.vertical_alignment = WD_CELL_VERTICAL_ALIGNMENT.CENTER
# 保存修改后的文档
doc_path = os.path.join(temp_folder, f"{i+1:02}.docx")
doc.save(doc_path)
import os
from docx import Document
from reportlab.pdfgen import canvas
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
# 获取所有docx文件
docx_files = [f for f in os.listdir(temp_folder) if f.endswith('.docx')]
# 获取所有docx文件
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(temp_folder, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(3)
# 合并所有的PDF文件
# 获取所有生成的PDF文件
pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# 创建PdfFileMerger对象
merger = PdfFileMerger()
# 将所有PDF文件添加到合并器中
for pdf_file in pdf_files:
pdf_path = os.path.join(temp_folder, pdf_file)
merger.append(pdf_path)
# 输出合并后的PDF文件
output_pdf_path = os.path.join(path, f'元宵节灯笼一页{t}张3-50边形共{len(image)}种.pdf')
# output_pdf_path = os.path.join(path, f'九叠篆篆章_中2班_幼儿姓名{len(images_123)}人{int(len(images_123)/12)}张.pdf')
merger.write(output_pdf_path)
time.sleep(10)
merger.close()
print(f"所有PDF文件已合并到 {output_pdf_path}")
import shutil
shutil.rmtree(temp_folder)
结果展示

width=Cm(20.2),height=Cm(26.45))

width=Cm(13.26),height=Cm(20.1))

width=Cm(10.1),height=Cm(13.23))

虽然实现了我想要的效果,但是我还是发现两个问题:
1、一个PDF里面有很多的图片,无法快速找到我需要的等分数字,如我需要20边形,但是图片上没有数字,找起来就很麻烦。

2、三个PDF统一使用一套图片(2100*2970,黏贴边250)。
在1图里面,图片插入后,黏贴边2.5回缩小一点。到了2图,黏贴边等比例缩2倍。到了4图里,黏贴边等比例缩小4倍。

这就不符合我希望“黏贴边”保持在2CM的限定目标(贴边宽一点,幼儿容易涂胶水,粘的面积大一点)
所以,就要做三套X边形图片,来适应1、2、4图大小,并保证黏贴边是2CM
测试,只做3-10边形灯笼
'''
202502新年05元宵节灯笼python制作图片
制作等比例的图纸,1图、2图、4图
星火讯飞、阿夏
20250221
'''
import math,os
from PIL import Image, ImageDraw, ImageFont
# 1 width=Cm(20.2),height=Cm(26.45)
# 2 width=Cm(13.26),height=Cm(20.1))
# 4 width=Cm(10.1),height=Cm(13.23))
ww=['2100','2020','1326','1010']
hh=['2970','2645','2010','1323']
nn=[0,1,2,4]
# 创建一个新的列表来存储结果
result_list_w = [1]
# 遍历列表并计算相邻数对的商
for i in range(len(ww) - 1):
num1 = int(ww[0])
num2 = int(ww[i + 1])
quotient = num1 / num2
result_list_w.append(round(quotient, 2))
print(result_list_w)
result_list_h=[1]
# 遍历列表并计算相邻数对的商
for i in range(len(hh) - 1):
num1 = int(hh[0])
num2 = int(hh[i + 1])
quotient = num1 / num2
result_list_h.append(round(quotient, 2))
print(result_list_h)
for aa in range(len(ww)):
sum=10
# 宽
w =int(ww[aa])
# 高
h = int(hh[aa])
# 骨架贴边(2厘米)
t = 200
# 上下贴边
b = int(150/result_list_h[aa])
# 外边高度(需要乘以2)
g = int(710/(result_list_h[aa]))
# 内柱高度
n = int(910/(result_list_h[aa]))
# 虚线
dash_length = 20
space_length = 20
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
pic=path+fr'\02多边形灯笼\{nn[aa]:02}灯笼多边形图片'
os.makedirs(pic,exist_ok=True)
for d in range(3,sum+1):
# X边形(可修改遍历)
# d = 3
# 创建一个2100x2900的白色背景图片
img = Image.new('RGB', (w,h), 'white')
draw = ImageDraw.Draw(img)
# 画外框图纸
border_width = 5
# 制作外边
# 画一个从(0,0)到(15,210)的长方形灰色底纹填充
# (右侧黏贴变宽度200)
rectangle_color = (128, 128, 128) # 灰色
# 两个灰色
draw.rectangle([(0, 0), (w-t, b)], fill=rectangle_color)
draw.rectangle([(0, b + g * 2), (w - t, b * 2 + g * 2)], fill=rectangle_color)
# 外边框线
draw.rectangle([(0, 0), (w - t, b * 2 + g * 2)], outline='black', width=border_width)
# 在(0, b*1+g*1)), (w-200, b*1+g*1))的地方画一条黑色2磅间隔2磅的虚线
start_y = b + g
end_y = start_y + g
for x in range(0, w - t, dash_length + space_length):
draw.line([(x, start_y), (x + dash_length, start_y)], fill='black', width=border_width)
# 画圆形
radius = 100
border_width = 10
draw.ellipse([(w-t/2 - radius, start_y - radius), (w-t/2 + radius, start_y + radius)], fill="white", outline="black", width=border_width)
# 插分等
dd = []
for x in range(d):
f = (w - t) / d * (x)
print(f)
dd.append(f)
print(dd)
# 画从0,dd到100,dd的直线(多条)
border_width2 = 10
for x in dd:
draw.line([(x, b), (x, b + g * 2)], fill='black', width=border_width2)
# 画内柱图纸
# 外边框线
draw.rectangle([(w-t,g*2+b*2), (w, h)], fill=rectangle_color, width=border_width2)
# 画白色
draw.rectangle([(0, b * 2 + g * 2), (w-t, h)], fill='white')
# border_width = 5
# 制作外边
# 画一个从(0,0)到(15,210)的长方形灰色底纹填充
# (右侧黏贴变宽度200)
rectangle_color = (150, 150, 150) # 灰色
# 两个灰色
draw.rectangle([(0, b + g * 2), (w - t, b * 3 + g * 2)], fill=rectangle_color)
draw.rectangle([(0, h - b), (w - t, h)], fill=rectangle_color)
# 外边框线
draw.rectangle([(0, b * 2 + g * 2), (w , h)], outline='black', width=border_width2)
draw.rectangle([(0, 0), (w-t, b * 2 + g * 2)], outline='black', width=border_width2)
# 如果大于10变形,棱柱近似圆形,没有必要这些棱柱的虚线,就不要画虚线了
if d>10:
pass
else:
# 插分等
dd1 = []
for x in range(d):
f = (w - t) / d * (x+1)
print(f)
dd1.append(f)
print(dd1)
# 画从0,dd到100,dd的直线(多条)
border_width2=10
# # 画从0,dd到100,dd的直线(多条)
# 设置虚线的参数
dash_length = 30 # 黑线长度
space_length = 30 # 空白间隔长度
for x1 in dd1:
start_x = x1 # 起始x坐标
end_x = start_x # 结束x坐标与起始x坐标相同,因为是竖线
start_y = b*2+g*2 # 起始y坐标
end_y = h # 结束y坐标
# 画从上到下的虚线
for y in range(start_y, end_y, dash_length + space_length):
draw.line([(start_x, y), (start_x, y + dash_length)], fill='black', width=border_width2)
# 最下面补一条黑线
# draw.line([(0, h-15), (w,h-15)], fill='black', width=border_width2)
# 写入数字
font = ImageFont.truetype("arial.ttf", 200) # 确保你有这个字体文件,或者使用其他字体文件路径
# 写入文本
if len(str(d))==1:
draw.text((w-t+80, 10), f'{d}', font=font, fill="black")
else:
draw.text((w-t, 10), f'{d}', font=font, fill="black")
# 保存图片
img.save(pic + fr'\{d:02}边形灯笼图纸(A4).png')

内部有四个文件夹,分别对应右侧的图片大小









然后将这些图片分别对应插入1图、2图、4图,看看黏贴边是否保持2CM。
'''
元宵灯笼X变形3-50边型(插入WORD,分别插入1图2图4图)
星火讯飞、阿夏
2025年2月21日
'''
from docx import Document
from docx.shared import Cm
import os,time
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
import pikepdf
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
image_folders = os.path.join(path, '02多边形灯笼')
# 获取 image_folders 目录下所有文件夹的完整路径
folder_paths = [os.path.join(image_folders, f) for f in os.listdir(image_folders) if os.path.isdir(os.path.join(image_folders, f))]
folder_paths = folder_paths[1:]
print(folder_paths)
l = [1, 2, 4]
bg = [['00'], ['00', '01'], ['00', '01', '10', '11']]
size = [['20.2', '26.45'], ['13.26', '20.1'], ['10.1', '13.23']]
# Convert size strings to floats
size = [[float(num) for num in sublist] for sublist in size]
for t in range(len(l)):
cs = l[t]
temp_folder = os.path.join(path, '临时')
os.makedirs(temp_folder, exist_ok=True)
image = [os.path.join(folder_paths[t], f) for f in os.listdir(folder_paths[t]) if f.endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif'))]
print(image)
image_files = []
for i in image:
for z in range(cs):
image_files.append(i)
grouped_images = [image_files[i:i + cs] for i in range(0, len(image_files), cs)]
print(grouped_images)
for i in range(len(grouped_images)):
doc = Document(os.path.join(path, f'{cs}图.docx'))
table = doc.tables[0]
for j in range(len(bg[t])):
pp = int(bg[t][j][0])
qq = int(bg[t][j][1])
picture = grouped_images[i][j]
print(pp, qq, picture)
cell = table.cell(pp, qq)
run = cell.paragraphs[0].add_run()
run.add_picture(f'{picture}', width=Cm(size[t][0]), height=Cm(size[t][1]))
cell.vertical_alignment = WD_CELL_VERTICAL_ALIGNMENT.CENTER
doc_path = os.path.join(temp_folder, f"{i+1:02}.docx")
doc.save(doc_path)
time.sleep(1)
import os
from docx import Document
from reportlab.pdfgen import canvas
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
# 获取所有docx文件
docx_files = [f for f in os.listdir(temp_folder) if f.endswith('.docx')]
# 获取所有docx文件
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(temp_folder, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(5)
# 合并所有的PDF文件
# 获取所有生成的PDF文件
pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# 创建PdfFileMerger对象
merger = PdfFileMerger()
# 将所有PDF文件添加到合并器中
for pdf_file in pdf_files:
pdf_path = os.path.join(temp_folder, pdf_file)
merger.append(pdf_path)
# 输出合并后的PDF文件
output_pdf_path = os.path.join(path, f'元宵灯笼2CM贴边一页{cs}张3-{len(image)+3}边形共{len(image)}种.pdf')
merger.write(output_pdf_path)
time.sleep(20)
merger.close()
print(f"所有PDF文件已合并到 {output_pdf_path}")
import shutil
shutil.rmtree(temp_folder)

A4 1页1张

A4 1页2张

A4 1页4张

黏贴边2CM对比——现在三个图纸上的黏贴边都是2CM

ok批量做3-50边形的2CM的1图、2图、4图
最终代码1-制作3-50边形灯笼纸模
'''
202502新年05元宵节灯笼python制作图片
制作等比例的图纸,1图、2图、4图
星火讯飞、阿夏
20250222
'''
import math,os
from PIL import Image, ImageDraw, ImageFont
# 1 width=Cm(20.2),height=Cm(26.45)
# 2 width=Cm(13.26),height=Cm(20.1))
# 4 width=Cm(10.1),height=Cm(13.23))
ww=['2100','2020','1326','1010']
hh=['2970','2645','2010','1323']
nn=[0,1,2,4]
ntb=200
sum=50
# 创建一个新的列表来存储结果
result_list_w = [1]
# 遍历列表并计算相邻数对的商
for i in range(len(ww) - 1):
num1 = int(ww[0])
num2 = int(ww[i + 1])
quotient = num1 / num2
result_list_w.append(round(quotient, 2))
print(result_list_w)
result_list_h=[1]
# 遍历列表并计算相邻数对的商
for i in range(len(hh) - 1):
num1 = int(hh[0])
num2 = int(hh[i + 1])
quotient = num1 / num2
result_list_h.append(round(quotient, 2))
print(result_list_h)
for aa in range(len(ww)):
# 宽
w =int(ww[aa])
# 高
h = int(hh[aa])
# 骨架贴边(2厘米)
t = ntb
# 上下贴边
b = int(150/result_list_h[aa])
# 外边高度(需要乘以2)
g = int(710/(result_list_h[aa]))
# 内柱高度
n = int(910/(result_list_h[aa]))
# 虚线
dash_length = 20
space_length = 20
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
pic=path+fr'\02多边形灯笼\{nn[aa]:02}灯笼多边形图片'
os.makedirs(pic,exist_ok=True)
for d in range(3,sum+1):
# X边形(可修改遍历)
# d = 3
# 创建一个2100x2900的白色背景图片
img = Image.new('RGB', (w,h), 'white')
draw = ImageDraw.Draw(img)
# 画外框图纸
border_width = 5
# 制作外边
# 画一个从(0,0)到(15,210)的长方形灰色底纹填充
# (右侧黏贴变宽度200)
rectangle_color = (128, 128, 128) # 灰色
# 两个灰色
draw.rectangle([(0, 0), (w-t, b)], fill=rectangle_color)
draw.rectangle([(0, b + g * 2), (w - t, b * 2 + g * 2)], fill=rectangle_color)
# 外边框线
draw.rectangle([(0, 0), (w - t, b * 2 + g * 2)], outline='black', width=border_width)
# 在(0, b*1+g*1)), (w-200, b*1+g*1))的地方画一条黑色2磅间隔2磅的虚线
start_y = b + g
end_y = start_y + g
for x in range(0, w - t, dash_length + space_length):
draw.line([(x, start_y), (x + dash_length, start_y)], fill='black', width=border_width)
# 画圆形
radius = 80
border_width = 10
draw.ellipse([(w-t/2 - radius, start_y - radius), (w-t/2 + radius, start_y + radius)], fill="white", outline="black", width=border_width)
# 插分等
dd = []
for x in range(d):
f = (w - t) / d * (x)
print(f)
dd.append(f)
print(dd)
# 画从0,dd到100,dd的直线(多条)
border_width2 = 10
for x in dd:
draw.line([(x, b), (x, b + g * 2)], fill='black', width=border_width2)
# 画内柱图纸
# 外边框线
draw.rectangle([(w-t,g*2+b*2), (w, h)], fill=rectangle_color, width=border_width2)
# 画白色
draw.rectangle([(0, b * 2 + g * 2), (w-t, h)], fill='white')
# border_width = 5
# 制作外边
# 画一个从(0,0)到(15,210)的长方形灰色底纹填充
# (右侧黏贴变宽度200)
rectangle_color = (150, 150, 150) # 灰色
# 两个灰色
draw.rectangle([(0, b + g * 2), (w - t, b * 3 + g * 2)], fill=rectangle_color)
draw.rectangle([(0, h - b), (w - t, h)], fill=rectangle_color)
# 外边框线
draw.rectangle([(0, b * 2 + g * 2), (w , h)], outline='black', width=border_width2)
draw.rectangle([(0, 0), (w-t, b * 2 + g * 2)], outline='black', width=border_width2)
# 如果大于10变形,棱柱近似圆形,没有必要这些棱柱的虚线,就不要画虚线了
if d>10:
pass
else:
# 插分等
dd1 = []
for x in range(d):
f = (w - t) / d * (x+1)
print(f)
dd1.append(f)
print(dd1)
# 画从0,dd到100,dd的直线(多条)
border_width2=10
# # 画从0,dd到100,dd的直线(多条)
# 设置虚线的参数
dash_length = 30 # 黑线长度
space_length = 30 # 空白间隔长度
for x1 in dd1:
start_x = x1 # 起始x坐标
end_x = start_x # 结束x坐标与起始x坐标相同,因为是竖线
start_y = b*2+g*2 # 起始y坐标
end_y = h # 结束y坐标
# 画从上到下的虚线
for y in range(start_y, end_y, dash_length + space_length):
draw.line([(start_x, y), (start_x, y + dash_length)], fill='black', width=border_width2)
# 最下面补一条黑线
# draw.line([(0, h-15), (w,h-15)], fill='black', width=border_width2)
# 写入数字
font = ImageFont.truetype("arial.ttf", 150) # 确保你有这个字体文件,或者使用其他字体文件路径
# 写入文本(X边形)
if len(str(d))==1:
draw.text((w-t+60, 10), f'{d}', font=font, fill="black")
else:
draw.text((w-t+18, 10), f'{d}', font=font, fill="black")
# 保存图片
img.save(pic + fr'\{d:02}边形灯笼图纸(A4).png')
最终代码2-制作3-50边形灯笼纸模的1图、2图、4图
'''
元宵灯笼X变形3-50边型(插入WORD,分别插入1图2图4图)2CM黏贴边
星火讯飞、阿夏
2025年2月22日
'''
from docx import Document
from docx.shared import Cm
import os,time
from PIL import Image
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT
from PyPDF2 import PdfFileMerger
import pikepdf
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250216元宵灯笼'
image_folders = os.path.join(path, '02多边形灯笼')
# 获取 image_folders 目录下所有文件夹的完整路径
folder_paths = [os.path.join(image_folders, f) for f in os.listdir(image_folders) if os.path.isdir(os.path.join(image_folders, f))]
folder_paths = folder_paths[1:]
print(folder_paths)
l = [1, 2, 4]
bg = [['00'], ['00', '01'], ['00', '01', '10', '11']]
size = [['20.2', '26.45'], ['13.26', '20.1'], ['10.1', '13.23']]
# Convert size strings to floats
size = [[float(num) for num in sublist] for sublist in size]
for t in range(len(l)):
cs = l[t]
temp_folder = os.path.join(path, '临时')
os.makedirs(temp_folder, exist_ok=True)
image = [os.path.join(folder_paths[t], f) for f in os.listdir(folder_paths[t]) if f.endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif'))]
print(image)
image_files = []
for i in image:
for z in range(cs):
image_files.append(i)
grouped_images = [image_files[i:i + cs] for i in range(0, len(image_files), cs)]
print(grouped_images)
for i in range(len(grouped_images)):
doc = Document(os.path.join(path, f'{cs}图.docx'))
table = doc.tables[0]
for j in range(len(bg[t])):
pp = int(bg[t][j][0])
qq = int(bg[t][j][1])
picture = grouped_images[i][j]
print(pp, qq, picture)
cell = table.cell(pp, qq)
run = cell.paragraphs[0].add_run()
run.add_picture(f'{picture}', width=Cm(size[t][0]), height=Cm(size[t][1]))
cell.vertical_alignment = WD_CELL_VERTICAL_ALIGNMENT.CENTER
doc_path = os.path.join(temp_folder, f"{i+1:02}.docx")
doc.save(doc_path)
time.sleep(1)
import os
from docx import Document
from reportlab.pdfgen import canvas
from PyPDF2 import PdfFileMerger
from docx2pdf import convert
# 获取所有docx文件
docx_files = [f for f in os.listdir(temp_folder) if f.endswith('.docx')]
# 获取所有docx文件
# 将每个docx文件转换为PDF
for docx_file in docx_files:
doc_path = os.path.join(temp_folder, docx_file)
pdf_path = os.path.join(temp_folder, docx_file.replace('.docx', '.pdf'))
convert(doc_path, pdf_path)
time.sleep(5)
# 合并所有的PDF文件
# 获取所有生成的PDF文件
pdf_files = [f for f in os.listdir(temp_folder) if f.endswith('.pdf')]
# 创建PdfFileMerger对象
merger = PdfFileMerger()
# 将所有PDF文件添加到合并器中
for pdf_file in pdf_files:
pdf_path = os.path.join(temp_folder, pdf_file)
merger.append(pdf_path)
# 输出合并后的PDF文件
output_pdf_path = os.path.join(path, f'元宵灯笼2CM贴边一页{cs}张3-{len(image)+2}边形共{len(image)}种.pdf')
merger.write(output_pdf_path)
time.sleep(20)
merger.close()
print(f"所有PDF文件已合并到 {output_pdf_path}")
import shutil
shutil.rmtree(temp_folder)

由此可见,如果刚接触这种灯笼,就使用1页4图、1页2图,图纸小,老师做起来快,幼儿操作也更容易(剪的线条距离短),让幼儿了解制作。
1页2图

1页4图

等幼儿熟悉后,可以再做一页1图的大灯笼,根据自己的能力,选择剪3条-20条(幼儿就不建议剪太细了,容易撕裂线条)

