Joomla!-开源天空

2008-10-08
首页 专栏热点 Joomla! 源代码分析 如何给Joomla!组件扩展添加PDF


如何给Joomla!组件扩展添加PDF

E-mail

在Joomla! 1.5下,JDocuemntPDF可以简单实现PDF文件的生成。例如,我们给一个组件添加PDF,只要在视图目录下,添加一个view.pdf.php 就可以生成相应的PDF文件。简单的代码示例如下:

<?php 
jimport( 'joomla.application.component.view');
class TestViewTest extends JView
{
 function display($tpl = null)
 {
  global $mainframe;
  $document = &JFactory::getDocument();
  // set document information
  $document->setTitle('this is title');
  $document->setName('this is name');
  $document->setDescription('this is description');
  $document->setMetaData('keywords', 'this is key word');
  // prepare header lines
  $document->setHeader('this is header line');
  echo 'this is content';
 }
}
?>

现在你就可以在浏览器中访问这个PDF文件了,路径是http://yourdomain.com/index.php?option=com_test&view=test&format=pdf

就这么简单,快点试试吧。

相关文章:
一个在文章正文中显示幻灯的插件
这篇关于Joomla! unit testing 的文章值得看
怎样创建一个Joomla! 1.5 新用户
如何修改mod_latestnews模块以显示文章的发布日期
给自己开发的Joomla!组件增加RSS
如何在Joomla!管理后台中添加自定义的按钮
给自己的Joomla!组件扩展添加参数
如何在Joomla!组件扩展中添加验证码captcha,程序修改篇
怎样强制自己退出登陆状态
如何在Joomla!组件扩展中添加验证码captcha,服务器配置篇


收藏此文章:
Digg! Reddit! Del.icio.us! JoomlaVote! Google! Live! Facebook! StumbleUpon! Yahoo! Free social bookmarking plugins and extensions for Joomla! websites!

发表您的文章评论

您的姓名 (昵称)
标题:
评分: 很差一般较好很好
评论:
验证码:
请输入验证码