const fs = require('fs');
const path = require('path');

// 读取PDF文件并转换为Data URL
const pdfPath = path.join(__dirname, 'public', 'sample.pdf');
const pdfBuffer = fs.readFileSync(pdfPath);
const base64 = pdfBuffer.toString('base64');
const dataUrl = `data:application/pdf;base64,${base64}`;

// 保存到文件
fs.writeFileSync(path.join(__dirname, 'pdf-data-url.txt'), dataUrl);

console.log('PDF Data URL generated successfully!');
console.log('First 100 characters:', dataUrl.substring(0, 100) + '...');