
CustomJS
Your AI agent generates PDFs, captures webpage screenshots, merges documents, and runs browser automation scripts through CustomJS, all triggered by customer requests. Invoices, reports, and visual snapshots produced on demand without developer involvement.




From converting HTML into polished PDFs to snapping screenshots of any URL, your agent executes CustomJS operations that would normally require a developer and a deployment pipeline.
CustomJS
Practical scenarios where AI agents use CustomJS to produce documents, capture visuals, and automate browser tasks for customers and internal teams.
A customer messages 'I need an invoice for my last three orders.' The AI agent gathers order data from your system, renders an HTML invoice template with line items, totals, and tax calculations, and sends it to CustomJS for PDF conversion. The customer receives a downloadable invoice within the conversation. No finance team intervention, no 24-hour wait.
A customer reports 'Your pricing page looks broken on mobile.' The AI agent captures a screenshot of the URL through CustomJS, attaches it to an internal ticket, and confirms to the customer that the visual evidence has been logged. Your development team gets a screenshot with the bug report instead of vague descriptions.
A sales prospect asks for a proposal package including the contract, pricing sheet, and case study. The AI agent collects the three PDF URLs, sends them to CustomJS for merging, and delivers a single combined document. The prospect gets everything in one file. Your sales rep never opens a PDF editor.

CustomJS
FAQs
The agent calls CustomJS's HTML to PDF endpoint, passing the HTML string and a JavaScript snippet that invokes the HTML2PDF converter. CustomJS renders the HTML in a headless browser and returns binary PDF data. The agent can then share the document as a download link or attach it to the conversation. CSS styling, images, and fonts are all preserved in the output.
Yes. The agent sends an array of PDF URLs to CustomJS's merge endpoint along with a JavaScript snippet that downloads each file and combines them using the PDF_MERGE utility. The result is a single merged PDF returned as binary data. You can merge contracts, invoices, appendices, or any combination of PDF documents in one API call.
CustomJS captures screenshots in PNG format at the page's native resolution. The Puppeteer-based renderer captures the full page or viewport depending on your script configuration. For higher resolution captures, you can set device scale factor in your Puppeteer script. The resulting images are suitable for documentation, bug reports, and visual QA.
No. CustomJS returns the binary data to Tars, which passes it to the conversation as a download or inline preview. Tars does not maintain a persistent file storage of generated documents. If you need long-term storage, configure your agent to upload files to your own cloud storage service after generation.
The agent can execute Puppeteer scripts that CustomJS supports, including page navigation, form interactions, element waiting, and screenshot capture. Scripts run in CustomJS's sandboxed environment with their Node.js runtime. Network access follows CustomJS's security policies. You control which scripts your agent is allowed to run through your Tars configuration.
Calling the API directly requires developer involvement for every document request. With Tars, your sales team can ask 'Generate a proposal PDF' or your customer can request 'Send me my invoice,' and the agent handles the API call, HTML templating, and file delivery automatically. No engineering tickets, no deployment cycles.
CustomJS uses a Chromium-based renderer, so it handles HTML and CSS the same way a modern browser would. If there are rendering issues like missing images or broken CSS, the PDF will reflect those problems. The agent can verify the output and notify your team if the generated file appears incomplete or malformed.
CustomJS processes PDF merges based on the total size of input files and your plan limits. Free plans support up to 600 operations per month. For large document packages, ensure individual PDFs are under the API's payload limits. The agent will report back if a merge operation fails due to size constraints so your team can split the request.
Don't limit your AI Agent to basic conversations. Watch how to configure and add powerful tools making your agent smarter and more functional.

Privacy & Security
At Tars, we take privacy and security very seriously. We are compliant with GDPR, ISO, SOC 2, and HIPAA.