fpdf.php 1.8 KB

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