尚未检测到更新。GitHub 发布版本后会显示在这里。
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证Arabic HTML to PDF and screenshot API hosted in Saudi Arabia: ready-to-run examples in curl, JavaScript, Python, .NET and Java
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗Ready-to-run examples for Sahifa, an HTML-to-PDF and screenshot API that renders Arabic and right-to-left documents correctly and processes everything in Saudi Arabia (Jeddah).
Documentation · Quick start · OpenAPI · Pricing · Data residency
curl https://api.sahifa.dev/v3/convert/pdf \
--user "api:$SAHIFA_API_KEY" \
--header "Content-Type: application/json" \
--data '{"source": "<html dir=\"rtl\" lang=\"ar\"><body><h1>فاتورة ضريبية</h1></body></html>"}' \
--output invoice.pdf
Generating a PDF with Arabic text is harder than it should be. Most PDF libraries draw each Arabic letter in its isolated form, reverse the word order, or show ????, and mixed Arabic, English and numbers in one line make it worse. Typical symptoms:
ف ا ت و ر ة instead of فاتورة;? or empty boxes instead of Arabic characters;Sahifa avoids this by rendering your HTML in Chromium, the same engine as Chrome, with Arabic fonts installed (Noto Naskh Arabic, Noto Sans Arabic, Amiri, Noto Kufi Arabic). Whatever looks right in Chrome looks right in the PDF: letter joining, bidi reordering, dir="rtl", Arabic-Indic digits, and mixed Arabic/English.
For fintechs and other regulated companies in the Kingdom there is a second reason: documents such as account statements and invoices often may not leave Saudi Arabia. Sahifa runs on Oracle Cloud in Jeddah, does not store the documents you send, and signs a data processing agreement. See the data residency statement.
| PDF from HTML | Screenshot of a URL | Retry on busy / rate limit | |
|---|---|---|---|
| curl | curl/pdf.sh | curl/screenshot.sh | curl/retry.sh |
| JavaScript (Node 18+) | javascript/pdf.mjs | javascript/screenshot.mjs | javascript/retry.mjs |
| Python 3.8+ | python/pdf.py | python/screenshot.py | python/retry.py |
| .NET 8 (C#) | dotnet/pdf.cs | dotnet/screenshot.cs | dotnet/retry.cs |
| Java 18+ | java/Pdf.java |
Each example is a single file with no SDK: it uses the language's standard HTTP client (Python needs requests).
| Language | Install | Repository |
|---|---|---|
| Node.js / TypeScript | npm install sahifa | sahifa-node |
| Python | pip install sahifa | sahifa-python |
| Laravel / PHP | composer require sahifa/laravel | sahifa-laravel |
| n8n | Settings → Community Nodes → n8n-nodes-sahifa | n8n-nodes-sahifa |
The examples below use plain HTTP, so they also work in any other language.
export SAHIFA_API_KEY=sk_live_... # macOS / Linux
$env:SAHIFA_API_KEY = "sk_live_..." # Windows PowerShell
bash curl/pdf.sh
node javascript/pdf.mjs
python python/pdf.py
dotnet run dotnet/pdf.cs # .NET 10; or paste into a console app
java java/Pdf.java
run-all.sh runs every example against the live API and checks the output files.POST https://api.sahifa.dev/v3/convert/pdfCompatible with the PDFShift v3 API, so existing PDFShift code usually needs only the host name changed.
api and your key as the password, or the header X-API-Key: <key>.source (HTML or a URL, required), format (A4, Letter, …), landscape, margin, header / footer ({ "source": "<html>" } with {{page}} and {{total}}), css, javascript, delay, wait_for, pages, zoom.application/pdf).GET or POST https://api.sahifa.dev/takeCompatible with the ScreenshotOne API.
access_key parameter or the header X-Access-Key.url or html, format (png, jpeg, webp, pdf), viewport_width, viewport_height, full_page, device_scale_factor, selector, block_ads, block_cookie_banners, dark_mode, delay (seconds).Every parameter is in the API reference and the OpenAPI document.
A few things make Arabic documents look professional, whichever tool you use:
<html dir="rtl" lang="ar">
<head>
<meta charset="utf-8">
<style>
body { font-family: 'Noto Naskh Arabic', 'Amiri', serif; }
.ltr { direction: ltr; unicode-bidi: isolate; } /* IBANs, emails, SKUs inside Arabic text */
table { width: 100%; } /* columns mirror automatically with dir="rtl" */
@page { size: A4; margin: 15mm; }
</style>
</head>
<body>
<h1>فاتورة ضريبية مبسطة</h1>
<p>رقم الحساب: <bdi class="ltr">SA03 8000 0000 6080 1016 7519</bdi></p>
</body>
</html>
dir="rtl" on <html>, not only on single elements, so tables, lists and page layout mirror.<bdi> (or unicode-bidi: isolate) so they are not reordered with the Arabic text around them.font-variant-numeric: tabular-nums for amount columns so the digits line up.dir, instead of mixing them inside one paragraph.Sahifa turns your invoice HTML into a PDF; it does not issue or report e-invoices to ZATCA. If your system already produces the ZATCA QR code (phase 1 TLV or the phase 2 value from the cleared XML), put it into the HTML as an image or an inline SVG and it will be printed as is.
| Plan | Renders a month | Price (monthly, excl. VAT) |
|---|---|---|
| Sandbox | 100 (up to 10 a day), watermarked | free |
| Developer | 2,000 | SAR 59 |
| Business | 15,000 | SAR 199 |
| Compliance | 50,000, DPA and data residency letter | SAR 799 |
One PDF or one screenshot counts as one render. Current prices: sahifa.dev/en/#pricing.
Merchants on Salla and Zid can use the Sahifa app to print Arabic invoices, packing slips, receipts and quotations for their orders, without any code. See Sahifa for Salla and Zid stores.
Sahifa is a service of Yimello LLC, United Arab Emirates. The code in this repository is released under the MIT License; the Sahifa service itself is governed by its terms.
صحيفة واجهة برمجية لتحويل HTML إلى PDF ولقطات الشاشة، تعرض النصوص العربية واتجاه اليمين إلى اليسار بشكل صحيح، وتعمل بالكامل داخل المملكة العربية السعودية (جدة)، ولا تحتفظ بالمستندات التي ترسلها.
يحتوي هذا المستودع على أمثلة جاهزة للتشغيل بلغات curl وJavaScript وPython و.NET وJava. أنشئ حسابًا مجانيًا في sahifa.dev، وضع مفتاحك في المتغير SAHIFA_API_KEY، ثم شغّل أي مثال.
التوثيق الكامل بالعربية: sahifa.dev/docs · الدعم: [email protected]
Gulyás György Tamás — ggyt.hu
| java/Screenshot.java |
| java/Retry.java |