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

Failed to generated PDF #20

Closed
StraightUpCode opened this issue Nov 13, 2018 · 6 comments
Closed

Failed to generated PDF #20

StraightUpCode opened this issue Nov 13, 2018 · 6 comments
Labels

Comments

@StraightUpCode
Copy link

StraightUpCode commented Nov 13, 2018

Hi!
When doign md2pdf HowToMarkdown.md
I get and error when generating the PDF, I read the Troubleshooting link but I couldn't find what is cause
x generating PDF from HowToMarkdown.md → TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
I also get the same error when running md2pdf HowToMarkdown.md --config-file ./config.json
And the config looks like this

 {
  "stylesheet": [
    "https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css"
  ],
  "css": " .page-break { page-break-after: always; } .markdown-body { font-size: 11px; }",
  "body_class": "markdown-body",
  "highlight_style": "monokai",
  "marked_options": {
    "headerIds": false,
    "smartypants": true
  },
  "pdf_options": {
    "format": "A5",
    "margin": "20mm"
  },
  "stylesheet_encoding": "utf-8"
}
@simonhaenisch
Copy link
Owner

simonhaenisch commented Nov 13, 2018

Hi @StraightUpCode, can you please let me know your platform, and run the command again with the --debug flag and see if it outputs an error stack trace?

Edit: It seems that the issue is related to Puppeteer not being able to launch Chromium... maybe I should expose the puppeteer.launch() options to the config, so you can try setting args like no-sandbox?

@StraightUpCode
Copy link
Author

StraightUpCode commented Nov 13, 2018

I running Manjaro Linux Kernel : 4.18.17-1
Error Stack Trace:

{ 
ListrError: Something went wrong
    at tasks.then (/home/robertos/.nvm/versions/node/v10.11.0/lib/node_modules/md-to-pdf/node_modules/listr/index.js:102:18)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'ListrError',
  errors:
   [ Error: Failed to launch chrome!
     [1113/143107.232866:FATAL:zygote_host_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
     #0 0x559faea997df base::debug::StackTrace::StackTrace()
     #1 0x559faea12f70 logging::LogMessage::~LogMessage()
     #2 0x559faff212d0 service_manager::ZygoteHostImpl::Init()
     #3 0x559fae676906 content::ContentMainRunnerImpl::Initialize()
     #4 0x559fae6a8328 service_manager::Main()
     #5 0x559fae675111 content::ContentMain()
     #6 0x559fb2a34488 headless::(anonymous namespace)::RunContentMain()
     #7 0x559fb2a34515 headless::HeadlessBrowserMain()
     #8 0x559fae6a68b2 headless::HeadlessShellMain()
     #9 0x559fac7bd1ac ChromeMain
     #10 0x7fcd7afbc223 __libc_start_main
     #11 0x559fac7bd02a _start

     Received signal 6
     #0 0x559faea997df base::debug::StackTrace::StackTrace()
     #1 0x559faea99351 base::debug::(anonymous namespace)::StackDumpSignalHandler()
     #2 0x7fcd7da573c0 <unknown>
     #3 0x7fcd7afcfd7f __GI_raise
     #4 0x7fcd7afba672 __GI_abort
     #5 0x559faea98185 base::debug::BreakDebugger()
     #6 0x559faea133e2 logging::LogMessage::~LogMessage()
     #7 0x559faff212d0 service_manager::ZygoteHostImpl::Init()
     #8 0x559fae676906 content::ContentMainRunnerImpl::Initialize()
     #9 0x559fae6a8328 service_manager::Main()
     #10 0x559fae675111 content::ContentMain()
     #11 0x559fb2a34488 headless::(anonymous namespace)::RunContentMain()
     #12 0x559fb2a34515 headless::HeadlessBrowserMain()
     #13 0x559fae6a68b2 headless::HeadlessShellMain()
     #14 0x559fac7bd1ac ChromeMain
     #15 0x7fcd7afbc223 __libc_start_main
     #16 0x559fac7bd02a _start
       r8: 0000000000000000  r9: 00007ffe42279b10 r10: 0000000000000008 r11: 0000000000000246
      r12: 00007ffe4227a708 r13: 0000000000000161 r14: 00007ffe4227a710 r15: 00007ffe4227a718
       di: 0000000000000002  si: 00007ffe42279b10  bp: 00007ffe42279d60  bx: 0000000000000006
       dx: 0000000000000000  ax: 0000000000000000  cx: 00007fcd7afcfd7f  sp: 00007ffe42279b10
       ip: 00007fcd7afcfd7f efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
      trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
     [end of stack trace]
     Calling _exit(1). Core file will not be generated.


     TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

         at onClose (/home/robertos/.nvm/versions/node/v10.11.0/lib/node_modules/md-to-pdf/node_modules/puppeteer/lib/Launcher.js:342:14)
         at Interface.helper.addEventListener (/home/robertos/.nvm/versions/node/v10.11.0/lib/node_modules/md-to-pdf/node_modules/puppeteer/lib/Launcher.js:331:50)
         at Interface.emit (events.js:187:15)
         at Interface.close (readline.js:379:8)
         at Socket.onend (readline.js:157:10)
         at Socket.emit (events.js:187:15)
         at endReadableNT (_stream_readable.js:1092:12)
         at process._tickCallback (internal/process/next_tick.js:63:19) ],
  context: {} }

@simonhaenisch
Copy link
Owner

Yup problem seems to be that sandboxed Chromium can't be launched on your platform, and suggested way to solve it is to update your kernel, or

If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

I'll release a new version tonight that will allow to pass args (or any config option) to puppeteer, then you can try the no-sandbox thing.

@StraightUpCode
Copy link
Author

Thank you

@simonhaenisch
Copy link
Owner

Can you please try updating to latest version (2.4.0), and see whether this works for you:

md2pdf HowToMarkdown.md --launch-options '{ "args": ["--no-sandbox"] }'

@StraightUpCode
Copy link
Author

Now it works, thank you very much!

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

No branches or pull requests

2 participants