KnpLabs / snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage

Home Page:https://knplabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error on posted value!

parkho opened this issue · comments

Hello there,
I am new to Snappy and trying to generate a PDF page from an PHP page, Below are my codes:

pdf.php file:

<?php
require_once("PersianCalendar.php");
$billno = $_POST["billno"];
$custname = $_POST["custname"];
$balance = $_POST["balance"];
$address = $_POST["address"];
$phone = $_POST["phone"];
$merchname = $_POST["merchname"];
$merchqty = $_POST["merchqty"];
$merchdetails = $_POST["merchdetails"];
function fa_number($number)
  {
     //if(!is_numeric($number) || empty($number))
     //return '۰';
     $en = array("0","1","2","3","4","5","6","7","8","9",".");
     $fa = array("۰","۱","۲","۳","۴","۵","۶","۷","۸","۹","،");
     return str_replace($en, $fa, $number);
  }

function en_number($number)
  {
     //if(!is_numeric($number) || empty($number))
     //return '۰';
     $en = array("0","1","2","3","4","5","6","7","8","9",".");
     $fa = array("۰","۱","۲","۳","۴","۵","۶","۷","۸","۹","،");
     return str_replace($fa, $en, $number);
  }
?>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Web Page</title>
<meta name="generator" content="Antenna 7.1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/mobl.css">
</head>
<body>
<div id="paper">
	<div id="image" class="abs">
		<img src="resid.png" alt="">
	</div>
	<div id="tarikh" class="abs">
		<p style="text-align: center;">
			<span style="color: black;">
				<?php
					$dynme = mds_date('l');
					$day = fa_number(mds_date('j'));
					$mnt = fa_number(mds_date('m'));
					$yr = fa_number(mds_date('Y'));
				 	echo $yr.'/'.$mnt.'/'.$day;
				?>
			</span>
		</p>
	</div>
	<div id="billno" class="abs"><p style="text-align: center;"><span style="color: black;"><?php echo fa_number($billno);?></span></p></div>
	<div id="custname1" class="abs"><p style="text-align: right;"><span style="color: black;"><?php echo $custname; ?></span></p></div>
	<div id="custname2" class="abs"><p style="text-align: right;"><span style="color: black;"><?php echo $custname; ?></span></p></div>
	<div id="mandeh" class="abs"><p style="text-align: center;"><span style="color: black;"><?php echo fa_number($balance); ?></span></p></div>
	<div id="address" class="abs"><p style="text-align: right;"><span style="color: black;"><?php echo $address; ?></span></p>	</div>
	<div id="phone" class="abs"><p style="text-align: right;"><span style="color: black;"><?php echo $phone; ?></span></p>	</div>
	<div id="merchname" class="abs"><p style="text-align: center;"><span style="color: black;"><?php echo $merchname; ?></span></p></div>
	<div id="merchqty" class="abs"><p style="text-align: center;"><span style="color: black;"><?php echo $merchqty; ?></span></p></div>
	<div id="merchdetails" class="abs"><p style="text-align: center;"><span style="color: black;"><?php echo $merchdetails; ?></span></p></div>
	<div id="send" class="abs">
		<form action="pdftest.php" method="post">
			<input type="hidden"  name="billno" value="<?php echo $billno;?>">
			<input type="hidden"  name="custname" value="<?php echo $custname;?>">
			<input type="hidden"  name="balance" value="<?php echo $balance;?>">
			<input type="hidden"  name="address" value="<?php echo $address;?>">
			<input type="hidden"  name="phone" value="<?php echo $phone;?>">
			<input type="hidden"  name="merchname" value="<?php echo $merchname;?>">
			<input type="hidden"  name="merchqty" value="<?php echo $merchqty;?>">
			<input type="hidden"  name="merchdetails" value="<?php echo $merchdetails;?>">
			<input id="send" type="submit" name="create_pdf" value="تولید">
		</form>
	</div>

</div>
</body>

And pdftest.php file:

<?php
require __DIR__ . '/snappy/vendor/autoload.php';
use Knp\Snappy\Pdf;

$billno = $_POST["billno"];
$custname = $_POST["custname"];
$balance = $_POST["balance"];
$address = $_POST["address"];
$phone = $_POST["phone"];
$merchname = $_POST["merchname"];
$merchqty = $_POST["merchqty"];
$merchdetails = $_POST["merchdetails"];
$snappy = new Pdf('C://"Program Files/"/wkhtmltopdf/bin/wkhtmltopdf.exe');
header('Content-Type: application/pdf');
$snappy->setOption('page-size', 'A5');
$snappy->setOption('no-background',false);
$snappy->setOption('margin-top', '1');
$snappy->setOption('margin-bottom', '0');
$snappy->setOption('margin-left', '0');
$snappy->setOption('margin-right', '0');
echo $snappy->getOutput('http://www.bnfgallery.ir/pdf.php');

Now when I hit the button to generate the PDF I get the missing value posted as below image while the values show correctly on pdf.php page! Any suggestions?

snappy

And this is the image for pdf.php page showing all the values posted:

snappy2