wxr2pdf, convert an WordPress Export File to PDF
wxr2pdf is an WP-CLI extension that converts the content of an WordPress Export File to PDF.
wp wxr2pdf [options]
filerequired, path to the WordPress Export File.
--posttype=<posttype>select post type. If not set,
postis used. Separate post types using colon.
A4, alternative is
P(portarit), alternative is
--watermark=<text>add watermark to the PDF, enclose in quotes if more than one word.
--noimgdon't include images.
--nocommentsdon't include comments
Add defaults options to your
wp-cli.yml file, eksample:
wxr2pdf: paper-format: Letter watermark: "WXR2PDF 2019"
Export from WordPress using
Convert to PDF, assuming the export is
wp wxr2pdf wxr-file.xml wp wxr2pdf wxr-file.xml --language=nb_NO wp wxr2pdf wxr-file.xml --noimg wp wxr2pdf wxr-file.xml --posttype=post:page wp wxr2pdf wxr-file.xml --nocomments wp wxr2pdf wxr-file.xml --paper-format=Letter --watermark="WP 2019"
The example PDF is created using
wp wxr2pdf --posttype=post --watermark=WXR2PDF wxr2pdf.WordPress.2019-02-26.xml
- Site content from wptest.io
Installation and activation
git clone https://github.com/soderlind/wxr2pdf
- Activate the plugin:
wp plugin activate wxr2pdf
- What's WXR? The WordPress XML export file uses the WordPress Extended RSS format, also known as WXR.
- Why doesn't the PDF look like my site? wxr2pdf converts only the content, not the design. It tries to remove embedded shortcodes.
- Why aren't any images included in the PDF? The site and it's images must be online and accessible. Also, if images on your site are added using shortcodes, wxr2pdf might not be able to add them.
- Continue refactoring code.
- Support piping, e.g., let the user do
wp export --stdout | wp wxr2pdf
- Convert to wp package
Copyright and License
wxr2pdf is copyright 2019 Per Soderlind
wxr2pdf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
wxr2pdf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Extension. If not, see http://www.gnu.org/licenses/.