public with sharing class PDFGenerationProxy { @AuraEnabled public static String generatePDFFromHTML(String htmlContent) { try { // Prepare the request Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://salesforce.tech4biz.io/generate-pdf'); request.setMethod('POST'); request.setHeader('Content-Type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'); // Create multipart form data String boundary = '----WebKitFormBoundary7MA4YWxkTrZu0gW'; String body = ''; body += '--' + boundary + '\r\n'; body += 'Content-Disposition: form-data; name="input"; filename="template.html"\r\n'; body += 'Content-Type: text/html\r\n\r\n'; body += htmlContent + '\r\n'; body += '--' + boundary + '--\r\n'; request.setBody(body); request.setTimeout(120000); // 2 minutes timeout // Make the callout HttpResponse response = http.send(request); if (response.getStatusCode() == 200) { // Convert the PDF response to base64 Blob pdfBlob = response.getBodyAsBlob(); return EncodingUtil.base64Encode(pdfBlob); } else { throw new CalloutException('API call failed with status: ' + response.getStatusCode() + ' - ' + response.getBody()); } } catch (Exception e) { throw new AuraHandledException('PDF generation failed: ' + e.getMessage()); } } @AuraEnabled public static String testAPIConnection() { try { // Test with simple HTML String testHtml = '