QREps.md.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # QREps
  2. [Class `QREps`](https://github.com/chillerlan/php-qrcode/blob/main/src/Output/QREps.php):
  3. [Encapsulated Postscript](https://en.wikipedia.org/wiki/Encapsulated_PostScript) (EPS) output.
  4. ## Example
  5. See: [EPS example](https://github.com/chillerlan/php-qrcode/blob/main/examples/eps.php)
  6. Set the options:
  7. ```php
  8. $options = new QROptions;
  9. $options->outputInterface = QREps::class;
  10. $options->scale = 5;
  11. $options->drawLightModules = false;
  12. // colors can be specified either as [R, G, B] or [C, M, Y, K] (0-255)
  13. $options->bgColor = [222, 222, 222];
  14. $options->moduleValues = [
  15. QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
  16. QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
  17. QRMatrix::M_FINDER => [233, 233, 233], // light (false)
  18. QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
  19. QRMatrix::M_ALIGNMENT => [233, 233, 233],
  20. QRMatrix::M_DATA_DARK => [0, 0, 0],
  21. QRMatrix::M_DATA => [233, 233, 233],
  22. ];
  23. ```
  24. Render and save to file:
  25. ```php
  26. $data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
  27. $file = __DIR__.'/qrcode.eps';
  28. (new QRCode($options))->render($data, $file);
  29. ```
  30. Push as file download in a browser:
  31. ```php
  32. header('Content-type: application/postscript');
  33. header('Content-Disposition: filename="qrcode.eps"');
  34. echo (new QRCode($options))->render($data);
  35. exit;
  36. ```
  37. ## Additional methods
  38. | method | return | description |
  39. |---------------------------------------------------|----------|--------------------------------------------|
  40. | (protected) `formatColor(array $values)` | `string` | Set the color format string |
  41. | (protected) `module(int $x, int $y, int $M_TYPE)` | `string` | Returns a path segment for a single module |
  42. ## Options that affect this class
  43. | property | type |
  44. |-----------------------|---------|
  45. | `$bgColor` | `array` |
  46. | `$connectPaths` | `bool` |
  47. | `$drawLightModules` | `bool` |
  48. | `$excludeFromConnect` | `array` |
  49. | `$scale` | `int` |