- Clone the workspace repository along with its submodule repository:
git clone --recurse-submodules [email protected]:MyBestHomecare/pdfmake-workspace.git
- Open the project in VS Code:
code pdfmake-workspace
- Install the recommended workspace extensions. To install, you can also run the following in the
ctrl/cmd + P
menu:ext install ritwickdey.liveserver esbenp.prettier-vscode effectful.debugger
- Open up a terminal in the workspace directory and install the node dependencies:
npm install
-
From the workspace directoy, navigate to the
src/
directory and modify theindex.js
file or any of the document definitions insidesrc/docDefinition
. You can also create local-only docDefinitions by creating files that end in.local.js
. So for example you could have:src/docDefinition/myTest.local.js
. Keep in mind that the.local.js
files will be ignored bygit
.You can use the official
pdfmake
playground and its documentation to familiarize yourself with the docDefinition syntax.From here you have 2 options:
- In the workspace directory, simply run:
npm start
- To quickly generate a PDF document, in the workspace directory run:
Alternatively, to keep a node server running that watches for changes, run:
npm run code:quick
npm run code:watch
- Finally, click on the "Go Live" button from the status bar. Alternatively, open the command pallette (
ctrl/cmd + shift + P
) and type:This requires the Live Server extension to be installed. The PDF viewer will be running onLive Server: Open With Live Server
localhost:8080
by default. This endpoint is rendering theout/index.html
file which opens the last generated PDF file (out/last.pdf
). The configuration for the live server exists in.vscode/settings.json
. To manually see a history of previously generated PDFs, navigate toout/history
.
- In the workspace directory, simply run:
- Either use the
Custom (Basic)
or theCustom (Effectful)
configurations. The latter is preferred as it allows stepping back as well as stepping forward. It requires the Effectful extension to be installed. After the code execution is finished, the resulting PDF file can be accessed either via the live server or via navigating to theout/
directory.