Skip to content

Output Formats

Every builder ends with a call that asks for something concrete.

PNG Bytes

php
$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

php
$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

php
$src = RaastQr::make()->amount('2500')->toDataUrl();
blade
<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:

php
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

php
$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

php
$image = RaastQr::make()->format('svg')->render();

render() returns PNG or SVG depending on the current format. Useful when the format is a variable:

php
RaastQr::make()->amount($total)->format($request->input('format', 'png'))->render();

Choosing Between Them

NeedUse
Inline on a web pagetoDataUrl() or <x-raast-qr />
Printed card, poster, invoice PDFtoSvg()
Email attachment, WhatsApp imagetoPng()
Thermal receipt printertoPayload()
Served from a routetoResponse() — see HTTP Responses
Saved for latersave() or store() — see Saving and Storing

Made with ❤️ from Pakistan