Template
Google Slides Template
Engine
Apps Script + Drive API
Output
PDF → Drive + Email
วิธีที่แนะนำ — Google Slides Template + Apps Script
📐
ทำไมใช้ Google Slides: ออกแบบ Certificate ใน Google Slides ได้ง่าย สวยงาม Apps Script แทนที่ Text Placeholder ([[NAME]], [[COURSE]], [[DATE]], [[SCORE]]) แล้ว Export เป็น PDF ได้โดยตรง ฟรี 100%
Apps Script Flow — Certificate Generation
→
→
Apps Script
Replace Placeholders
→
→
Apps Script Code — Certificate Generator
Code.gs — generateCertificate()
function generateCertificate(studentData) {
const TEMPLATE_ID = 'YOUR_SLIDES_TEMPLATE_ID';
const OUTPUT_FOLDER_ID = 'YOUR_DRIVE_FOLDER_ID';
// 1. Copy template
const template = DriveApp.getFileById(TEMPLATE_ID);
const certFile = template.makeCopy(
`Certificate_${studentData.name}_${studentData.course}`,
DriveApp.getFolderById(OUTPUT_FOLDER_ID)
);
// 2. Replace placeholders
const slides = SlidesApp.openById(certFile.getId());
const slide = slides.getSlides()[0];
slide.replaceAllText('[[NAME]]', studentData.name);
slide.replaceAllText('[[COURSE]]', studentData.course);
slide.replaceAllText('[[DATE]]', Utilities.formatDate(new Date(), 'Asia/Bangkok', 'dd MMMM yyyy'));
slide.replaceAllText('[[SCORE]]', `${studentData.score}/${studentData.max_score}`);
slide.replaceAllText('[[CERT_ID]]', generateCertId(studentData));
slides.saveAndClose();
// 3. Export as PDF
const pdfBlob = DriveApp.getFileById(certFile.getId())
.getAs('application/pdf');
pdfBlob.setName(`Certificate_${studentData.name}.pdf`);
// 4. Save PDF to Drive
const pdfFile = DriveApp.getFolderById(OUTPUT_FOLDER_ID).createFile(pdfBlob);
pdfFile.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
// 5. Send email with attachment
GmailApp.sendEmail(
studentData.email,
`🏅 ใบประกาศนียบัตร — ${studentData.course}`,
'',
{
htmlBody: buildCertEmailHTML(studentData, pdfFile.getUrl()),
attachments: [pdfBlob],
name: 'ทีมหลักสูตร'
}
);
// 6. Log to Sheets
logCertificate(studentData, pdfFile.getUrl());
// Delete Slides copy (keep only PDF)
certFile.setTrashed(true);
}
Certificate Template Placeholders ที่ต้องมีใน Google Slides
[[NAME]]
[[COURSE]]
[[DATE]]
[[SCORE]]
[[CERT_ID]]
[[INSTRUCTOR]]
[[ORG_NAME]]
ทางเลือก PDF Generation
วิธี A — แนะนำ: ฟรี
Google Slides + Apps Script
- ออกแบบใน Google Slides
- Apps Script Copy + Replace
- Export PDF ผ่าน Drive API
- ส่งอีเมลพร้อม Attachment
✓ ฟรี ออกแบบสวยได้ง่าย
✗ ต้องเขียน Apps Script เล็กน้อย
วิธี B — No-Code
Pabbly + Carbone/DocuPilot
- Upload Template ใน Carbone
- Pabbly ส่งข้อมูลไป API
- รับ PDF URL กลับมา
- Gmail ส่งพร้อม Link
✓ ไม่ต้องเขียนโค้ดเลย
✗ มีค่าใช้จ่าย $10–30/เดือน
วิธี C — Developer
n8n + Puppeteer/HTML→PDF
- ออกแบบ HTML Template
- n8n render HTML + inject data
- Puppeteer print เป็น PDF
- ส่งผ่าน SendGrid
✓ ควบคุมดีไซน์ได้ 100%
✗ ต้องการ Server + Dev skills