This function can only be used when you are writing a file to memory and not to a physical file. Otherwise you will get an error like this one: Don't fetch buffer contents when writing to file.
PHP - Manual: PDF_get_buffer
2024-11-15
(PHP 4 >= 4.0.5, PECL pdflib >= 1.0.0)
PDF_get_buffer — Get PDF output buffer
$p
) : stringFetches the buffer containing the generated PDF data.
This function can only be used when you are writing a file to memory and not to a physical file. Otherwise you will get an error like this one: Don't fetch buffer contents when writing to file.
If you plan to use get_buffer() you have to call open_file() with an
empty filename.
官方地址:https://www.php.net/manual/en/function.pdf-get-buffer.php