I want to be able to export a html page to PDF. I downloaded TCPDF (mainly because it allows me save High resolution images and shrinks the filesize.) The TCPDF folder is in my theme folder.
If a user clicks on a link in a certain page the current page should be saved as a PDF.
The link contains an element to pass the page ID.
<a href="<?php get_bloginfo('template_directory')?>/tcpdf/export/export_pdf.php?id=<?php echo $id; ?>">Click here to PDF this page</a>
export_pdf.php file I used
$id = $_GET['id'] to retrieve the ID from the URL.
With the ID I want to
get_post_meta($id); like that but it gives me the following error:
Fatal error: Call to undefined function get_post_meta() in...
I use get_post_meta to retrieve data from outside the loop but I think I'm wrong :-)
This is the code I use in TCPDF to write HTML:
global $post; $id = $_GET['id']; $review = get_post_meta($id); $thispost = get_post( $review ); $content = $thispost->post_content; $content; // output the HTML content $pdf->writeHTML($content, true, false, true, false, '');
I hope somebody can help me with this.