fpdf.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * @created 03.06.2020
  4. * @author Maximilian Kresse
  5. * @license MIT
  6. */
  7. use chillerlan\QRCode\{QRCode, QROptions};
  8. use chillerlan\QRCode\Common\EccLevel;
  9. use chillerlan\QRCode\Data\QRMatrix;
  10. use chillerlan\QRCode\Output\QROutputInterface;
  11. require_once __DIR__ . '/../vendor/autoload.php';
  12. $options = new QROptions([
  13. 'version' => 7,
  14. 'outputType' => QROutputInterface::FPDF,
  15. 'eccLevel' => EccLevel::L,
  16. 'scale' => 5,
  17. 'bgColor' => [234, 234, 234],
  18. 'drawLightModules' => false,
  19. 'imageBase64' => false,
  20. 'moduleValues' => [
  21. // finder
  22. QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
  23. QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
  24. QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
  25. // alignment
  26. QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
  27. QRMatrix::M_ALIGNMENT => [255, 255, 255],
  28. // timing
  29. QRMatrix::M_TIMING_DARK => [255, 0, 0],
  30. QRMatrix::M_TIMING => [255, 255, 255],
  31. // format
  32. QRMatrix::M_FORMAT_DARK => [67, 191, 84],
  33. QRMatrix::M_FORMAT => [255, 255, 255],
  34. // version
  35. QRMatrix::M_VERSION_DARK => [62, 174, 190],
  36. QRMatrix::M_VERSION => [255, 255, 255],
  37. // data
  38. QRMatrix::M_DATA_DARK => [0, 0, 0],
  39. QRMatrix::M_DATA => [255, 255, 255],
  40. // darkmodule
  41. QRMatrix::M_DARKMODULE => [0, 0, 0],
  42. // separator
  43. QRMatrix::M_SEPARATOR => [255, 255, 255],
  44. // quietzone
  45. QRMatrix::M_QUIETZONE => [255, 255, 255],
  46. ],
  47. ]);
  48. if(php_sapi_name() !== 'cli'){
  49. header('Content-type: application/pdf');
  50. }
  51. echo (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  52. exit;