Output Formats
Every builder ends with a call that asks for something concrete.
PNG Bytes
$png = RaastQr::make()->amount('2500')->toPng();Raw binary. Attach it to a mail message, push it to a printer, or write it yourself.
Requires ext-gd or ext-imagick.
SVG String
$svg = RaastQr::make()->amount('2500')->toSvg();A complete SVG document as a string. Pure PHP, so it works with no image extension installed.
Use SVG for anything printed or scaled.
Data URL
$src = RaastQr::make()->amount('2500')->toDataUrl();<img src="{{ $src }}" alt="Scan to pay">Returns a PNG data URL by default. Switch to SVG and you get an SVG data URL instead:
RaastQr::make()->format('svg')->toDataUrl();
// data:image/svg+xml;base64,...Data URLs keep it off disk
Nothing is written anywhere. The image lives in the response and disappears with it, which is exactly what you want for a code carrying a customer's order total.
The Raw Payload
$payload = RaastQr::make()->amount('2500')->toPayload();
// 0002020102120202000424PK33ABCD...No image at all. Hand it to a thermal printer, a JavaScript front end, or a PDF library that renders its own codes. See The Raw Payload.
Whatever Is Selected
$image = RaastQr::make()->format('svg')->render();render() returns PNG or SVG depending on the current format. Useful when the format is a variable:
RaastQr::make()->amount($total)->format($request->input('format', 'png'))->render();Choosing Between Them
| Need | Use |
|---|---|
| Inline on a web page | toDataUrl() or <x-raast-qr /> |
| Printed card, poster, invoice PDF | toSvg() |
| Email attachment, WhatsApp image | toPng() |
| Thermal receipt printer | toPayload() |
| Served from a route | toResponse() — see HTTP Responses |
| Saved for later | save() or store() — see Saving and Storing |
Made with ❤️ from Pakistan