Forum


Replies: 1   Views: 147
Change filename of streamed pdf or get in memory pdf from transform
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 11-10-2024 - 11:23

Hello,

There's no option in the current stable release of phpdocx to customize the Content-Disposition value when streaming a PDF using TransformDocAdvPDF.

We have added support in the testing branch. Please edit TransformDocAdvPDF.php and replace the following line:

$this->pdf->stream();

with:

$this->pdf->stream($target);

After this change, the target value will be used in Content-Disposition. This same change will be included in the next stable release of phpdocx.

Alternatively, you could use ob_ PHP methods (https://www.php.net/manual/en/ref.outcontrol.php) to get the PDF content and return it as needed:

$docx = new CreateDocx();
CreateDocx::$streamMode = true;
ob_start();
$docx->transformDocument('document.docx', 'document.pdf', 'native', array('dompdf' => $dompdf));
$pdfContent = ob_get_clean();
ob_end_clean();
// custom headers...
echo $pdfContent;
ob_end_flush();

Regards.