Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to run HTML2PDF on a generated page


Go to End


12 Posts   12251 Views

Avatar
EKaburu

Community Member, 7 Posts

24 February 2016 at 10:50pm

Edited: 24/02/2016 10:58pm

Yes I'm not using composer.
I also have tried the require_once thing and its still giving same error.

 
<?php
	require_once(BASE_PATH.'/tcpdf/thirdparty/tcpdf/tcpdf.php'); 
	class RaaOrders Extends ReportsModule {
 

Instead of giving you so much trouble, let me first try using composer then if it don't work I will get back to you please.

Avatar
EKaburu

Community Member, 7 Posts

25 February 2016 at 9:51am

@swaiba, thank you very much for suggesting composer will help me solve the issue. Can now generate pdf using the code in my function pdf(). Now the problem is getting it to render content that is in my .ss file to the pdf. How would I do that?

Avatar
swaiba

Forum Moderator, 1899 Posts

25 February 2016 at 8:23pm

This would achieve that..

$pdf = new TCPDF();
$pdf->AddPage();
$vd = new ViewableData();
$str = $vd->customise(ArrayData::create(array('MyVariable'=>'MyValue')))->renderWith('MyTemplateName');
$pdf->writeHTMLCell(0, 0, '', '', $str, 0, 1, 0, true, '', true);
$strContent = $pdf->Output(BASE_PATH.'/tmp/tmp.pdf', 'S');

Avatar
EKaburu

Community Member, 7 Posts

26 February 2016 at 4:54am

@Swaiba, everything is now working like a charm. I very much appreciate the help

Go to Top