Skip to content

Commit baa17d3

Browse files
committed
Bash script for generating pdf file from the course content
1 parent 2dcfe4f commit baa17d3

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

pdfgen.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## **Script to Generate PDF of the Course**
2+
## Usage Instructions:
3+
## - Requires `asciidoctor-pdf` to be installed on the system.
4+
## - Place this script in the root directory of your content repository.
5+
## - Run the script using: sh pdfgen.sh
6+
##
7+
## Limitations:
8+
## - This script has been tested only on Linux systems.
9+
## - Images included in the content are not rendered in the generated PDF.
10+
##
11+
## TODO:
12+
## - A better alternative would be to use one of Antora's official npm packages for PDF generation.
13+
14+
count=1
15+
filename=$(basename $(pwd)).pdf
16+
echo -ne "Processing the content repository . . "
17+
18+
for line in `cat antora.yml | grep adoc | awk '{print $2}'`
19+
do
20+
dir=`dirname $line`
21+
asciidoctor-pdf modules/ROOT/pages/index.adoc -o ./file.pdf
22+
for file in `cat $line | grep xref | sed -E 's/.*xref:([^[]+).*/\1/'`
23+
do
24+
echo -ne " . "
25+
asciidoctor-pdf $dir/pages/$file -o ./file$count.pdf > /dev/null 2>&1
26+
list="$list file$count.pdf"
27+
count=$((count+1))
28+
done
29+
done
30+
31+
echo -ne " . done\n"
32+
pdftk $list cat output $filename
33+
rm -f file*.pdf
34+
echo -e "Look for the file '$filename' generated in the current directory."

0 commit comments

Comments
 (0)