Page 1 of 1
Increase limit of open files
Posted: Tue 21. May 2024, 13:24
by PuntonetSvb
I have a php program that joins thousands of pdf files into one just to send it to the printer, but the moment I go beyond 1024 I get the error:
I have followed all the tutorials I have found, I have modified the /proc/sys/fs/file-max file
I have tried:
sysctl -w fs.file-max=600000
but I'm still the same as I was, as soon as I go beyond 1024 open files the program stops and the error appears
AH01071: Got error 'PHP message: PHP Warning: fopen(./fras/1017.pdf): Failed to open stream: Too many open files in
Re: Increase limit of open files
Posted: Tue 21. May 2024, 13:29
by 24unix
Why don't you just close the files after concating with the main file?
Re: Increase limit of open files
Posted: Tue 21. May 2024, 14:31
by Tobi
My suggestion:
Combine the first 1000 files into one file.
Then the next 1000 files.
And so on.
After the these combinations, you can combine the 1000-combine-files into one extreme large file.
Re: Increase limit of open files
Posted: Tue 21. May 2024, 14:52
by Jolinar
Consider Alternatives:
- Command-line tools: Tools like pdftk offer command-line PDF merging options that might be more efficient for large datasets.
- Third-party libraries: Explore dedicated PDF manipulation libraries like setasign/fpdi for PHP that offer optimized functionalities for merging PDFs.
Re: Increase limit of open files
Posted: Wed 22. May 2024, 16:57
by PuntonetSvb
Jolinar wrote: ↑Tue 21. May 2024, 14:52
Consider Alternatives:
- Command-line tools: Tools like
pdftk offer command-line PDF merging options that might be more efficient for large datasets.
- Third-party libraries: Explore dedicated PDF manipulation libraries like
setasign/fpdi for PHP that offer optimized functionalities for merging PDFs.
I use this library, but I didn't find an option to close the file after importing it
// set the source file
$pdf->setSourceFile($fichero);
// import page 1
$tplId = $pdf->importPage(1);
No matter how much I searched, I couldn't find the option to close the file after importing it.
Re: Increase limit of open files
Posted: Sun 2. Jun 2024, 16:31
by BasHeijermans
Openfile -> append to main-file -> close file -> next pdf.
Looks to me you keep them open all the time.
Why don't you do the above? Then it doesn't matter how many files you have.