Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bookmarks: some chinese characters not displayed properly #362

Closed
kaiceo opened this issue Jul 28, 2021 · 7 comments
Closed

bookmarks: some chinese characters not displayed properly #362

kaiceo opened this issue Jul 28, 2021 · 7 comments
Assignees

Comments

@kaiceo
Copy link

kaiceo commented Jul 28, 2021

Testing text mixing chinese, digital, english and punctuation is utf8 encoding, every character is checked by utf8.ValidRune and passed.
But some text encode error , i dont know where error occured, maybe i should not use utf8 encoding, or some thing wrong from utf8 encoding to utf16 by the latest commit modification
anyway, it is awesome after this commit
use package from the latest commit, test text is below
testing str.txt

20210728112122

@hhrutter
Copy link
Collaborator

hhrutter commented Jul 28, 2021

This issue is related to the specific font (file) used in your PDF viewer.
Maybe some Private Use Area Unicode code points.
Unfortunately we cannot control the font used for rendering the outline tree AFAIK.

@hhrutter hhrutter changed the title chinese characters supported incompletely, some text encode error bookmarks: some chinese characters not displayed properly Jul 28, 2021
@kaiceo
Copy link
Author

kaiceo commented Jul 28, 2021

thanks for replying in time, i will do more tests, maybe figure out some solutions . more feedbacks will be supplied by then

@kaiceo
Copy link
Author

kaiceo commented Jul 28, 2021

Some wierd situation happened, three testing is below, all chinese words are usual, but some words including "尾" encode error, others like 密封 操作 and so on

f := "a919-2065308.pdf"
api.AddBookmarksFile(f, "out.pdf", []pdfcpu.Bookmark{{Title: "test", PageFrom: 1}}, pdfcpu.NewDefaultConfiguration())
api.AddBookmarksFile(f, "out.pdf", []pdfcpu.Bookmark{{Title: "测试", PageFrom: 1}}, pdfcpu.NewDefaultConfiguration())
api.AddBookmarksFile(f, "out.pdf", []pdfcpu.Bookmark{{Title: "尾巴", PageFrom: 1}}, pdfcpu.NewDefaultConfiguration())

image

image
image

SimSun Font.zip
a919-2065308.pdf

@hhrutter hhrutter self-assigned this Jul 28, 2021
@kaiceo
Copy link
Author

kaiceo commented Aug 4, 2021

@hhrutter I found some differences about adding chinese bookmark by api and manual.
for example : 作

  1. add bookmark by api , not displayed
    image

  2. add bookmark manually in acrobat pro, displayed normally

image

image

result is 2 has extra "5C", i dont know the reason

@hhrutter
Copy link
Collaborator

hhrutter commented Aug 4, 2021

I think I know what is going here..
The string literal needs to be escaped before it is written out to the file.
I will provide a fix.

@hhrutter
Copy link
Collaborator

hhrutter commented Aug 5, 2021

This is fixed with latest commit.
Let me know if this works for you.
Thank you for using pdfcpu 💚

@kaiceo
Copy link
Author

kaiceo commented Aug 6, 2021

it runs very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants