Skip to content

tcsatheesh/create-pdf-from-md

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

create-pdf-from-md

This project is to create a pdf file from a markdown file.

Pre-requisites

  1. nodejs latest version

Steps

  1. Download and install the latest version of nodejs.

  2. Navigate to the folder containing the create.js file.

  3. Create or update the package.json file using your favourite editor. The contents are as below.

    {
      "name": "docs",
      "version": "1.0.0",
      "description": "Create pdf from md file.",
      "main": "",
      "scripts": {
        "create-html": "node .\\create.js <input path relative to create.js script> ./output github"
      },
      "author": "Author",
      "license": "License",
      "dependencies": {
        "markdown-styles": "^3.1.10",
        "phantom": "^4.0.12"
      }
    }
  4. Edit the input folder name and output folder name as desired in the create-html section. Input folder is the one containing the markdown files and the output folder is the one containing the html output files.

  5. In a command prompt navigate to the folder containing the create.js file and run the following command. This installs the dependencies identified in the package.json.

    npm intall
  6. Next run the following command

    npm run-script create-pdf
  7. Check the output folder contains the html files.

  8. Copy any assets like images, css etc to the output folder. Use the same folder structure when creating the markdown.

  9. Open the html in a browser and use print to pdf to generate the pdf. Note: This needs revising to automate the process.

Known Issues

  1. In Windows ensure that the "Size of text, apps and other items" in the Display properties is set to 100% before running this script. A fix is being explored.
  2. If your markdown uses other assets then copy these manually to the output folder and run the script.

About

A simple project to convert a markdown file to a pdf file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published