No Helvetica.afm file is being created when I use Next.js locally.
import { NextResponse } from 'next/server';
import PDFDocument from 'pdfkit';
export async function GET() {
// Create a new PDF document
const doc = new PDFDocument();
// Create a buffer to store the PDF data
const pdfBuffer: Buffer = await new Promise((resolve, reject) => {
const buffers: Uint8Array[] = [];
doc.on('data', buffers.push.bind(buffers));
doc.on('end', () => {
const pdfData = Buffer.concat(buffers);
resolve(pdfData);
});
// Add content to the PDF document
doc.fontSize(25).text('Hello, world!', 100, 100);
doc.fontSize(12).text('This PDF was generated server-side with pdfkit in Next.js.', 100, 150);
// Finalize the PDF
doc.end();
});
// Return the PDF as a response
return new NextResponse(pdfBuffer, {
headers: {
'Content-Type': 'application/pdf',
'Content-Length': pdfBuffer.length.toString(),
'Content-Disposition': 'inline; filename="output.pdf"', // or 'attachment;' for download
},
});
}
Bug Report
No Helvetica.afm file is being created when I use Next.js locally.
Description of the problem
I have to manually create a) the
datafolder and b) theHelvetica.afmfile in.next/server/vendor-chunksevery time I start the project.Code sample
Your environment