wxr2pdf is an WP-CLI extension that converts the content of an WordPress Export File to PDF.
wp wxr2pdf [parameters]
Required, either
file
path to the WordPress Export File.
or
--stdin
Optional
--posttype=<posttype>
select post type. If not set,post
is used. Separate post types using colon.--language=<country_CODE>
loads languages/country_CODE.mo--paper-format=<format>
default isA4
, alternative isLetter
--paper-orientation=<oriantation>
default isP
(portarit), alternative isL
(landscape)--watermark=<text>
add watermark to the PDF, enclose in quotes if more than one word.--noimg
don't include images.--nocomments
don't include comments
Add defaults options to your wp-cli.yml
file, eksample:
wxr2pdf:
paper-format: Letter
watermark: "WXR2PDF 2019"
Export from WordPress using wp export
Convert to PDF, assuming the export is wxr-file.xml
wp wxr2pdf wxr-file.xml
wp export --stdout | wp wxr2pdf --stdin --posttype=page
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
- In
wp-content/plugins
dogit clone https://github.com/soderlind/wxr2pdf
- In
wp-content/plugins/wxr2pdf
runcomposer install
- 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 dowp export --stdout | wp wxr2pdf
- Convert to wp package
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/.