fpdf.php 1.7 KB

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