fpdf.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace chillerlan\QRCodeExamples;
  3. use chillerlan\QRCode\{QRCode, QROptions};
  4. use chillerlan\QRCode\Common\EccLevel;
  5. require_once __DIR__ . '/../vendor/autoload.php';
  6. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  7. $options = new QROptions([
  8. 'version' => 7,
  9. 'outputType' => QRCode::OUTPUT_FPDF,
  10. 'eccLevel' => EccLevel::L,
  11. 'scale' => 5,
  12. 'imageBase64' => false,
  13. 'moduleValues' => [
  14. // finder
  15. 1536 => [0, 63, 255], // dark (true)
  16. 6 => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
  17. // alignment
  18. 2560 => [255, 0, 255],
  19. 10 => [255, 255, 255],
  20. // timing
  21. 3072 => [255, 0, 0],
  22. 12 => [255, 255, 255],
  23. // format
  24. 3584 => [67, 191, 84],
  25. 14 => [255, 255, 255],
  26. // version
  27. 4096 => [62, 174, 190],
  28. 16 => [255, 255, 255],
  29. // data
  30. 1024 => [0, 0, 0],
  31. 4 => [255, 255, 255],
  32. // darkmodule
  33. 512 => [0, 0, 0],
  34. // separator
  35. 8 => [255, 255, 255],
  36. // quietzone
  37. 18 => [255, 255, 255],
  38. ],
  39. ]);
  40. \header('Content-type: application/pdf');
  41. echo (new QRCode($options))->render($data);