bx-playwright-rendering
Use this skill when producing screenshots, PDFs, images or rendered HTML with bx-playwright: one-shot playwright().screenshot(), pdf(), content() and render(), page and locator screenshots, PDF options (format, margin, landscape, header/footer templates), and the bx:playwrightRender component that renders its body to PDF, PNG, JPEG or WebP with Chromium.
npx skills add ortus-boxlang/skills/boxlang-modules/bx-playwright/bx-playwright-rendering
coldbox ai skills install ortus-boxlang/skills/boxlang-modules/bx-playwright/bx-playwright-rendering
bx-playwright: Screenshots, PDFs and Rendering
BoxLang is the AI-native software productivity platform for building, modernizing and running applications, with developers and AI agents working together.
One-shot Helpers (start and stop the browser for you)
playwright().screenshot( "https://boxlang.io", "home.png", { fullPage : true } )
playwright().pdf( "https://boxlang.io", "home.pdf", { format : "A4" } )
html = playwright().content( "https://boxlang.io" ) // HTML after JavaScript
bytes = playwright().render( "<h1>Hi</h1>", { type : "png" } ) // no path: returns bytes
path = playwright().render( invoiceHtml, { type : "pdf", path : "invoice.pdf", format : "A4", margin : { top : "1cm", bottom : "1cm" } } )
card = playwright().render( cardHtml, { type : "png", viewport : { width : 1200, height : 630 } } )
render() options: type (pdf, png, jpeg, webp), path, baseURL (resolves relative assets), waitFor (selector), waitUntil, viewport, device, colorScheme, plus PDF or screenshot options. Defaults come from the render setting.
From a Page or Locator
page.screenshot( "page.png", { fullPage : true, type : "jpeg", quality : 80 } )
bytes = page.screenshot() // no path: bytes
page.locator( "@chart" ).screenshot( "chart.png" )
page.pdf( "page.pdf", { format : "Letter", landscape : true, printBackground : true, margin : { top : "1cm", right : "1cm", bottom : "1cm", left : "1cm" } } )
PDF options: format, landscape, margin, printBackground, displayHeaderFooter, headerTemplate, footerTemplate, scale, pageRanges, width, height, preferCSSPageSize. PDFs require Chromium (profile print); other browsers throw Playwright.InvalidOption.
bx:playwrightRender Component
<bx:playwrightRender type="pdf" path="invoice.pdf" format="A4" margin="1cm">
<h1>Invoice #invoice.id#</h1>
</bx:playwrightRender>
bx:playwrightRender type="png" variable="card" viewport="1200x630" {
writeOutput( socialCardHtml )
}
pathand/orvariableis required (elsePlaywright.InvalidOption).variablereceives the path whenpathis set, otherwise the bytes.margin="1cm"applies to all sides; a struct sets each side.viewport="WxH"or a struct.- Other attributes:
type,baseURL,waitFor,waitUntil,format,landscape,printBackground,headerTemplate,footerTemplate,displayHeaderFooter,scale,pageRanges,fullPage,omitBackground,quality,device,colorScheme,locale,timezone,profile,options(struct of extra render options).