]> BookStack Code Mirror - api-scripts/blob - node-docx-to-page/readme.md
Added bsfs to community project list
[api-scripts] / node-docx-to-page / readme.md
1 # Convert docx to Page
2
3 This script will take a docx file,
4 attempt to convert it to a BookStack suitable format, then upload
5 it into a BookStack book via the API.
6
7 This is a simplistic example of a NodeJS script. You will likely want to
8 alter and extend this script to suit your use-case.
9
10 ## Requirements
11
12 You will need NodeJS installed (Tested on v14, may work on earlier versions).
13 Images can be converted and uploaded via this but this requires Base64 image support
14 by BookStack so you'll need to be using BookStack v21.05.1 or greater. 
15
16 ## Running
17
18 First, download all the files in the same directory as this readme to a folder on your system
19 and run the below from within that directory.
20
21 ```bash
22 # Install NodeJS dependencies via NPM
23 npm install 
24
25 # Setup
26 # ALTERNATIVELY: Open the script and add to the empty strings in the variables at the top.
27 export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL
28 export BS_TOKEN_ID=abc123 # Set to be your API token_id
29 export BS_TOKEN_SECRET=123abc # Set to be your API token_secret
30
31 # Running the script
32 node index.js <docx_file> <book_slug>
33 ```
34
35 - `<docx_file>` - File you want to convert & upload.
36 - `<book_slug>` - The unique book identifier shown in the URL bar within BookStack (Autogenerated from the name). 
37     - For example:
38         - Book URL: https://example.com/books/bookstack-user-guide
39         - Book Slug: bookstack-user-guide
40         
41 ## Examples
42
43 ```bash
44 # Convert the 'my_content.docx' file and upload to the Book with slug 'bookstack-user-guide'
45 node index.js my_content.docx bookstack-user-guide
46 ```