generatePdf
Generate an HTML asset and export it as a webpage, PDF, or image
mindstudio.generatePdf({ source, sourceType, outputFormat, pageSize, testData }) → Result
Renders an HTML asset and exports it as a webpage, PDF, or image, returning a hosted file. Turns a templated invoice, report, or certificate into a downloadable document.
Parameters
source
string
RequiredThe HTML or Markdown source template for the asset
sourceType
string
RequiredSource type: html, markdown (auto-formatted), spa (single page app), raw (pre-generated HTML in a variable), dynamic (AI-generated from prompt), or customInterface
htmlmarkdownsparawdynamiccustomInterface
outputFormat
string
RequiredThe output format for the generated asset
pdfpnghtmlmp4openGraph
pageSize
string
RequiredPage size for PDF, PNG, or MP4 output
fullletterA4custom
testData
object
RequiredTest data used for previewing the template with sample variable values
options
object
Additional rendering options
spaSource
object
Single page app source configuration (advanced)
rawSource
string
Raw HTML source stored in a variable, using handlebars syntax (e.g. {{myHtmlVariable}})
dynamicPrompt
string
Prompt to generate the HTML dynamically when sourceType is "dynamic"
dynamicSourceModelOverride
object
Model override for dynamic HTML generation. Leave undefined to use the default model
transitionControl
string
Controls how the step transitions after displaying in foreground mode
defaultnative
shareControl
string
Controls visibility of the share button on displayed assets
defaulthidden
shareImageUrl
string
URL of a custom Open Graph share image
intermediateAsset
boolean
When true, the asset is created but hidden from the user's gallery (tagged as intermediate)
Call from a method
import { mindstudio } from '@mindstudio-ai/agent'; const result = await mindstudio.generatePdf({ source: /* ... */, sourceType: /* ... */, outputFormat: /* ... */, pageSize: /* ... */, testData: /* ... */ });