PDF/eBook export automation
fdicarlo opened this issue · 0 comments
fdicarlo commented
Based on https://github.com/fdicarlo/RHCSA_cs a possible improvement (connected to #1 is to automate the export of the chapters through Ruby/Python script in a PDF or ePub/mobi format for a consumption with eBook reader.
A script could be:
bookname = "Unofficial AZ-900 Study Guide"
chapters = Array.new
Dir["./chapters/*"].entries.each { |n| chapters.push(n) if File.file?(n) && n.include?("draft") }
chapters.sort!
chap = chapters.join(' ')
puts "Building EPUB - /compile/#{bookname}.epub..."
`pandoc -S --epub-metadata=metadata.xml -o compile/#{bookname}.epub title.txt #{chap} --toc --smart --epub-stylesheet=./templates/epub.css
# --epub-cover-image=./Cover_demo.png`
puts "...done!"
puts "Building MOBI - /compile/#{bookname}.mobi..."
`kindlegen compile/#{bookname}.epub`
puts "...done!"
puts "Building PDF - /compile/#{bookname}-A4.pdf..."
`pandoc -S --epub-metadata=metadata.xml -o compile/#{bookname}-A4.pdf title.txt #{chap} --toc --smart --epub-stylesheet=./templates/epub.css --epub-cover-image=./Cover_demo.png`
puts "...done!"
puts "Building PDF - /compile/#{bookname}-A5.pdf..."
`pandoc -S --epub-metadata=metadata.xml --template=./templates/a5.tex -o compile/#{bookname}-A5.pdf title.txt #{chap} --toc --smart --epub-stylesheet=./templates/epub.css --epub-cover-image=./Cover_demo.png`
puts "...done!"