Forum


Replies: 7   Views: 5050
Saving pdf
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 xox  · 20-12-2010 - 13:29

Is it possible to save PDF file (converted from docx) to specif folder without direct download link provided? I'm asking for free version.

Posted by admin  · 11-04-2013 - 12:12

Hi xox,

You only need to replace in TransformDoc.inc file the following lines:

$fileName = $this->getFileName() . '.pdf';
$domPDF->stream($fileName);

with:

$pdf = $domPDF>output();
file_put_contents("saved_pdf.pdf", $pdf);

Remember to change saved_pdf to file name.

Regards.

Posted by xox  · 11-04-2013 - 12:12

It Doesn't work, all I get is
[quote]Fatal error: Call to undefined function output() in C:\phpdocx\classes\TransformDoc.inc on line 280[/quote]

[code] /**
* Convert DOCX to PDF, using dompdf. DOCX->XHTML->PDF
*
* @access public
*/
public function generatePDF()
{
$this->generateXHTML();
$this->cleanXHTML();
try {
$domPDF = new DOMPDF();
$domPDF->load_html($this->_xhtml);
$domPDF->render();
[b]$pdf = $domPDF>output();[/b]
file_put_contents(”trytosave.pdf”, $pdf);
}
catch (Exception $err) {
echo 'Unable to generate PDF file. ';
echo $err;
}
}[/code]

Line is 280 is marked with bold.

Posted by admin  · 11-04-2013 - 12:12

Hi,

Dompdf is used to generate PDF files. Please visit http://code.google.com/p/dompdf/ for more info.

There's an example to save PDF in disk at this page: http://code.google.com/p/dompdf/wiki/FAQ.

We have tested output method and is working ok. You must be doing something wrong in your code.

Regards.

Posted by xox  · 11-04-2013 - 12:12

Is it possible to show working example converting docx files to pdf and save to disk with dompdf in phpdocx ?

Regards,
xox

Posted by xox  · 11-04-2013 - 12:12

[quote][b]Quote from admin on December 21, 2010, 10:16[/b]
Hi,

[b]Dompdf[/b] is used to generate PDF files. Please visit http://code.google.com/p/dompdf/ for more info.

There's an example to save PDF in disk at this page: http://code.google.com/p/dompdf/wiki/FAQ.

We have tested output method and is working ok. You must be doing something wrong in your code.

Regards.[/quote]

I've contacted domPDF team and they say that they can't help because they support only html -> pdf and not docx-> pdf, this is why I'm posting here.

Posted by admin  · 11-04-2013 - 12:12

Hi,

Phpdocx uses a XSL file to do DOCX->HTML, and dompdf to do HTML->PDF. So if you want to save PDF as a file you should use dompdf functions.

The example you request is not available in phpdocx free; you can buy phpdocx pro or get a ticket support.

Regards.