Built-In-Output-QREps.md.txt 2.5 KB

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