From c07a58131f9e4293e643132b09c56dc12f816dca Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 23 Feb 2023 12:41:50 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=AF=BC=E5=87=BA=20PDF=20=E6=97=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=B0=86=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E9=99=84=E4=BB=B6=E5=B5=8C=E5=85=A5=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7414?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/go.mod | 5 ++--- kernel/go.sum | 2 ++ kernel/model/export.go | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/kernel/go.mod b/kernel/go.mod index 9da6b4af7..f52c69d5b 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -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.20230223023428-417e2a8897ac + github.com/88250/pdfcpu v0.3.14-0.20230223031826-d2ae187e1c38 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 @@ -141,7 +141,6 @@ replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20 //replace github.com/siyuan-note/httpclient => D:\88250\httpclient //replace github.com/siyuan-note/filelock => D:\88250\filelock //replace github.com/88250/lute => D:\gogogo\src\github.com\88250\lute -replace github.com/88250/pdfcpu => D:\88250\pdfcpu - +//replace github.com/88250/pdfcpu => D:\88250\pdfcpu //replace github.com/88250/gulu => D:\88250\gulu //replace github.com/mattn/go-sqlite3 => D:\88250\go-sqlite3 diff --git a/kernel/go.sum b/kernel/go.sum index be1d02102..cfc52a2ba 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -10,6 +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.20230223031826-d2ae187e1c38 h1:MaFRabDTXOpLBrdP4qkZnjFBIUTu/rk8S6fu7hC6jCY= +github.com/88250/pdfcpu v0.3.14-0.20230223031826-d2ae187e1c38/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= diff --git a/kernel/model/export.go b/kernel/model/export.go index 73aafa7ea..b1a14c1c9 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -791,6 +791,7 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { linkMap := map[int][]pdfcpu.AnnotationRenderer{} for _, link := range otherLinks { + link.URI, _ = url.PathUnescape(link.URI) if 1 > len(linkMap[link.Page]) { linkMap[link.Page] = []pdfcpu.AnnotationRenderer{link} } else { @@ -798,7 +799,7 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { } } - attachementMap := map[int][]*pdfcpu.IndirectRef{} + attachmentMap := map[int][]*pdfcpu.IndirectRef{} now := pdfcpu.StringLiteral(pdfcpu.DateString(time.Now())) for _, link := range assetLinks { link.URI = strings.ReplaceAll(link.URI, "http://127.0.0.1:6806/export/temp/", "") @@ -883,10 +884,10 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { continue } - if 1 > len(linkMap[link.Page]) { - attachementMap[link.Page] = []*pdfcpu.IndirectRef{ann} + if 1 > len(attachmentMap[link.Page]) { + attachmentMap[link.Page] = []*pdfcpu.IndirectRef{ann} } else { - attachementMap[link.Page] = append(attachementMap[link.Page], ann) + attachmentMap[link.Page] = append(attachmentMap[link.Page], ann) } } @@ -897,7 +898,7 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { } // 添加附件注解指向内嵌的附件 - for page, anns := range attachementMap { + for page, anns := range attachmentMap { pageDictIndRef, pageErr := pdfCtx.PageDictIndRef(page) if nil != pageErr { logging.LogWarnf("page dict ind ref failed: %s", pageErr)