Reputation: 65
I have a HTML page that stored in PHP variable that I want to pass to another page.
It's a big page that includes a lot of text and HTML tags.
How can I pass this variable?
I tried this:
echo "
<form action=\"toPrint.php\" method=\"post\">
<input type=\"hidden\" value=\" {$output} \">
<button class=\"btn btn-info\">go to print page</button>
</form>";
But obviously it didn't work.
(Because this vaiable includes alot of html tags, it simply printed the text. probably the quotation marks inside the text, mess this up)
The reason I want to do this is because I want to send the page to a special PHP page that will present a printed version of the page without all of the menus around.
Is there other way to do that?
Thanks!
Upvotes: 0
Views: 28
Reputation: 177975
My first suggestion is to hide what you do not want to print, as detailed in How do I hide an element when printing a web page?
My second suggestion is to load the same page with a print parameter and generate the PDF from the content
Alternatively use jsPDF to grab the rendered page and output it to PDF
Lastly I suggest using htmlentities to escape the HTML
Upvotes: 1