diff --git a/public/examples.html b/public/examples.html index 9f257eb..1e8f75b 100644 --- a/public/examples.html +++ b/public/examples.html @@ -111,6 +111,7 @@ footer .container { display: flex; justify-content: space-between; align-items: Markdown Charts Receipt + URL to PDF Node.js Python Go @@ -270,6 +271,36 @@ footer .container { display: flex; justify-content: space-between; align-items: + +
+

URL to PDF

+

Capture a live webpage and convert it to PDF. Send a URL to the /v1/convert/url endpoint and get a rendered PDF back. JavaScript is disabled for security (SSRF protection), and private/internal URLs are blocked.

+ +
+ curl — basic +
curl -X POST https://docfast.dev/v1/convert/url \
+  -H "Authorization: Bearer YOUR_API_KEY" \
+  -H "Content-Type: application/json" \
+  -d '{"url": "https://example.com"}' \
+  --output page.pdf
+
+ +
+ curl — with options +
curl -X POST https://docfast.dev/v1/convert/url \
+  -H "Authorization: Bearer YOUR_API_KEY" \
+  -H "Content-Type: application/json" \
+  -d '{
+    "url": "https://example.com",
+    "format": "A4",
+    "margin": { "top": "20mm", "bottom": "20mm" },
+    "scale": 0.8,
+    "printBackground": true
+  }' \
+  --output page.pdf
+
+
+

Node.js Integration

diff --git a/public/src/examples.html b/public/src/examples.html index b9a8699..448a7d3 100644 --- a/public/src/examples.html +++ b/public/src/examples.html @@ -60,6 +60,7 @@ Markdown Charts Receipt + URL to PDF Node.js Python Go @@ -219,6 +220,36 @@
+ +
+

URL to PDF

+

Capture a live webpage and convert it to PDF. Send a URL to the /v1/convert/url endpoint and get a rendered PDF back. JavaScript is disabled for security (SSRF protection), and private/internal URLs are blocked.

+ +
+ curl — basic +
curl -X POST https://docfast.dev/v1/convert/url \
+  -H "Authorization: Bearer YOUR_API_KEY" \
+  -H "Content-Type: application/json" \
+  -d '{"url": "https://example.com"}' \
+  --output page.pdf
+
+ +
+ curl — with options +
curl -X POST https://docfast.dev/v1/convert/url \
+  -H "Authorization: Bearer YOUR_API_KEY" \
+  -H "Content-Type: application/json" \
+  -d '{
+    "url": "https://example.com",
+    "format": "A4",
+    "margin": { "top": "20mm", "bottom": "20mm" },
+    "scale": 0.8,
+    "printBackground": true
+  }' \
+  --output page.pdf
+
+
+

Node.js Integration

diff --git a/src/__tests__/examples-url-to-pdf.test.ts b/src/__tests__/examples-url-to-pdf.test.ts new file mode 100644 index 0000000..e0d0fb9 --- /dev/null +++ b/src/__tests__/examples-url-to-pdf.test.ts @@ -0,0 +1,35 @@ +import { describe, it, expect } from 'vitest'; +import { readFileSync } from 'fs'; +import { join } from 'path'; + +describe('examples.html - URL to PDF section', () => { + const html = readFileSync(join(__dirname, '../../public/examples.html'), 'utf-8'); + + it('contains a URL to PDF section', () => { + expect(html).toContain('id="url-to-pdf"'); + expect(html).toContain('URL to PDF'); + }); + + it('contains a nav link to the URL to PDF section', () => { + expect(html).toContain('href="#url-to-pdf"'); + }); + + it('uses the correct API URL (docfast.dev, not api.docfast.dev)', () => { + expect(html).toContain('https://docfast.dev/v1/convert/url'); + expect(html).not.toContain('api.docfast.dev'); + }); + + it('shows the /v1/convert/url endpoint', () => { + expect(html).toContain('/v1/convert/url'); + }); + + it('does NOT reference non-existent SDKs for URL conversion', () => { + expect(html).not.toContain('docfast-url'); + expect(html).not.toContain('url-to-pdf-sdk'); + }); + + it('mentions security notes about JavaScript and private URLs', () => { + expect(html).toMatch(/[Jj]ava[Ss]cript.*disabled|disabled.*[Jj]ava[Ss]cript/i); + expect(html).toMatch(/private|internal/i); + }); +});