diff --git a/public/examples.html b/public/examples.html index bbf5fd2..bbd98b6 100644 --- a/public/examples.html +++ b/public/examples.html @@ -163,7 +163,7 @@ footer .container { display: flex; justify-content: space-between; align-items:
curl -X POST https://api.docfast.dev/v1/convert/html \
+ curl -X POST https://docfast.dev/v1/convert/html \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<html>...your invoice HTML...</html>"}' \
@@ -178,7 +178,7 @@ footer .container { display: flex; justify-content: space-between; align-items:
curl
- curl -X POST https://api.docfast.dev/v1/convert/markdown \
+ curl -X POST https://docfast.dev/v1/convert/markdown \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
@@ -217,7 +217,7 @@ footer .container { display: flex; justify-content: space-between; align-items:
curl
- curl -X POST https://api.docfast.dev/v1/convert/html \
+ curl -X POST https://docfast.dev/v1/convert/html \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d @report.json \
@@ -271,70 +271,80 @@ footer .container { display: flex; justify-content: space-between; align-items:
Node.js Integration
- A complete Node.js script to generate a PDF and save it to disk. Works with Node 18+ using native fetch.
+ Install the official SDK: npm install docfast
- JavaScript — generate-pdf.mjs
- const html = `
- <h1>Hello from Node.js</h1>
- <p>Generated at ${new Date().toISOString()}</p>
-`;
+ JavaScript — Using the SDK (recommended)
+ import DocFast from "docfast";
+import { writeFileSync } from "fs";
-const res = await fetch("https://api.docfast.dev/v1/convert/html", {
+const client = new DocFast(process.env.DOCFAST_API_KEY);
+
+// HTML to PDF
+const pdf = await client.html("<h1>Hello World</h1>");
+writeFileSync("output.pdf", pdf);
+
+// Markdown to PDF
+const doc = await client.markdown("# Report\n\nQ4 revenue grew **32%**.");
+
+// With options
+const report = await client.html(html, {
+ format: "A4",
+ landscape: true,
+ margin: { top: "20mm", bottom: "20mm" },
+});
+
+
+
+ JavaScript — Using fetch (no dependencies)
+ const res = await fetch("https://docfast.dev/v1/convert/html", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.DOCFAST_API_KEY}`,
"Content-Type": "application/json",
},
- body: JSON.stringify({ html }),
+ body: JSON.stringify({ html: "<h1>Hello</h1>" }),
});
-
-if (!res.ok) throw new Error(`API error: ${res.status}`);
-
-const buffer = Buffer.from(await res.arrayBuffer());
-await import("fs").then(fs =>
- fs.writeFileSync("output.pdf", buffer)
-);
-
-console.log("✓ Saved output.pdf");
+const pdf = Buffer.from(await res.arrayBuffer());
Python Integration
- Generate a PDF from Python using the requests library. Drop this into any Flask, Django, or FastAPI app.
+ Install the official SDK: pip install docfast
- Python — generate_pdf.py
- import os
-import requests
+ Python — Using the SDK (recommended)
+ from docfast import DocFast
-html = """
-<h1>Hello from Python</h1>
-<p>This PDF was generated via the DocFast API.</p>
-<ul>
- <li>Fast rendering</li>
- <li>Pixel-perfect output</li>
- <li>Simple REST API</li>
-</ul>
-"""
+client = DocFast("df_pro_your_api_key")
+
+# HTML to PDF
+pdf = client.html("<h1>Hello World</h1>")
+with open("output.pdf", "wb") as f:
+ f.write(pdf)
+
+# With options
+pdf = client.html(html, format="A4", landscape=True)
+
+# Async support
+from docfast import AsyncDocFast
+
+async with AsyncDocFast("df_pro_your_api_key") as client:
+ pdf = await client.html("<h1>Hello</h1>")
+
+
+
+ Python — Using requests (no SDK)
+ import requests
response = requests.post(
- "https://api.docfast.dev/v1/convert/html",
- headers={
- "Authorization": f"Bearer {os.environ['DOCFAST_API_KEY']}",
- "Content-Type": "application/json",
- },
- json={"html": html},
+ "https://docfast.dev/v1/convert/html",
+ headers={"Authorization": f"Bearer {api_key}"},
+ json={"html": "<h1>Hello</h1>"},
)
-
-response.raise_for_status()
-
-with open("output.pdf", "wb") as f:
- f.write(response.content)
-
-print("✓ Saved output.pdf")
+pdf = response.content
diff --git a/public/index.html b/public/index.html
index a160313..6628c13 100644
--- a/public/index.html
+++ b/public/index.html
@@ -402,7 +402,7 @@ html, body {
Everything you need
- A complete PDF generation API. No SDKs, no dependencies, no setup.
+ A complete PDF generation API. Official SDKs for Node.js & Python, or just use curl.