Files
aue/create-sample-pdf.cjs
2026-06-03 13:16:30 +08:00

64 lines
1.1 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const minimalPdfContent = `%PDF-1.4
1 0 obj
<< /Type /Catalog /Pages 2 0 R >>
endobj
2 0 obj
<< /Type /Pages /Kids [3 0 R] /Count 1 >>
endobj
3 0 obj
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792]
/Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>
endobj
4 0 obj
<< /Length 200 >>
stream
BT
/F1 12 Tf
100 700 Td
(Sample PDF Document) Tj
0 -20 Td
(This is a sample PDF file for testing the PDF reader.) Tj
0 -20 Td
(You can use this to test:) Tj
0 -20 Td
(- Text selection and highlighting) Tj
0 -20 Td
(- Adding comments and annotations) Tj
0 -20 Td
(- Voice reading functionality) Tj
0 -20 Td
(- Page navigation) Tj
0 -20 Td
(- Zoom controls) Tj
ET
endstream
endobj
5 0 obj
<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>
endobj
xref
0 6
0000000000 65535 f
0000000009 00000 n
0000000058 00000 n
0000000115 00000 n
0000000266 00000 n
0000000518 00000 n
trailer
<< /Size 6 /Root 1 0 R >>
startxref
589
%%EOF`;
const outputPath = path.join(__dirname, 'public', 'sample.pdf');
fs.writeFileSync(outputPath, minimalPdfContent, 'binary');
console.log('Sample PDF created at:', outputPath);