Appearance
Developer API, Hooks & Shortcodes
Extend and customize Blog to PDF Exporter programmatically with actions, filters, and shortcodes.
1. Shortcode Usage
To place the PDF export button anywhere inside block content, page builders (Elementor, Divi), or custom templates:
html
[blog_to_pdf_button]Or within PHP template files:
php
<?php echo do_shortcode('[blog_to_pdf_button]'); ?>2. Filters & Hooks
Modify PDF HTML Layout
Filter the raw HTML markup before PDF rendering:
php
add_filter('b2p_pdf_content_html', function($html, $post_id) {
// Append custom disclaimer or styling
$html .= '<div class="custom-footer">Certified by Enterprise Compliance</div>';
return $html;
}, 10, 2);Alter Paper Size Programmatically
php
add_filter('b2p_pdf_page_size', function($size, $post_id) {
if (get_post_meta($post_id, '_is_whitepaper', true)) {
return 'Letter';
}
return 'A4';
}, 10, 2);3. AJAX Endpoint
PDF downloads are processed via authenticated AJAX with nonce verification:
- Action:
b2p_export_pdf - Method:
GET - Parameters:
post_id: Integer ID of the target WordPress post.nonce: Security token generated viawp_create_nonce('b2p_export_nonce_' . $post_id).