Skip to content

Commit 7106d6e

Browse files
momo_102@bluemail.chmomo_102@bluemail.ch
authored andcommitted
Init pdf labels
1 parent 6142b86 commit 7106d6e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

admin/helpers/pdflabels.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* @version $Id$
4+
* @package Joomla
5+
* @subpackage ClubManagement-Tools
6+
* @copyright Copyright (c) 2014 Norbert Kuemin. All rights reserved.
7+
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE
8+
* @author Norbert Kuemin
9+
* @authorEmail momo_102@bluemail.ch
10+
*/
11+
12+
// Check to ensure this file is included in Joomla!
13+
defined('_JEXEC') or die('Restricted access');
14+
15+
/**
16+
* CVS helper.
17+
*
18+
* @package Joomla
19+
* @subpackage com_clubmanagement
20+
* @since 3.0
21+
*/
22+
class PdfLabelsHelper {
23+
public static function saveLabels($data, $settings = array(), $filename = 'output.pdf') {
24+
$pdf = self::_initPdf();
25+
self::_printLabels($pdf, $data, $settings);
26+
$buffer = self::_finishPdf($pdf);
27+
header('Content-Type: application/pdf');
28+
header('Content-Length: '.strlen($buffer));
29+
header('Content-Disposition: attachment; filename="'.$filename.'"');
30+
header('Content-Transfer-Encoding: binary');
31+
header('Expires: 0');
32+
header('Pragma: no-cache');
33+
print $buffer;
34+
// Close the application.
35+
$app = JFactory::getApplication();
36+
$app->close();
37+
}
38+
39+
private static function _initPdf($settings) {
40+
$pdf = PDF_new();
41+
$optlist = 'destination={page=1 type=fixed top=100 left=50}';
42+
if (PDF_begin_document($pdf, "", "") == 0) {
43+
die("Error: " . PDF_get_errmsg($pdf));
44+
}
45+
$user = JFactory::getUser();
46+
PDF_set_info($pdf, "Creator", "PdfLabelsHelper");
47+
if (!$user->guest) {
48+
PDF_set_info($pdf, "Author", $user->name);
49+
}
50+
PDF_set_info($pdf, "Title", "Labels");
51+
return $pdf;
52+
}
53+
54+
private static function _initPdf() {
55+
PDF_end_document($pdf, "");
56+
return PDF_get_buffer($pdf);
57+
}
58+
59+
private _calcMilimeterToPoints($amount) {
60+
return intval($amount*2.833333333+0.5);
61+
}
62+
63+
private _printLabels($pdf, $data, $settings) {
64+
$row = 1;
65+
$col = 1;
66+
}
67+
}
68+
?>

0 commit comments

Comments
 (0)