I want to get a pdf of post details , so I installed sfTCPDFPlugin. I'm a new to it so can any one help me with this?
How to generate PDF using sfTCPDFPilugin in symfony 1.4?
The main problem you seems to have is to get the HTML output from your template to put it into the generated PDF. For that, you can use getPartial or getPresentationFor.
getPartial will render a partial
getPresentationFor will render a module/action
I recommend you to use the getPartial. Create a partial with the content you want to extract (and by the way, you will be able to use the same partial elsewhere if you need the same information to be viewable as html).
Assuming you create a partial called _my_partial.php, you can do that:
public function executePdf()
{
$config = sfTCPDFPluginConfigHandler::loadConfig();
/* put all your PDF configuration */
$html = $this->getPartial(
'my_partial',
// put in this array all variables you want to give to the partial
array('posts' => $posts)
);
$pdf->writeHTMLCell(
$w=0,
$h=0,
$x='',
$y='',
$html,
$border=0,
$ln=1,
$fill=0,
$reseth=true,
$align='',
$autopadding=true
);
$pdf->Output('example_001.pdf', 'I');
throw new sfStopException();
}
Refer link for step by step to generate PDF using sfTCPDFPlugin.
http://www.symfony-project.org/plugins/sfTCPDFPlugin/1_6_3?tab=plugin_readme
Related
i need to create a module on prestashop on product page , im new in prestashop idk how to do that .
This module should be on bottom of page ,it contains product technical description
Can someone tell me how to do that
Ps : i know nothing about prestashop Hooks ....
Thanks in advance!
There is one hook that may fit you.
displayProductFooter
First you have to add the hook registration in your module install function
public function install()
{
...
$this->registerHook('displayProductFooter');
}
Then create a function to display the content in the hook
Save the content you want to display and use the return to send a string with all the HTML you want to print in the product footer.
In the params you will also find some useful variables like the product ID.
public function hookDisplayProductFooter($params)
{
// Your content here
return $output;
}
The same procedure should work with any other hook (as long as it's a display hook)
Hi guys ,
I'm currently working on a Drupal project which use the Panelizer module by overriding the default node display. The panel for this content type is made width a lot of rules and specifications in order to display some specific content (like views) according some fields.
Now I need to print in PDF the same content that is displayed by the panelizer module but in another display (in one column ), so I cloned the display I use and rearranged it to display what I want.Then I want to use this display width the print module but I didn't managed to do that.
Any idea how can I do that ?
I just can't use the default node render, because I would miss some informations dues to the specifications used in the panel, and I can't print the panelized content because it's not the same display.
I read this thread but how can I say to the print module to use the "print" display I cloned instead of the default one ?
Any suggestions or ideas will be appreciated or if you have another idea for doing that you're welcome :)
Thank you !
In your print pdf template you can load the node then create a view with the display and finally render it : drupal_render(node_view(node_load($node->nid), "name of your display")) ;
Another way is to alter node entity info, telling that 'print' view can be panelized, i.e.
/**
* Implements hook_entity_info_alter().
*/
function mymodule_entity_info_alter(&$entity_info) {
$entity_info['node']['view modes']['print']['custom settings'] = TRUE;
...
}
After that, you go to panelizer settings of your content type(s), and set whatever you want for the print view mode
How to use PDDestination class in PDFbox ?
whether getPagenumber() method will return the current page number
can any one share u r views
Thanks
The usage of PDDestination or PDAction is very similar to the one of PdfDestination or PdfAction of iText.
So you may want to search iText examples firstly.
Specifically on PDFBox,
e.g.
the following makes the first open page to page 5.
PDDestination dest = new PDPageDestination();
// When you open this PDF, you will see page 5.
dest.setPageNumber(4)
PDActionGoTo action = new PDActionGoTo();
action.setDestination(dest);
document.getDocumentCatalog().setOpenAction(action);
I have this header that it's fixed across all pages except, the logo. The logo varies a little in color, regarding the page where the user are.
Should we set that on the corresponded controller and call it on the layout.php page ?
On controller
public $param = 'logoimagename';
On layout
echo $this->param
I've heard that Yii by design doesn't favor this, is there any better way ?
I would implement it using an helper function with a signature like this:
function getLogoName($controller, $action, ...){
$logo = Yii::app()->params['default_logo'];
$logo_rules = Yii::app()->params['logo_rules'];
// check if controller and action match any of the logo rules and get the logo name if found; use the default one otherwise
return $logo;
}
The default_logo and the logo_rules are parameters you have to set up in the config files.
In the view files, you could simply write:
echo .... getLogoName($this->id, $this->action->id, ...);
I have a php file under protected/views/directory_controller_name with formatting like that
<p>
<?php echo $model->title;?>
</p>
...
I display the file with classic method in the controller :
$this->render('filename',array('model'=>$model));
But know, I need to send an email with the same template/layout so I want to store the render of the file in an variable like
$msgHTML = $this->renderInternal('_items', array('model'=>$model));
But it doesn't work!
How can I get render view from a file and store in a variable?
Is it possible?
I don't want to use:
$msgHTML = '<p>'.$model->title.'</p>'
...
Because the file is very long and I don't want to duplicate code!!!
Don't use the renderInternal method, use renderPartial instead. Render internal is low level method and should not be used in such context. To catch the output just set the $return parameter to true:
<?php $output = $this->renderPartial('_subView', $dataArray, true); ?>
$msgHTML = $this->renderInternal('_items', array('model'=>$model), true);
http://www.yiiframework.com/doc/api/1.1/CBaseController#renderInternal-detail
I might be missing something, but can't you just use regular render() with the return argument set to true? Then you can just use a view 'name' instead of knowing the path. (And unless my trusty stack trace logger is broken, renderFile and renderInternal take the same fully qualified path argument. At least I can see renderPartial() passing the full path to my view file to renderFile.)
you can do this with these ways
1) if you want to get the output with header and footer (i.e ) full layout then do this
//add true in the last parameter if you want a return of the output
$htmloutput=$this->render('_pdfoutput',array('data'=>'nothing'),true);
2) similarly if you don't want to get the layout files just use renderpartial in the same way
$htmloutput=$this->renderpartial('_pdfoutput',array('data'=>'nothing'),true);
you will get the html of files in the variable . use this anywhere