wkhtmltopdf - nice free command line program which can be used to create single pdf file of multiple blog posts or pages

Over past few days, I was creating pdf blogbooks for period from around 2020 to now, for posts and pages of my two main blogs - this worldly blog and the other spiritual blog. I used the free version of BlogBooker online facility, https://blogbooker.com/ , for most of the task. That works well but the free version restricts the use as 3 times and max blog period of 1 year each time, within a utility usage period of 6 months. I quickly used up the free version runs and was able to manage two such runs. After that I still had some posts to capture in a single pdf as well as pages of the two blogs, and looked around for free software or online facility to do that other than BlogBooker. That's when I came across this wkhtmltopdf utility.

Yesterday, 25th Jun. 2023, I installed and tried out wkhtmltopdf command line program on my Microsoft Windows PC. It worked in two cases but tripped up on the third which had to be fixed by breaking up the work into parts! Overall, I found it to be a useful tool and so decided to put up a post on it.

From the main web page for the tool: https://wkhtmltopdf.org/ , "wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine."

From its help page: https://wkhtmltopdf.org/usage/wkhtmltopdf.txt , "wkhtmltopdf is able to put several objects into the output file, an object is either a single webpage, a cover webpage or a table of contents."

Given below are the key commands used to create a pdf for Year 2023 posts of this blog.

cd C:\Users\Ravi-user\Desktop\Temp

C:\'Program Files'\wkhtmltopdf\bin\wkhtmltopdf https://ravisiyermisc.blogspot.com/2023/01/creating-anchor-ids-for-content-within.html https://ravisiyermisc.blogspot.com/2023/01/miscellaneous-facebook-posts-comments.html https://ravisiyermisc.blogspot.com/2023/01/some-info-and-some-questions-about.html https://ravisiyermisc.blogspot.com/2023/02/links-to-my-recent-posts-elsewhere.html https://ravisiyermisc.blogspot.com/2023/03/in-blogger-showing-search-button.html https://ravisiyermisc.blogspot.com/2023/03/test-post.html https://ravisiyermisc.blogspot.com/2023/04/miscellaneous-facebook-posts-comments.html https://ravisiyermisc.blogspot.com/2023/06/miscellaneous-facebook-posts-comments.html https://ravisiyermisc.blogspot.com/2023/06/added-page-having-dynamically-generated.html 20230625-ravisiyermisc-20230101-20230625-posts.pdf 

The above command worked even though while running it gave some error messages. Even pictures (screenshots) are printed in the pdf. The output pdf file "20230625-ravisiyermisc-20230101-20230625-posts.pdf" can be viewed here: https://drive.google.com/file/d/1OKO9WsoUJrfaciJJoiLUDLpFQTchBCpU/view?usp=drive_link

========================

The commands to print key pages of this blog as one pdf file.

cd C:\Users\Ravi-user\Desktop\Temp

C:\'Program Files'\wkhtmltopdf\bin\wkhtmltopdf https://ravisiyermisc.blogspot.com/p/list-of-posts-in-blog-in-reverse.html https://ravisiyermisc.blogspot.com/p/all-blog-contents-all-in-one-doc-last.html 20230625-ravisiyermisc-pages.pdf

The output pdf file "20230625-ravisiyermisc-pages.pdf" can be viewed here:  https://drive.google.com/file/d/18QbZYhVCYhcyi_lLS0CEP-3u9z1nlTCz/view?usp=drive_link

========================

Single command to print key pages of my spiritual blog (ravisiyer.blogspot.com) as a single pdf file failed. Multiple commands were needed to print the key pages as a few pdf files. 

cd C:\Users\Ravi-user\Desktop\Temp

**** The program failed to print all the pages listed together and created a huge file with many empty pages. So broke it into separate runs. Given below are the separate runs that worked to print all the pages in 4 separate pdf files. *****

C:\'Program Files'\wkhtmltopdf\bin\wkhtmltopdf https://ravisiyer.blogspot.com/p/list-of-posts-in-blog-in-reverse.html https://ravisiyer.blogspot.com/p/table-of-contents.html https://ravisiyer.blogspot.com/p/consolidated-blog-content-document.html https://ravisiyer.blogspot.com/p/all-my-blogbooks-publicly-accessible-on.html 20230625-ravisiyer-pages-1.pdf


C:\'Program Files'\wkhtmltopdf\bin\wkhtmltopdf https://ravisiyer.blogspot.com/p/table-of-contents-overflow.html https://ravisiyer.blogspot.com/p/chronological-table-of-contents.html 20230625-ravisiyer-pages-2.pdf


C:\'Program Files'\wkhtmltopdf\bin\wkhtmltopdf https://ravisiyer.blogspot.com/p/about-ravi-s-iyer.html https://ravisiyer.blogspot.com/p/autobiography-of-indian-software-techie.html https://ravisiyer.blogspot.com/p/autobiography-of-indian-software-techie_14.html 20230625-ravisiyer-pages-3.pdf


C:\'Program Files'\wkhtmltopdf\bin\wkhtmltopdf https://ravisiyer.blogspot.com/p/feedback-on-my-book-who-am-i-i-am-i.html https://ravisiyer.blogspot.com/p/feedback-on-my-book-autobiography-of.html https://ravisiyer.blogspot.com/p/given-below-is-older-version-of.html 20230625-ravisiyer-pages-4.pdf

The four output files can be viewed in this Google Drive public directory:  https://drive.google.com/drive/folders/1piJNpZ_nMFw0oZlnjsqFVvBwWBi4JF1j?usp=drive_link

========================

Also see https://stackoverflow.com/questions/18601198/how-to-print-a-large-list-of-urls-to-pdf for batch file to go through list of urls file. As of now, I have not felt the need to use a file having one url per line and so I have not tried the above batch file. 

Comments