#!/bin/bash # 创建临时文件列表 temp_file="html_files.txt" # 清空临时文件 > $temp_file # 获取当前目录的绝对路径 current_dir=$(pwd) # 创建发布目录(如果不存在) mkdir -p "${current_dir}/publish" # 首先添加主页 echo "file://${current_dir}/docs/_site/docs/index.html" >> $temp_file # 添加文章 find "${current_dir}/docs/_site/docs/articles" -name "*.html" | sed 's|^|file://|' >> $temp_file # 添加示例文档 find "${current_dir}/docs/_site/docs/examples" -name "*.html" | sed 's|^|file://|' >> $temp_file # 添加API文档 find "${current_dir}/docs/_site/docs/api" -name "*.html" | sed 's|^|file://|' >> $temp_file # 构建wkhtmltopdf命令 cmd="wkhtmltopdf \ --enable-local-file-access \ --enable-javascript \ --javascript-delay 1000 \ --no-stop-slow-scripts \ --enable-external-links \ --enable-internal-links \ --page-size A4 \ --margin-top 15 \ --margin-bottom 15 \ --margin-left 20 \ --margin-right 20 \ --footer-left \"ThreatSource Library\" \ --footer-right \"[page]/[topage]\" \ --footer-spacing 5 \ --footer-font-size 8 \ --disable-smart-shrinking \ --zoom 0.8 \ --dpi 300" # 添加所有HTML文件到命令中 while IFS= read -r file; do cmd="$cmd \"$file\"" done < "$temp_file" # 添加输出文件名 cmd="$cmd \"${current_dir}/publish/ThreatSource-Library.pdf\"" # 执行命令 eval $cmd # 删除临时文件 rm $temp_file echo "PDF generation completed: publish/ThreatSource-Library.pdf"