DOC CREATE
Convert HTML content or a web page URL to a PDF or DOCX file using LibreOffice headless. Output is saved to /root/files/ and the virtual path is returned.
Input must be HTML. Use
AS "html" for HTML content, AS "text" for plain text. Plain text wraps each line in a paragraph automatically. Both FROM STRING and FROM URL are supported.FROM STRING — inline HTML
DOC CREATE FROM STRING "<h1>Report</h1><p>Q3 results exceeded targets.</p>" AS "html" OUTPUT PDF SET ?path
AFTER EMIT ?path
FROM STRING — plain text
DOC CREATE FROM STRING "Line one\nLine two\nLine three" AS "text" OUTPUT PDF SET ?path
AFTER EMIT ?path
FROM STRING — variable
STRING "<h1>Invoice</h1><p>Amount due: R500</p>" SET ?html
AFTER DOC CREATE FROM STRING ?html AS "html" OUTPUT DOCX SET ?path
AFTER EMIT ?path
FROM URL — convert a web page
DOC CREATE FROM URL "https://example.com/report" AS "html" OUTPUT PDF SET ?path
AFTER EMIT ?path
Reading from virtual storage first
DOC CREATE does not accept filesystem paths directly. Use READ to load content first:
READ "/root/templates/invoice.html" SET ?html
AFTER DOC CREATE FROM STRING ?html AS "html" OUTPUT PDF SET ?path
AFTER EMIT ?path
Serve the generated file
DOC CREATE FROM STRING ?html AS "html" OUTPUT PDF SET ?path
AFTER SERVE ?path
Share the generated file
DOC CREATE FROM STRING ?html AS "html" OUTPUT PDF SET ?path
AFTER SHARE ?path AS "24h" SET ?url
AFTER EMIT ?url
Verb reference
| Verb | Description |
|---|---|
DOC CREATE FROM STRING "html" AS "html" OUTPUT PDF SET ?path | Convert HTML string to PDF. → virtual path string |
DOC CREATE FROM STRING "text" AS "text" OUTPUT PDF SET ?path | Convert plain text to PDF. Lines become paragraphs. |
DOC CREATE FROM STRING ?var AS "html"|"text" OUTPUT DOCX SET ?path | Convert to DOCX. |
DOC CREATE FROM URL "https://url" AS "html" OUTPUT PDF SET ?path | Fetch URL and convert to PDF. |