Skip to content

Commit

Permalink
Fix #362
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Aug 5, 2021
1 parent 3c08a45 commit 5e1ae87
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/api/test/bookmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAddSimpleBookmarks(t *testing.T) {
bms := []pdfcpu.Bookmark{
{PageFrom: 1, Title: "Page 1: Applicant’s Form"},
{PageFrom: 2, Title: "Page 2: Bold 这是一个测试", Bold: true},
{PageFrom: 3, Title: "Page 3: Italic", Italic: true, Bold: true},
{PageFrom: 3, Title: "Page 3: Italic 测试 尾巴", Italic: true, Bold: true},
{PageFrom: 4, Title: "Page 4: Bold & Italic", Bold: true, Italic: true},
{PageFrom: 16, Title: "Page 16: The birthday of Smalltalk", Color: &bookmarkColor},
{PageFrom: 17, Title: "Page 17: Gray", Color: &pdfcpu.Gray},
Expand Down
7 changes: 6 additions & 1 deletion pkg/pdfcpu/bookmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,14 @@ func createOutlineItemDict(ctx *Context, bms []Bookmark, parent *IndirectRef, pa
return nil, nil, 0, err
}

s, err := Escape(encodeUTF16String(bm.Title))
if err != nil {
return nil, nil, 0, err
}

d := Dict(map[string]Object{
"Dest": Array{*pageIndRef, Name("Fit")},
"Title": StringLiteral(encodeUTF16String(bm.Title)),
"Title": StringLiteral(*s),
"Parent": *parent},
)

Expand Down
Binary file modified pkg/samples/bookmarks/bookmarkSimple.pdf
Binary file not shown.

0 comments on commit 5e1ae87

Please sign in to comment.