software.md
# -*- coding: utf-8 -*-
import os
f = open("software.md", "w", encoding="utf-8")
f.write('内部测试版2024 MD版\n')
for root, dirs, files in os.walk(path):
dax= os.path.basename(root)
if dax == "":
print("空白目录indexMd")
continue
f.write('## {}\n'.format(dax))
for file in files:
keyy = get_string_before_dash(file)
if webHref[keyy] != "http://www.baidu.com":
f.write('- [{}]({})\n'.format(get_string_before_dash(file),webHref[keyy]))
else:
f.write('"{}":"https://gitee.com",\n'.format(get_string_before_dash(file)))
f.write('\n')
software.pdf
# -*- coding: utf-8 -*-
import os
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.pagesizes import A4
ver = "内部测试版2024 PDF版"
# 指定PDF文件名
pdf_filename = "software.pdf"
# 设置PDF文件页面大小
c = canvas.Canvas(pdf_filename, pagesize=A4)
# 加载中文字体
pdfmetrics.registerFont(TTFont('SimSun', 'SimSun.ttf'))
# 设置字体
c.setFont('SimSun', 12)
b1 = 790
c1 = 20
# 在PDF文件中添加文本
c.drawString(250, 800, ver)
for root, dirs, files in os.walk(path):
ml= os.path.basename(root)
# print(ml) 目录
if ml == "":
print("空白目录indexPDF")
continue
if b1 > 60:
b1 = b1-30
else:
c.showPage()
c.setFont('SimSun', 12)
# c.drawString(250, 800, ver)
# break
c.drawString(c1, b1, '----------------------------------------')
c.drawString(c1, b1-7, ml)
c.drawString(c1, b1-14, '----------------------------------------')
for file in files:
sname = file[:-4]
keyy = get_string_before_dash(file)
if webHref[keyy] != "http://www.baidu.com" and b1>50:
sname = sname + " -->" + webHref[keyy]
c.drawString(c1, b1-30, sname)
b1 = b1-15
else:
c.showPage()
c.setFont('SimSun', 12)
b1 = 810
sname = sname + " -->" + webHref[keyy]
c.drawString(c1, b1-15, sname)
# break
# 关闭PDF文件
c.save()