This project is to create a pdf file from a markdown file.
- nodejs latest version
-
Download and install the latest version of nodejs.
-
Navigate to the folder containing the create.js file.
-
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" } }
-
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.
-
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
-
Next run the following command
npm run-script create-pdf
-
Check the output folder contains the html files.
-
Copy any assets like images, css etc to the output folder. Use the same folder structure when creating the markdown.
-
Open the html in a browser and use print to pdf to generate the pdf. Note: This needs revising to automate the process.
- 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.
- If your markdown uses other assets then copy these manually to the output folder and run the script.