Export a single PDF with all posts, or custom post types.
Export a single PDF with all posts, or custom post types.
You can also export a single post, or the exact number you need.
IMPORTANT This plugin requires at least 512MB of free RAM available, or it will timeout / return an error.
This plugin is NOT recommended for people with no tech knowledge.
The PDF layout/design is VERY basic and will require html/css/php technical knowledge to customize.
Read more about this below.
The plugin checks if a pdf already exists with the same date (ddMonyear), if yes, the existing pdf will be served, otherwise a new will be generated. Since the PDF generation uses up a lot of resources, this will prevent too many runs of the plugin and the crashing of your server.
Check the example below or the FAQ for ways to force the PDF generation anyway.
Depending on how many posts you have, it might take from a few seconds to several minutes for a new PDF to be generated.
If no PDF is generated you probably don’t have enough server resources. This can’t be fixed, as PDF libraries are very resource-hungry.
Ask your hosting to check how many resources you would need to run the plugin and if there is anything you can do, within your hosting limits, to make sure the plugin has enough or appropriate RAM/PHP settings.
If you don’t use a custom url, hence you don’t add the post_type
parameter to the url, the default post type exported will always be WP default post
.
Currently, the template and design for the exported pdf, is very basic (and posts are rendered as a table, since floating doesn’t play nicely with the DOMPDF library).
You can copy the plugin’s basic structure from wp-content/plugins/simple-pdf-exporter/assets/pdf_layout.php
inside your current theme and edit it.
Your layout must be echoed in php, eg. echo '<div>the content goes here</div>';
or it won’t show up in the PDF.
You can copy the plugin’s basic CSS from wp-content/plugins/simple-pdf-exporter/assets/pdf_export.css
inside your current theme and edit it.
Do not edit directly the plugin’s files pdf_layout.php
and pdf_export.css
, they will be overwritten with the next update.
Check the FAQ before opening new threads in the forum!
Contact me if you want a custom version of the plugin, for a fee (email on shambix.com).
http://yoursite.com/?export=pdf
in your browser. You can also make the url into a link or button on your site, to use on frontend, please check the FAQ.In order to export a pdf, you can do it from backend from Tools -> PDF Export or enter http://yoursite.com/?export=pdf
in your browser.
You can also make the url into a link or button on your site, to use on frontend.
You can add a frontend link or button on your frontend and customize it, like in this example for Twitter Bootstrap:
Change the parameters to suit your needs.
<?php // Check if PDF Export Plugin exists first if( function_exists('simple_pdf_export_process')) { ?> <ul class="nav nav-tabs pull-right pdf_export_menu"> <li role="presentation" class="dropdown"> <a class="dropdown-toggle btn" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Export Posts to PDF <span class="caret"></span></a> <ul class="dropdown-menu"> <?php $post_type_to_export = 'portfolio'; $final_pdf = SIMPLE_PDF_EXPORTER_EXPORT.$post_type_to_export.SIMPLE_PDF_EXPORTER_EXTRA_FILE_NAME.date('dMY').'.pdf'; if(file_exists($final_pdf)) { $file_date = date("d M Y - H:i", filemtime($final_pdf)); ?> <li><a class="" href="?export=pdf&post_type=portfolio&num=3" target="_blank">Download Existing Version <small>(<?php echo $file_date; ?> GMT)</small></a></li> <?php } ?> <li><a class="" href="?export=pdf&post_type=portfolio&num=3&force" target="_blank">Generate New Version <small>(might take several minutes)</small></a></li> </ul> </li> </ul> <?php } ?>
Use &num=x
in your url.
eg. http://yoursite.com/?export=pdf&num=3
Use &post_id=x
with the ID of the post or custom post type you need, in your url.
eg. http://yoursite.com/?export=pdf&post_id=3
In this case, don’t use the post_type
parameter. The num
parameter will be ignored for obvious reasons.
Use &post_type=x
.
eg. http://yoursite.com/?export=pdf&post_type=your-post-type-slug
You need to change the file pdf_layout.php
inside the plugin folder wp-content/plugins/simple-pdf-exporter/process/pdf_layout.php
Your layout must be echoed in php. eg. echo '<div>the content goes here</div>';
or it won’t show up in the PDF.
Use &force
after your url
eg. http://yoursite.com/?export=pdf&force
This will also invalidate the internal cache, hence it will take more time to generate the PDF. Avoid if possible.
You can use a custom CSS to customize the layout.
Create a file named pdf_export.css in your theme folder, otherwise the plugin’s default (and really basic) CSS will be used (you can find it here wp-content/plugins/simple-pdf-exporter/assets/pdf_export.css
)
Yes there’s a few. In order to change them, add them to your wp-config.php
file.
eg. define(SIMPLE_PDF_EXPORTER_PAGINATION’, true);
Here’s the full list and what they are set to, by default:
You can set define(‘SIMPLE_PDF_EXPORTER_HTML_OUTPUT’, true); in your wp-config.php
file, just remember to comment the line or set to false
, when you are done debugging.
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'SIMPLE_PDF_EXPORT_SETTINGS' does not have a method 'settings_section_simple_pdf_export_settings' in /home/larucheiiz/www/wp-admin/includes/template.php on line 1643
SIMPLE_PDF_EXPORTER_DEBUG
which will output in html for debugging purposespdf_export.php
in the current theme, instead of the correct filename pdf_layout.php
– the file pdf_export.php
will still work until the next update, please rename it asap (Thanks to artifexmedia
for reporting the bug)post_id
(for exporting specific post)