browser_pdf_save
Save web pages as PDFs for accessibility compliance checks. Specify a custom filename or use a default timestamp-based name to store the document for further review.
Instructions
Save page as PDF
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. |
Implementation Reference
- src/tools/pdf.ts:37-42 (handler)The handler function for the 'browser_pdf_save' tool. It generates an output filename (defaulting to 'page-{timestamp}.pdf'), adds generated code and result message to the response, and saves the current page as PDF using Playwright's page.pdf() method.handle: async (tab, params, response) => { const fileName = await tab.context.outputFile(params.filename ?? `page-${new Date().toISOString()}.pdf`); response.addCode(`await page.pdf(${javascript.formatObject({ path: fileName })});`); response.addResult(`Saved page as ${fileName}`); await tab.page.pdf({ path: fileName }); },
- src/tools/pdf.ts:22-24 (schema)Zod schema defining the input parameters for the tool: an optional 'filename' string.const pdfSchema = z.object({ filename: z.string().optional().describe('File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.'), });
- src/tools/pdf.ts:29-35 (schema)Tool metadata schema including name, title, description, inputSchema reference, and readOnly type.schema: { name: 'browser_pdf_save', title: 'Save as PDF', description: 'Save page as PDF', inputSchema: pdfSchema, type: 'readOnly', },
- src/tools/pdf.ts:26-47 (registration)Defines the 'browser_pdf_save' tool using defineTabTool and exports it as the default array for inclusion in the tools registry.const pdf = defineTabTool({ capability: 'pdf', schema: { name: 'browser_pdf_save', title: 'Save as PDF', description: 'Save page as PDF', inputSchema: pdfSchema, type: 'readOnly', }, handle: async (tab, params, response) => { const fileName = await tab.context.outputFile(params.filename ?? `page-${new Date().toISOString()}.pdf`); response.addCode(`await page.pdf(${javascript.formatObject({ path: fileName })});`); response.addResult(`Saved page as ${fileName}`); await tab.page.pdf({ path: fileName }); }, }); export default [ pdf, ];
- src/tools.ts:50-50 (registration)Includes the pdf tools (including 'browser_pdf_save') in the allTools array that is used by the backend for listTools()....pdf,