Advertisement
Guest User

Untitled

a guest
Aug 10th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 0);
  3. if(isset($_GET['Submit'])) {
  4. //CONNECT TO DATABASE
  5. $dsn = 'mysql:dbname=csv;host=localhost;port=3306';
  6. $username = 'test';
  7. $password = 'pentaho6';
  8.  
  9. $db = new PDO($dsn, $username, $password);
  10. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11.  
  12.  
  13. $nametosearch = $_GET['id'];
  14. $sth = $db->prepare("SELECT StartPage, NumPages FROM new_table where CustomerNumber= :custnum");
  15. $sth->bindValue(':custnum', $nametosearch, PDO::PARAM_INT);
  16.  
  17. $sth->execute();
  18. while ($row = $sth->fetch(PDO::FETCH_ASSOC))
  19. {
  20. $bgn=$row['StartPage'];
  21. $lk= $row['NumPages'];
  22. $end=$row['StartPage']+$row['NumPages']-1;
  23. }
  24.  
  25. exec("pdftk /var/www/html/pdfconversion/VSAT.INVOICE.LV.201010.3.pdf cat $bgn-$end output output.pdf flatten");
  26.  
  27. // Force Download the output file
  28. header('Content-Description: File Transfer');
  29. header('Content-Type: application/octet-stream');
  30. header('Content-Disposition: attachment; filename=' . 'output.pdf' );
  31. header('Expires: 0');
  32. header('Cache-Control: must-revalidate');
  33. header('Pragma: public');
  34. header('Content-Length: ' . filesize('/var/www/html/output.pdf'));
  35.  
  36. readfile('output.pdf');
  37. exit;
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement