Guest User

https://stackoverflow.com/questions/59220954/retrieving-pdf-

a guest
Dec 6th, 2019
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $invoice = array(
  5. "logo" => "test.dev", // url to logo
  6. "from" => "Wouter van Marrum \n<a href=\"http://www.concept-core.nl\">concept-core.nl</a>", // The name of your organization
  7. "to" => "marleen", // The entity being billed - multiple lines ok
  8. "number" => 20001, // Invoice number
  9. //"purchase_order" => "", // Purchase order number
  10. "date" => null, // Invoice date
  11. "due_date" => null, // Invoice due date
  12. "payment_terms" => null, // Payment terms summary (i.e. NET 30)
  13. // items
  14. "items[0][name]" => "Website",
  15. "items[0][quantity]" => 1,
  16. "items[0][unit_cost]" => 300,
  17. "items[1][name]" => "logo",
  18. "items[1][quantity]" => 1,
  19. "items[1][unit_cost]" => 150,
  20. // End items
  21. // Fields
  22. "fields[tax]" => true, // can be true, false
  23. "fields[discounts]" => false, // Subtotal discounts - numbers only
  24. "fields[shipping]" => false, // Can be true or false
  25. // End fields
  26. "tax"=> 21, // Tax - numbers only
  27. "amount_paid" => 0, // Amount paid - numbers only
  28. "notes" => "", // Notes - any extra information not included elsewhere
  29. "terms" => "Lees dit", // Terms and conditions - all the details
  30. );
  31.  
  32. $ch = curl_init();
  33. curl_setopt($ch, CURLOPT_URL, "https://invoice-generator.com");
  34. curl_setopt($ch, CURLOPT_POST, 1);
  35. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); // AGREGADO POR MI
  36. curl_setopt($ch, CURLOPT_POSTFIELDS, $invoice);
  37. $result = curl_exec($ch);
  38.  
  39. //header('Content-Length: ' . $response->getHeader('Content-Length')[0]);
  40.  
  41. //$file = $result->getBody();
  42.  
  43. header('Cache-Control: public');
  44. header('Content-type: application/pdf');
  45. header('Content-Disposition: attachment; filename="new.pdf"');
  46. header('Content-Length: '.strlen($result));
  47.  
  48. echo $result;
  49.  
  50.  
  51. curl_close($ch);
Add Comment
Please, Sign In to add comment