From: <al...@us...> - 2007-08-19 12:46:40
|
Revision: 509 http://sciret.svn.sourceforge.net/sciret/?rev=509&view=rev Author: alpeb Date: 2007-08-19 05:46:39 -0700 (Sun, 19 Aug 2007) Log Message: ----------- New feature download pdf for article Added Paths: ----------- branches/release-candidates/sciret-1.2/actions/ArticleToPdf.php Added: branches/release-candidates/sciret-1.2/actions/ArticleToPdf.php =================================================================== --- branches/release-candidates/sciret-1.2/actions/ArticleToPdf.php (rev 0) +++ branches/release-candidates/sciret-1.2/actions/ArticleToPdf.php 2007-08-19 12:46:39 UTC (rev 509) @@ -0,0 +1,44 @@ +<?php + +require_once 'actions/Action.php'; +require_once 'models/Article.php'; +require_once 'tcpdf/tcpdf.php'; + +class ArticleToPdf extends Action { + + function dispatch() { + + $article = new Article($_GET['artId']); + if (!$article->getId()) { + die($this->user->lang('Error: article does not exist')); + } + if ($this->user->isAnonymous() && !$article->isPublished()) { + die($this->user->lang('Error: this article hasn\'t yet been published')); + } + + $name = $this->user->lang('article_').$article->getId(); + + set_time_limit(0); + + $pdf = new TCPDF('P', 'mm', 'A4', true); + $pdf->setHeaderFont(Array('freeserif', '', 10)); + $pdf->setFooterFont(Array('freeserif', '', 8)); + $pdf->AliasNbPages(); + $pdf->AddPage(); + $pdf->writeHTML($article->getContent(), true, 0); + $output = $pdf->Output($name, 'S'); + + if (ob_get_contents()) ob_end_clean(); + header("Content-type: application/octet-stream"); + header("Content-Disposition: attachment; filename=\"".$name.".pdf\""); + header("Content-Length: ".strlen($output)); + // work-around IE bug when using SSL + header("Pragma: public"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Expires: 0"); + echo $output; + exit; + } +} + +?> Property changes on: branches/release-candidates/sciret-1.2/actions/ArticleToPdf.php ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |