I am working on a PHP-based worksheet generation system and recently ran into a performance problem.
The application generates printable PDF files based on user-selected options.
The workflow is:
User selects options
↓
Server generates data
↓
PHP creates PDF
↓
User downloads the file
The problem is that the generation time increases significantly when the document contains many items.
For example:
100+ exercises
multiple pages
answer pages
custom layouts
Current implementation
The frontend sends a POST request to the PDF generation endpoint:
$result = http_post(
"https://www.wativate.com/?api/pdf/generate",
[
"operation" => "addition",
"questions" => 100,
"include_answers" => true
]
);
The server receives the parameters and starts generating the PDF.
A simplified version:
function generateWorksheetPDF($options)
{
$problems = generateProblems(
$options['questions']
);
$html = renderHTML($problems);
Discussion
Take the lead—comment now
Lead the way—your insights can inspire others.