新增: HTML预览导出PDF并兼容Edge环境

- chromedp 通道新增源文件入口,file:// 加载原始HTML
- 相对资源在原目录天然解析,printBackground 保背景色
- 预览工具栏新增导出按钮,默认文件名取当前HTML名
- 远程文件复用站点缓存路径,本地远程同一命令
- 浏览器探测扩Chrome+Edge双查,Markdown通道重复探测归一
This commit is contained in:
lxy
2026-09-17 16:24:46 +08:00
parent 54b3f03d1f
commit e87ffe1d0c
4 changed files with 251 additions and 18 deletions
+26
View File
@@ -51,6 +51,32 @@ func (a *App) ExportPDF(content string, title string, fileName string, fontSize
}, nil
}
// ExportHtmlFileToPDF 将HTML文件导出为PDF
func (a *App) ExportHtmlFileToPDF(path string, saveName string) (map[string]interface{}, error) {
pdfAPI, err := a.requirePdfAPI()
if err != nil {
return map[string]interface{}{
"success": false,
"message": err.Error(),
}, err
}
result, err := pdfAPI.ExportHtmlFileToPDF(path, saveName)
if err != nil {
return map[string]interface{}{
"success": false,
"message": err.Error(),
}, err
}
return map[string]interface{}{
"success": result.Success,
"message": result.Message,
"path": result.Path,
"size": result.Size,
}, nil
}
// SelectPDFSaveDirectory 选择PDF保存目录
func (a *App) SelectPDFSaveDirectory() (string, error) {
pdfAPI, err := a.requirePdfAPI()