vscode-markdown-pdf icon indicating copy to clipboard operation
vscode-markdown-pdf copied to clipboard

Would it support command line convert?

Open TangChangcheng opened this issue 5 years ago • 10 comments

It will be more convenient if command-line is supported

TangChangcheng avatar Nov 27 '19 10:11 TangChangcheng

We have several markdown files that are created by a variety of people at any time, it really would be useful in our case to execute the pdf conversion from the command line as well (versus right clicking dozens of times). I also checked if VSCode had a straightforward to just automate right clicking but didn't see anything.

ronaldpetty avatar Apr 20 '20 21:04 ronaldpetty

badly missing command line tool for linux...

bladerunner2020 avatar Jun 17 '22 15:06 bladerunner2020

Command line

Currently tested in the following environments:

  • node v14.15.5
  • windows11
# install
> npm i -g markdown-to-file

# help
> m2f
Usage: m2f <md> [type] [options...]
       md      -- path to markdown file to convert
       type    -- Output file format: pdf|html|jpeg|png|all
       options -- See: https://github.com/wll8/markdown-to-file
   Eg:
       m2f README.md
       m2f README.md html
       m2f README.md pdf outputDirectory=./mydoc/ markdown-it-include.enable=false

wll8 avatar Aug 12 '22 09:08 wll8

Command line

Currently tested in the following environments:

  • node v14.15.5
  • windows11

Thanks. Tested on Mac and Ubuntu Server 20.04. It works on Mac and doesn't work on Ubuntu. It converted to html only if it is run on Ubuntu. No error messages but it left temporary html file when I tried to convert md to pdf.

bladerunner2020 avatar Aug 13 '22 08:08 bladerunner2020

@bladerunner2020 Not sure if the requirement must require Ubuntu to have the UI system installed.

You can try to install vscode in Ubuntu and try to use the original plugin to see if it can be generated (probably not) to help troubleshoot the problem.

wll8 avatar Aug 15 '22 10:08 wll8

@bladerunner2020 Not sure if the requirement must require Ubuntu to have the UI system installed.

You can try to install vscode in Ubuntu and try to use the original plugin to see if it can be generated (probably not) to help troubleshoot the problem.

This should be my job, let me troubleshoot these issues.

wll8 avatar Aug 15 '22 10:08 wll8

Please try to install the following dependencies in ubuntu:

sudo apt update
sudo apt install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

I went through the above steps and can export the pdf successfully.

For details, please refer to chrome-headless-doesnt-launch-on-unix

wll8 avatar Aug 15 '22 10:08 wll8

A new version of markdown-to-file has been released which does not mask the error log.

wll8 avatar Aug 15 '22 11:08 wll8

Please try to install the following dependencies in ubuntu:

sudo apt update
sudo apt install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

I went through the above steps and can export the pdf successfully.

For details, please refer to chrome-headless-doesnt-launch-on-unix

Now it does work! That's incredible! Now we can setup our CI for documentation. Thank you very much.

The only thing left - need to find out the best way to install chromium to avoid installation of first run.

bladerunner2020 avatar Aug 16 '22 07:08 bladerunner2020

I have created a docker image to use markdown-to-file as part of CI/CD job. https://hub.docker.com/repository/docker/bladerunner2020/markdown-to-file

bladerunner2020 avatar Aug 16 '22 11:08 bladerunner2020