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>
In the 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.
"I found a solution but I've got a new problem"
. Since this is a question / answer format and not a traditional forum it's best to ask one question at a time. If you have an answer to your solution it should be posted in the answer section below so that it's indexed by the website global search ( comments are not indexed in search ). If you have more questions it's best to create an entirely new question especially since it appears that the new issue is separate from the post title and bulk of the main content.x
at the end of your comment yourself :)