🎨 导出 PDF 时支持将资源文件作为附件嵌入 https://github.com/siyuan-note/siyuan/issues/7414

This commit is contained in:
Liang Ding 2023-02-23 10:50:08 +08:00
parent c0c605b664
commit f003aac384
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 9 additions and 9 deletions

View file

@ -3,7 +3,7 @@ import {exportLayout, getInstanceById, JSONToLayout, resetLayout, resizeDrag, re
import {hotKey2Electron, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
/// #if !BROWSER
import {dialog, getCurrentWindow} from "@electron/remote";
import {webFrame, ipcRenderer, OpenDialogReturnValue} from "electron";
import {ipcRenderer, OpenDialogReturnValue, webFrame} from "electron";
import * as fs from "fs";
import * as path from "path";
import {afterExport} from "../protyle/export/util";
@ -418,7 +418,7 @@ export const initWindow = () => {
const pdfFilePath = path.join(result.filePaths[0], replaceLocalPath(ipcData.rootTitle) + ".pdf");
fs.writeFileSync(pdfFilePath, pdfData);
window.siyuan.printWin.destroy();
fetchPost("/api/export/addPDFOutline", {
fetchPost("/api/export/processPDF", {
id: ipcData.rootId,
merge: ipcData.mergeSubdocs,
path: pdfFilePath

View file

@ -311,7 +311,7 @@ func exportHTML(c *gin.Context) {
}
}
func addPDFOutline(c *gin.Context) {
func processPDF(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
@ -326,7 +326,7 @@ func addPDFOutline(c *gin.Context) {
if nil != arg["merge"] {
merge = arg["merge"].(bool)
}
err := model.AddPDFOutline(id, path, merge)
err := model.ProcessPDF(id, path, merge)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()

View file

@ -233,7 +233,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/export/exportPreviewHTML", model.CheckAuth, exportPreviewHTML)
ginServer.Handle("POST", "/api/export/exportMdHTML", model.CheckAuth, exportMdHTML)
ginServer.Handle("POST", "/api/export/exportDocx", model.CheckAuth, exportDocx)
ginServer.Handle("POST", "/api/export/addPDFOutline", model.CheckAuth, addPDFOutline)
ginServer.Handle("POST", "/api/export/processPDF", model.CheckAuth, processPDF)
ginServer.Handle("POST", "/api/export/preview", model.CheckAuth, exportPreview)
ginServer.Handle("POST", "/api/export/exportAsFile", model.CheckAuth, exportAsFile)
ginServer.Handle("POST", "/api/export/exportData", model.CheckAuth, exportData)

View file

@ -7,7 +7,7 @@ require (
github.com/88250/css v0.1.2
github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798
github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e
github.com/88250/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2
github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20230216061320-bccdb98581a3
github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732

View file

@ -10,8 +10,8 @@ github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 h1:sR/s/Y9wyl79ZRCUER
github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e h1:7UgFzsksh+z6IX2z+BKG3tt1TU7LJNb0zOHDbhLEaUc=
github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
github.com/88250/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2 h1:M1JxCmcaLwI7qlQJD5UatAxaIT6tfLvq3GptOsMffn4=
github.com/88250/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac h1:deLsfAbzg+KJy53yJDGNe/+9RZr6RR813rbMKOiW/uI=
github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1/go.mod h1:U3pckKQIgxxkmZjV5yXQjHdGxQK0o/vEZeZ6cQsxfHw=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=

View file

@ -654,7 +654,7 @@ func processIFrame(tree *parse.Tree) {
}
}
func AddPDFOutline(id, p string, merge bool) (err error) {
func ProcessPDF(id, p string, merge bool) (err error) {
inFile := p
links, err := api.ListToCLinks(inFile)
if nil != err {