fpdf.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 | QRMatrix::IS_DARK => [0, 63, 255], // dark (true)
  23. QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
  24. // alignment
  25. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => [255, 0, 255],
  26. QRMatrix::M_ALIGNMENT => [255, 255, 255],
  27. // timing
  28. QRMatrix::M_TIMING | QRMatrix::IS_DARK => [255, 0, 0],
  29. QRMatrix::M_TIMING => [255, 255, 255],
  30. // format
  31. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => [67, 191, 84],
  32. QRMatrix::M_FORMAT => [255, 255, 255],
  33. // version
  34. QRMatrix::M_VERSION | QRMatrix::IS_DARK => [62, 174, 190],
  35. QRMatrix::M_VERSION => [255, 255, 255],
  36. // data
  37. QRMatrix::M_DATA | QRMatrix::IS_DARK => [0, 0, 0],
  38. QRMatrix::M_DATA => [255, 255, 255],
  39. // darkmodule
  40. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => [0, 0, 0],
  41. // separator
  42. QRMatrix::M_SEPARATOR => [255, 255, 255],
  43. // quietzone
  44. QRMatrix::M_QUIETZONE => [255, 255, 255],
  45. ],
  46. ]);
  47. if(php_sapi_name() !== 'cli'){
  48. header('Content-type: application/pdf');
  49. }
  50. echo (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  51. exit;