* Writes the QR code to a SVG and renders it in the container.
(
contents: string,
width: number,
height: number,
hints: Map<EncodeHintType, any> = null
)
| 40 | * Writes the QR code to a SVG and renders it in the container. |
| 41 | */ |
| 42 | public write( |
| 43 | contents: string, |
| 44 | width: number, |
| 45 | height: number, |
| 46 | hints: Map<EncodeHintType, any> = null |
| 47 | ): SVGSVGElement { |
| 48 | |
| 49 | if (contents.length === 0) { |
| 50 | throw new IllegalArgumentException('Found empty contents'); |
| 51 | } |
| 52 | |
| 53 | if (width < 0 || height < 0) { |
| 54 | throw new IllegalArgumentException('Requested dimensions are too small: ' + width + 'x' + height); |
| 55 | } |
| 56 | |
| 57 | let quietZone = hints && hints.get(EncodeHintType.MARGIN) !== undefined |
| 58 | ? Number.parseInt(hints.get(EncodeHintType.MARGIN).toString(), 10) |
| 59 | : BrowserSvgCodeWriter.QUIET_ZONE_SIZE; |
| 60 | |
| 61 | const code = this.encode(hints, contents); |
| 62 | |
| 63 | return this.renderResult(code, width, height, quietZone); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Encodes the content to a Barcode type. |
nothing calls this directly
no test coverage detected