Home Forums Platforms WP e-Commerce Plugin Ideas Add PDF support to Printable Invoices Reply To: Add PDF support to Printable Invoices


just saw this, perhaps you could adapt another plugin i’m making use of? : http://www.techna2.com/blog/documentation/wp-post-to-pdf/

^ works great for WPEC product pages. i had to make some tweaks to get it to work…

in wp-post-to-pdf.php after the line:

// Process shortcodes if selected
if ($this->options['processShortcodes'])
$post->post_content = do_shortcode($post->post_content);

i added:

// Strip HTML formatting (i.e. post-text = strip_tags(post-text, 'exceptions') )
// http://www.php.net/manual/en/function.strip-tags.php
$post->post_content = strip_tags($post->post_content, '');

// Get post image (http://wordpress.org/extend/plugins/wp-get-post-image/)
if (function_exists('wp_get_post_image'))
$image = wp_get_post_image('width=500&parent_id='.$post->ID);

… and further down, i updated the output to:

// Set some content to print
$html = " . html_entity_decode($post->post_title, ENT_QUOTES) . ";
$html = html_entity_decode($image, ENT_QUOTES);
$html .= html_entity_decode($post->post_content, ENT_QUOTES);

the result is a clean pdf with the main post image above it.

then i edited the generate_pdf_file() function to include the wpsc-product page type:

if ('post' != $post->post_type and 'page' != $post->post_type and 'wpsc-product' != $post->post_type)

… using icon position = ‘manual’ setting under options, simply included the code in the single product page template.