Domain Patterns
Skill: databricks-unstructured-pdf-generation
What You Can Build
Section titled “What You Can Build”A synthetic corpus only earns its keep if it resembles real documents — and real API references, financial reports, and HR policies don’t look alike. Since your AI coding assistant writes the HTML for every document, each domain gets its own typography, layout, and content conventions: monospace technical references, serif finance reports with metric callouts, sans-serif policies with notice boxes. This page gives you a working pattern per domain plus the parallel fan-out for multi-domain corpora.
In Action
Section titled “In Action”“Generate an API reference PDF for our payments service — endpoint listings, request headers, monospace styling — and upload it to docs_catalog.api_docs.”
generate_and_upload_pdf( html_content='''<!DOCTYPE html><html><head><style> body { font-family: monospace; margin: 40px; } code { background: #f4f4f4; padding: 2px 6px; } pre { background: #f4f4f4; padding: 15px; overflow-x: auto; } .endpoint { background: #e3f2fd; padding: 10px; margin: 10px 0; }</style></head><body> <h1>Payments API Reference</h1> <div class="endpoint"> <code>GET /api/v1/payments</code> <p>Returns a paginated list of payment records.</p> </div> <div class="endpoint"> <code>POST /api/v1/payments/refunds</code> <p>Creates a refund for a captured payment.</p> </div> <h2>Request Headers</h2> <pre>Authorization: Bearer {token}Content-Type: application/json</pre></body></html>''', filename="payments_api_reference.pdf", catalog="docs_catalog", schema="api_docs")Key decisions:
- Monospace body font signals “technical” — readers immediately parse it as engineering documentation, and inline code doesn’t fight the body text.
- One
.endpointblock per route — each API operation becomes a distinct visual unit, which is also how real reference docs are structured. - Concrete routes and headers —
GET /api/v1/payments,Authorization: Bearer— realistic specifics beat placeholder text when the corpus stands in for a customer’s document estate.
More Patterns
Section titled “More Patterns”Business reports with metric callouts
Section titled “Business reports with metric callouts”“Create a Q1 2024 performance report with big revenue and growth callouts, styled like a finance document, in finance.reports under a quarterly folder.”
generate_and_upload_pdf( html_content='''<!DOCTYPE html><html><head><style> body { font-family: Georgia, serif; margin: 50px; } .metric { display: inline-block; text-align: center; margin: 20px; } .metric-value { font-size: 2em; color: #1a73e8; } .metric-label { color: #666; }</style></head><body> <h1>Q1 2024 Performance Report</h1> <div class="metric"> <div class="metric-value">$2.4M</div> <div class="metric-label">Revenue</div> </div> <div class="metric"> <div class="metric-value">+15%</div> <div class="metric-label">Growth</div> </div></body></html>''', filename="q1_2024_report.pdf", catalog="finance", schema="reports", folder="quarterly")Serif typography and metric callouts make the document read as finance, not engineering. The folder="quarterly" argument keeps report types separated inside the Volume, so downstream ingestion can scope to /Volumes/finance/reports/raw_data/quarterly/ without filename gymnastics.
HR policies with notice boxes
Section titled “HR policies with notice boxes”“Write an employee leave policy PDF with numbered sections, an effective date, and a highlighted submission-deadline notice, in hr_catalog.policies.”
generate_and_upload_pdf( html_content='''<!DOCTYPE html><html><head><style> body { font-family: Arial; margin: 40px; line-height: 1.8; } .policy-section { margin: 30px 0; } .important { background: #fff3e0; padding: 15px; border-radius: 5px; }</style></head><body> <h1>Employee Leave Policy</h1> <p><em>Effective: January 1, 2024</em></p> <div class="policy-section"> <h2>1. Annual Leave</h2> <p>All full-time employees are entitled to 20 days of paid annual leave per calendar year.</p> </div> <div class="important"> <strong>Note:</strong> Leave requests must be submitted at least 2 weeks in advance. </div></body></html>''', filename="leave_policy.pdf", catalog="hr_catalog", schema="policies")Policy documents trade on structure: numbered sections, an effective date, and an .important notice box. Generous line-height and plain sans-serif styling are exactly how real HR PDFs look — which matters when the corpus is standing in for a real document library in a demo.
Multi-domain corpus, one parallel fan-out
Section titled “Multi-domain corpus, one parallel fan-out”“Build a mixed demo corpus — two HR policies, two API docs, and two finance reports — each domain in its own folder under demo_catalog.synthetic.”
# Six parallel calls, three domain styles, one Volumegenerate_and_upload_pdf(html_content=handbook_html, filename="employee_handbook.pdf", catalog="demo_catalog", schema="synthetic", folder="hr")generate_and_upload_pdf(html_content=conduct_html, filename="code_of_conduct.pdf", catalog="demo_catalog", schema="synthetic", folder="hr")generate_and_upload_pdf(html_content=auth_api_html, filename="auth_api_reference.pdf", catalog="demo_catalog", schema="synthetic", folder="technical")generate_and_upload_pdf(html_content=webhooks_html, filename="webhooks_guide.pdf", catalog="demo_catalog", schema="synthetic", folder="technical")generate_and_upload_pdf(html_content=q1_report_html, filename="q1_earnings.pdf", catalog="demo_catalog", schema="synthetic", folder="finance")generate_and_upload_pdf(html_content=budget_html, filename="budget_variance.pdf", catalog="demo_catalog", schema="synthetic", folder="finance")Batch generation is the agent making parallel generate_and_upload_pdf calls — there is no separate batch tool. Author all six HTML documents first, each in its domain style, then fire the calls simultaneously: at 2-5 seconds per document, the whole corpus lands in roughly the time of one. Folder-per-domain keeps ingestion pipelines cleanly scoped.
Watch Out For
Section titled “Watch Out For”- One stylesheet for every domain — if HR policies, API docs, and finance reports all share the same CSS, the corpus looks machine-generated. Vary typography and layout per domain: monospace technical, serif finance, sans-serif HR.
- Placeholder content undermines the corpus — “Lorem ipsum” and “policy text here” defeat the purpose. Ask for specifics: policy numbers, endpoint paths, dollar figures, effective dates.
- One giant document instead of a corpus — retrieval demos need many distinct documents, not one 40-page PDF. One
generate_and_upload_pdfcall per document, fired in parallel. - Mixed domains in one folder — dumping everything into the Volume root means downstream pipelines can’t scope by document type. Pass
folder=from the first call; reorganizing a Volume afterward is manual cleanup.