feat: Carbone Word template integration with DOCX merge and LibreOffice PDF conversion

This commit is contained in:
root
2026-07-16 09:03:44 +00:00
parent ffa4655d39
commit 9dc14b0f58
11 changed files with 2696 additions and 3 deletions

44
renderer/test_carbone.js Normal file
View File

@@ -0,0 +1,44 @@
// Test Carbone render with master template + sample data
const carbone = require('carbone');
const { transformCandidateData } = require('./carbone-service');
const fs = require('fs');
const candidateData = {
candidate: {
first_name: 'John', last_name: 'Smith',
email: 'john.smith@email.com', phone: '+1-555-123-4567',
address: 'Cape Town, South Africa',
linkedin: 'linkedin.com/in/johnsmith',
github: 'github.com/jsmith',
summary: 'Experienced software engineer with 8+ years in full-stack development specializing in .NET technologies and cloud architecture.'
},
skills: [
{ skill_name: 'C# / .NET', skill_category: 'Programming', proficiency: 'Expert', years_experience: 8.5 },
{ skill_name: 'Azure Cloud', skill_category: 'Cloud', proficiency: 'Advanced', years_experience: 6.5 },
{ skill_name: 'React', skill_category: 'Frontend', proficiency: 'Advanced', years_experience: 5.5 }
],
experience: [
{ position: 'Senior Software Engineer', company: 'TechCorp', location: 'Cape Town', start_date: '2022-01-01', end_date: null, description: 'Led team building cloud-native microservices.', achievements: ['Reduced deployment time 70%', 'Architected event-driven system'], skills_used: ['C#','Azure','Docker'] },
{ position: 'Software Engineer', company: 'DataSoft', location: 'Johannesburg', start_date: '2019-03-01', end_date: '2021-12-01', description: 'Developed ASP.NET Core APIs.', achievements: ['Built React dashboard'], skills_used: ['C#','React'] }
],
education: [{ degree: 'BSc Computer Science', field_of_study: 'Computer Science', institution: 'University of Cape Town', start_date: '2014-01-01', end_date: '2017-12-01', grade: 'First Class' }],
certifications: [{ name: 'Azure Developer Associate', issuer: 'Microsoft', issue_date: '2021-06-01' }]
};
const data = transformCandidateData(candidateData, '2026-07-16');
console.log('Transformed data keys:', Object.keys(data));
console.log('Experience count:', data.experience.length);
console.log('Skills count:', data.skills.length);
const templatePath = './carbone-templates/master_cv_template.docx';
const options = { convertTo: 'pdf', hardRefreshCache: true };
carbone.render(templatePath, data, options, function(err, result) {
if (err) {
console.error('ERROR:', err.message);
process.exit(1);
}
const outPath = './output/carbone_test.pdf';
fs.writeFileSync(outPath, result);
console.log('PDF saved:', outPath, 'Size:', result.length, 'bytes');
});