Joomla 3.8 - call to undefined method while generating a pdf

Phoca PDF - creating PDF documents in Joomla! CMS
alenah502
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 22 Sep 2017, 12:50

Joomla 3.8 - call to undefined method while generating a pdf

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post 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) :idea:

Jan
If you find Phoca extensions useful, please support the project
alenah502
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 22 Sep 2017, 12:50

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post 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...
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post 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);
If you find Phoca extensions useful, please support the project
alenah502
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 22 Sep 2017, 12:50

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post by alenah502 »

Ok, thanks!
I have tried it - but the pdf is not generated - I get only a html page
francky
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 25 Sep 2017, 14:06

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post 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
JanMisker
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 25 Sep 2017, 15:41

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post 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 ?
JanMisker
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 25 Sep 2017, 15:41

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post 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.
Paul33
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 06 Sep 2017, 10:15

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post by Paul33 »

Hi @janmisker,

I'm facing the same issue as you. Do you think you can share your modified files ?

Best regards,

Paul
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Joomla 3.8 - call to undefined method while generating a pdf

Post by Jan »

Hi @janmisker, yes, will be great if you can share the changes here.

Thank you, Jan
If you find Phoca extensions useful, please support the project
Post Reply