Page 1 of 2
Joomla 3.8 - call to undefined method while generating a pdf
Posted: 22 Sep 2017, 12:53
by alenah502
Hi,
I have a problem with generating pdf from article - it gives this error. It worked before update
Call to undefined method Joomla\CMS\Document\RawDocument::setHeader() in ...components\com_content\views\article\view.pdf.php on line 131
The same for other methods in that file.
I have tried at two websites, even with a default Joomla protostar template.
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 22 Sep 2017, 13:48
by Jan
Hi, Joomla! 3.8 is now full of issues, can you let me know all the errors, so I can take a look at it (unfortunately for now I don't know if I should change it in code or if it will be fixed in some of next Joomla! version)
Jan
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 22 Sep 2017, 14:25
by alenah502
So far the only one.
The same error is also for these lines in view.pdf.php
$document->setArticleText($item->article_text);
$document->setArticleTitle($item->title);
Just a patch would be fine :), but if the new version is about to be released soon...
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 22 Sep 2017, 14:39
by Jan
Hi, I can add the patch when I know, it is not a bug in Joomla! which will be fixed.
For now, just try to comment all the rows with $document:
FROM:
Code: Select all
$document = JFactory::getDocument();
$document->setHeader($this->getHeaderText($item, $params));
echo $item->text;
$document->setArticleText($item->article_text);
$document->setArticleTitle($item->title);
TO:
Code: Select all
//$document = JFactory::getDocument();
//$document->setHeader($this->getHeaderText($item, $params));
echo $item->text;
//$document->setArticleText($item->article_text);
//$document->setArticleTitle($item->title);
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 22 Sep 2017, 15:11
by alenah502
Ok, thanks!
I have tried it - but the pdf is not generated - I get only a html page
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 25 Sep 2017, 14:20
by francky
I'm having the same issue, Commented those lines and just like alenah502, i only can have an html page.
So commenting just helps to give no error, but PDF isn't created
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 25 Sep 2017, 15:46
by JanMisker
The document rendering seems completely reworked in Joomla 3.8, there is no JDocument class anymore, instead there is a Document class in libraries/src/Document/
Any estimate on how long it will take to achieve compatibility with 3.8 ?
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 26 Sep 2017, 13:10
by JanMisker
I managed to get it working again with the new Document class. I created a file libraries/src/Document/PdfDocument.php and put in there the contents of libraries/joomla/document/pdf/pdf.php, with some small changes to the code, most important of course to extend from Document instead of JDocument.
I also had to re-apply a fix I made earlier to administrator/components/com_phocapdf/helpers/phocapdfrender.php, in the default: case there was no $pdf object created. This was needed to use it with my custom component.
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 26 Sep 2017, 14:19
by Paul33
Hi @janmisker,
I'm facing the same issue as you. Do you think you can share your modified files ?
Best regards,
Paul
Re: Joomla 3.8 - call to undefined method while generating a pdf
Posted: 29 Sep 2017, 09:28
by Jan
Hi @janmisker, yes, will be great if you can share the changes here.
Thank you, Jan