A simple script to allow you to export all your blog posts to a nicely formatted PDF file
Table of Contents
I wanted a way to output all the posts in my WordPress blog to a nicely formatted PDF file but none of the existing WordPress plugins worked so I decided to build my own script.
Running the script is very straight forward:
- download the code
- run php index.php
You can read more about how this all works in this blog post.
Requirements are very simple, it requires the following:
- PHP (I tested on v7.4.33)
- a WordPress blog and your WordPress Application Password (see this blog post for details of how to do that).
- Clone the repo:
git clone https://github.com/williamsdb/wordpress-to-pdf.git
- Run the code:
php index.php "URL of your site" "name of the WordPress user" "your Application Password" "local folder where you would like the output placed"
You will see output similar to the following:
The last step, “Writing output file” takes quite a while so don’t worry if it doesn’t seem to be responding.
For more information, please refer to the this blog post
- only the featured image is supported, any in the body of the post will be silently dropped. Also, videos of any sort are not supported.
- only simple text formatting is supported (bold, italics and plain text) everything else will look strange
- only character set Windows-1252 is supported which means any non-English characters and other non-standard characters such as emojis will be dropped
- WordPress code blocks are only partially supported and have no code formatting.
There are no plans to fix these issues and more likely is a rewrite of the code to support UTF-8. Keep an eye on my site for more information.
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the GNU General Public License v3.0. See LICENSE
for more information.
Your Name - @spokenlikeageek - Contact
Project Link: https://github.com/williamsdb/wordpress-to-pdf