Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 0);
- if(isset($_GET['Submit'])) {
- //CONNECT TO DATABASE
- $dsn = 'mysql:dbname=csv;host=localhost;port=3306';
- $username = 'test';
- $password = 'pentaho6';
- $db = new PDO($dsn, $username, $password);
- $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $nametosearch = $_GET['id'];
- $sth = $db->prepare("SELECT StartPage, NumPages FROM new_table where CustomerNumber= :custnum");
- $sth->bindValue(':custnum', $nametosearch, PDO::PARAM_INT);
- $sth->execute();
- while ($row = $sth->fetch(PDO::FETCH_ASSOC))
- {
- $bgn=$row['StartPage'];
- $lk= $row['NumPages'];
- $end=$row['StartPage']+$row['NumPages']-1;
- }
- exec("pdftk /var/www/html/pdfconversion/VSAT.INVOICE.LV.201010.3.pdf cat $bgn-$end output output.pdf flatten");
- // Force Download the output file
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename=' . 'output.pdf' );
- header('Expires: 0');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- header('Content-Length: ' . filesize('/var/www/html/output.pdf'));
- readfile('output.pdf');
- exit;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement