gitbook-pdfgen
gitbook-pdfgen copied to clipboard
Add support for multipart book and non-ascii characters in file names
Thanks for your answer! I learn the gitbook and md almost begin this week, because i want to write a soft mannul with md. I just tried to change the book.json root property to my local project and failed to get something right.Please do me a faver to get the right way to generator the pdf. You can get the md project from https://github.com/MuyNooB/pas300-editor and pls give some good suggestion about my book anywhere.
You can see from the repo all Chinese so pls forgive the awesome English hha
Posting a stack trace for record:
TypeError: Cannot read property 'value' of undefined
at GitbookToWkhtmltopdf._processNodes (C:\Users\lwchkg\AppData\Roaming\npm\node_modules\gitbook-pdfgen\gen_pdf_wk.js:50:62)
at GitbookToWkhtmltopdf.process (C:\Users\lwchkg\AppData\Roaming\npm\node_modules\gitbook-pdfgen\gen_pdf_wk.js:119:10)
at configLoader.loadConfig.then.then (C:\Users\lwchkg\AppData\Roaming\npm\node_modules\gitbook-pdfgen\gen_pdf_wk.js:243:38)
at <anonymous>
I've tested a book using markdown and it's okay. Attached the [Uploading book_wk.pdf…](generated pdf) so you may have a look of the output (without gitbook-pdfgen related settings.)
BTW, I think that the Chinese file names is causing problems. I'll see if it is fixable (I don't know how wkhtmltopdf is handling the files, but currently we can't even start wkhtmltopdf).
Found the cause of the crash... You book is a multipart book which is currently NOT supported by gitbook-pdfgen
.
Thanks for your bug report and the repo, and now I'll can start to think about how gitbook-pdfgen should handle this.
For non-ASCII characters, see https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1546. The outlook is not positive.
@MuyNooB You're advised to convert these characters into English, or Pinyin.
Thanks for the quick answer! So what I should do is that first change the file and dir names into characters instead of Chinese and than wait the gitbook-pdfgen support multipart book? And i wanna know that how long you will fix the bug. I am not in urgent need that and just wanna have a date in mind. The time in America now is 1:00 am.Thanks a lot for your help
I live in Hong Kong, so in the same time zone as you.
BTW, I guess you shouldn't wait for the multiparty feature. That feature needs some engineering to be done right (not just done).
For your summary.MD, just deleting all those ###...
will fix the problem.
I don't think you need those multiparty titles at all, since there is only
one root document in each part.
On Nov 19, 2017 2:08 PM, "MuyNooB" [email protected] wrote:
Thanks for the quick answer! So what I should do is that first change the file and dir names into characters instead of Chinese and than wait the gitbook-pdfgen support multipart book? And i wanna know that how long you will fix the bug. I am not in urgent need that and just wanna have a date in mind. The time in America now is 1:00 am.Thanks a lot for your help
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lwchkg/gitbook-pdfgen/issues/2#issuecomment-345494731, or mute the thread https://github.com/notifications/unsubscribe-auth/AD7FN8NAwM7brzbMmbv2kvjLii1YKxGkks5s38XdgaJpZM4QjP4r .
Ok. Thanks for the suggestion and I will test later.
Figured out absolute file:// URL works for chinese, e.g. : D:\Downloads\pas300-editor-master\_ebook>wkhtmltopdf "file:///D:/Downloads/pas300-editor-master/_ebook/%E5%9B%BE%E5%BD%A2%E7%BC%96%E8%BE%91%E5%99%A8%E6%A6%82%E8%BF%B0/%E5%9B%BE%E5%BD%A2%E7%BC%96%E8%BE%91%E5%99%A8%E6%A6%82%E8%BF%B0.html" test.pdf
The command is long, so we need to use --read-args-from-stdin
to process the arguments. The code reading the args is found in https://github.com/wkhtmltopdf/wkhtmltopdf/blob/c754e38b074a75a51327df36c4a53f8962020510/src/pdf/wkhtmltopdf.cc. Fortunately this is cross-platform as long as non-ascii characters are not used.
Non-ascii character handling is fixed in https://github.com/lwchkg/gitbook-pdfgen/commit/adc8835e832758220490ec9d0fbc63e61a440a54. Multipart book should render, but full fix is still pending.