1
I have a php page that receives values from a form (post) and wanted to print this results on paper.
It turns out that by clicking the button the value in the textarea does not appear in the print.
On the origin page I have this form with textarea and a button to print, so:
<form method="post">
<p><textarea name="textoImprimir" cols="" rows="" class="anamnese-tarea">quero imprimir este texto que acabei de digitar.</textarea></p>
<p><iframe src="imprimir.php" name="frame1" style="display:none;"></iframe>
<input type="button" onclick="frames['frame1'].print()" value="print!"></p>
</form>
On the page print.php I have so:
<?php
$textoImprimir = $_POST['textoImprimir'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Imprimir</title>
<style>
html, body { width:100%; height:100%; margin:0px; }
.fundo { background: url(../_imagens/fundo_print.png);
background-size: 100% 100%;
background-repeat: no-repeat;
}
@page {
size: A4;
margin: 15mm 15mm 15mm 15mm;
}
table { top:18%; bottom:20%; position:absolute; }
</style>
</head>
<body class="fundo">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20%" align="center" valign="middle">ALGUM TEXTO</td>
</tr>
<tr>
<td height="80%" align="justify" valign="top"><?php echo $imprimir;?></td>
</tr>
</table>
</body>
</html>
that’s right, simplest thing... at the bottom of the page I added the forwarding to the source page (regardless if print, save to pdf or cancel) and it was perfect. Thank you.
– user26858
I came across a problem: if I add css or even an image on the print.php page, it no longer works. There’s a way around this?
– user26858
You added that way Peter?
– Sr. André Baill
André, on the other page I put a table and in the middle of the cell an image, like this: <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom:#666 thin Solid;"> <tr> <td align="center" valign="bottom"><img src="image.png" width="100" height="100" /></td> </tr> <tr> <td> </td> </tr> </table>
– user26858