apyhub
Back

Generate Arabic Receipt PDF API

What it does

The Arabic Receipt PDF API turns sale data sent as JSON into a receipt PDF in Arabic, English or both. Send the receipt number, date, currency, seller and line items. The API returns the PDF with the subtotal, tax and total already worked out.

Set format to receipt-80mm or receipt-58mm for thermal printer rolls, or to A4, A5, Letter or Legal for a full page. Long receipts on a full page flow onto more pages. Set language to ar, en or bilingual, and direction switches to right-to-left when the content has Arabic. Each item in lines takes a quantity, a unit_price, an optional tax_percent and an optional flat discount, up to 500 lines.

Teams use the Arabic Receipt PDF API to print 80mm receipts at cafes and shops, email a receipt PDF after an online payment, and keep a bilingual copy of each sale. Add a QR code from any text with qr_text, or your logo with logo_url. Set output to binary to get the PDF file itself, or keep the default base64 JSON.

The API returns a PDF. It does not print to a device, so send the file to your printer or POS software.

For a layout of your own, use Convert HTML Content to PDF API. For a separate QR image, such as a review link, use Generate QR Code API.

POST
Receipt PDF
https://api.eu.apyhub.com/odelyo/generate-arabic-receipt-pdf/receipts

QUICKSTART

GUIDE

Quickstart

Create an 80mm thermal receipt for one item with 15% tax.

curl -X POST "https://api.eu.apyhub.com/odelyo/generate-arabic-receipt-pdf/receipts" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"number":"R-2001","date":"2026-11-30","currency":"SAR","seller":{"name":"Al Ward Cafe"},"lines":[{"description":"Arabic coffee","quantity":2,"unit_price":12,"tax_percent":15}],"format":"receipt-80mm"}'

What you'll get back

Returns a JSON object with data and meta. data holds the PDF as base64, its size, page count and the worked-out totals.

{
  "data": {
    "pdf_base64": "JVBERi0x...",
    "bytes": 33024,
    "pages": 1,
    "totals": { "subtotal": 24, "tax": 3.6, "total": 27.6 }
  },
  "meta": { "request_id": "req_31710ba752f877f5", "version": "v1" }
}
TRY ITLIVE · 10 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Required. Receipt date, printed as sent.
lines*
Required. Receipt line items. 1 to 500 items.
lines-1*
Required. Quantity. Minimum 0.
Required. Price per unit. Minimum 0.
Required. Line description.
Required. Receipt number.
seller*
Required. Seller details printed on the document.
Required. Seller name.
Required. Currency code or label printed next to amounts.
Font family.
buyer
Buyer details printed on the document. If you send it, `name` is required.
Required. Buyer name.
Buyer email.
Buyer phone number.

About this endpoint

What it does

Creates a receipt PDF in Arabic, English or both from the sale data you send. It returns the PDF with the subtotal, tax and total worked out from your line items.

Request Body

ParameterTypeDescription
numberStringRequired. Receipt number. 1 to 60 characters.
dateStringRequired. Receipt date, printed as sent. 1 to 40 characters.
currencyStringRequired. Currency code or label printed next to amounts, for example SAR. 1 to 10 characters.
sellerObjectRequired. Seller details printed on the receipt.
seller.nameStringRequired. Seller name. 1 to 200 characters.
seller.name_enStringSeller name in English, used in bilingual layouts. 1 to 200 characters.
seller.emailStringSeller email. 1 to 200 characters.
seller.phoneStringSeller phone number. 1 to 40 characters.
seller.addressStringSeller address. 1 to 500 characters.
seller.cr_numberStringSeller commercial registration (CR) number. 1 to 40 characters.
seller.tax_numberStringSeller tax or VAT number. 1 to 40 characters.
buyerObjectBuyer details printed on the receipt. If you send it, buyer.name is required. Same fields as seller.
linesObject ArrayRequired. Receipt line items. Min 1 item. Max 500 items.
lines[].descriptionStringRequired. Line description. 1 to 500 characters.
lines[].description_enStringLine description in English, used in bilingual layouts. 1 to 500 characters.
lines[].quantityNumberRequired. Quantity. Minimum: 0.
lines[].unit_priceNumberRequired. Price per unit. Minimum: 0.
lines[].discountNumberFlat discount amount in the receipt currency, not a percent. Minimum: 0. Must not be more than quantity × unit_price.
lines[].tax_percentNumberTax rate for this line in percent. Range: 0 to 100.
titleStringHeading printed on the receipt. 1 to 100 characters.
due_dateStringPayment due date, printed as sent. 1 to 40 characters.
notesStringFree-text notes printed near the bottom. 1 to 2,000 characters.
amount_in_wordsStringTotal in words, printed as sent. The API does not write it for you. 1 to 500 characters.
qr_textStringText to encode in a QR code on the receipt. 1 to 2,000 characters.
languageENUMLanguage of the labels. Allowed values: ar, en, bilingual.
directionENUMText direction. Allowed values: auto, rtl, ltr. Default: auto (right-to-left when the content has Arabic).
fontENUMFont family. Allowed values: naskh, kufi, sans, amiri. Default: naskh.
formatENUMPage size. Allowed values: A4, A5, Letter, Legal, receipt-80mm, receipt-58mm. Default: A4. Use receipt-80mm or receipt-58mm for thermal printer rolls.
landscapeBooleanRender the page in landscape.
margin_mmNumberPage margin in millimetres. Range: 0 to 40.
page_numbersBooleanPrint page numbers.
decimalsIntegerNumber of decimal places for amounts. Range: 0 to 3.
accent_colorStringAccent colour as a hex value, for example #0F766E.
logo_urlStringLogo as an http(s) URL or a data:image/ URI. Up to 2,000,000 characters.
header_htmlStringCustom HTML for the page header. 1 to 20,000 characters.
footer_htmlStringCustom HTML for the page footer. 1 to 20,000 characters.
filenameStringFile name for the PDF. Letters, digits, spaces, dots, dashes and underscores, up to 100 characters.
outputENUMAllowed values: base64, binary. Default: base64. binary returns the PDF file itself.

Response

Returns a JSON object with data and meta (status 201). data holds the PDF as base64 and the totals. When output is binary, the response is the PDF file itself (status 200, application/pdf).

ParameterTypeDescription
data.pdf_base64StringThe receipt PDF, base64-encoded.
data.bytesIntegerSize of the PDF in bytes.
data.pagesIntegerNumber of pages in the PDF.
data.totals.subtotalNumberSum of quantity × unit_price minus discounts.
data.totals.taxNumberTotal tax across all lines.
data.totals.totalNumbersubtotal + tax.
meta.request_idStringRequest identifier.
meta.versionStringAPI version, for example v1.

Notes

  • Each format returns its own page size. Long receipts on a sheet format (A4, A5, Letter, Legal) flow onto more pages: 500 lines on A4 gives 24 pages.
  • Errors return status 422 with error.code, error.message, error.field and error.detail. validation_error means a field is missing or invalid. invalid_discount means a line discount is more than the line amount.
  • The API does not print to a device. Send the PDF to your printer or POS software.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.