As far as i know Freshservice does not have a direct API to download or print a ticket as a PDF.
If it is possible please someone correct me.
However, you can achieve this using the following approaches:
Option 1: Use Headless Browser Automation (Recommended)
Since Freshservice provides a printable view (/print
URL), you can use a headless browser (like Puppeteer or Selenium) to programmatically open the URL and save it as a PDF.
Example using Puppeteer (Node.js)
javascript
CopyEdit
const puppeteer = require('puppeteer'); (async () => { const ticketId = "12345"; // Change this dynamically const url = `https://helpdesk.ABC.com/a/tickets/${ticketId}/print`; const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto(url, { waitUntil: 'networkidle2' }); await page.pdf({ path: `ticket_${ticketId}.pdf`, format: 'A4' }); await browser.close(); console.log(`Ticket ${ticketId} saved as PDF.`); })();
- You must be authenticated before accessing the page. Use session cookies or login automation.
Option 2: Use Third-Party Screenshot API
If you don’t want to use Puppeteer, you can use services like:
These can take a screenshot of the ticket’s print page and convert it into a PDF.
Option 3: Manually Generate a PDF from Ticket Data
- Use Freshservice API to get ticket details:
GET /api/v2/tickets/{ticket_id}
- Format the ticket data into an HTML template.
- Use a library like wkhtmltopdf or jsPDF to generate a PDF from the HTML content.
Hope one of these might help you out
Hi,
thanks for your input
tried headless selenium, have to go through company login page and MFA (Zzz...)
thanks!
Jonathan