Exemple #1
0
 public function fillText($text, $x, $y, $maxWidth = null)
 {
     if (self::DEBUG) {
         echo __FUNCTION__ . "\n";
     }
     $this->canvas->addText($x, $y, $this->style->fontSize, $text);
 }
 function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0)
 {
     list($r, $g, $b) = $color;
     $this->_pdf->setColor($r, $g, $b);
     $this->_set_line_transparency($blend, $opacity);
     $this->_set_fill_transparency($blend, $opacity);
     $font .= ".afm";
     $this->_pdf->selectFont($font);
     $this->_pdf->addText($x, $this->y($y) - Font_Metrics::get_font_height($font, $size), $size, utf8_decode($text), $angle, $adjust);
 }
 function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0)
 {
     list($r, $g, $b) = $color;
     $this->_pdf->setColor($r, $g, $b);
     $this->_set_line_transparency($blend, $opacity);
     $this->_set_fill_transparency($blend, $opacity);
     $font .= ".afm";
     $this->_pdf->selectFont($font);
     //Font_Metrics::get_font_height($font, $size) ==
     //$this->get_font_height($font, $size) ==
     //$this->_pdf->selectFont($font),$this->_pdf->getFontHeight($size)
     //- FontBBoxheight+FontHeightOffset, scaled to $size, in pt
     //$this->_pdf->getFontDescender($size)
     //- Descender scaled to size
     //
     //$this->_pdf->fonts[$this->_pdf->currentFont] sizes:
     //['FontBBox'][0] left, ['FontBBox'][1] bottom, ['FontBBox'][2] right, ['FontBBox'][3] top
     //Maximum extent of all glyphs of the font from the baseline point
     //['Ascender'] maximum height above baseline except accents
     //['Descender'] maximum depth below baseline, negative number means below baseline
     //['FontHeightOffset'] manual enhancement of .afm files to trim windows fonts. currently not used.
     //Values are in 1/1000 pt for a font size of 1 pt
     //
     //['FontBBox'][1] should be close to ['Descender']
     //['FontBBox'][3] should be close to ['Ascender']+Accents
     //in practice, FontBBox values are a little bigger
     //
     //The text position is referenced to the baseline, not to the lower corner of the FontBBox,
     //for what the left,top corner is given.
     //FontBBox spans also the background box for the text.
     //If the lower corner would be used as reference point, the Descents of the glyphs would
     //hang over the background box border.
     //Therefore compensate only the extent above the Baseline.
     //
     //print '<pre>['.$font.','.$size.','.$this->_pdf->getFontHeight($size).','.$this->_pdf->getFontDescender($size).','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3].','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][1].','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontHeightOffset'].','.$this->_pdf->fonts[$this->_pdf->currentFont]['Ascender'].','.$this->_pdf->fonts[$this->_pdf->currentFont]['Descender'].']</pre>';
     //
     //$this->_pdf->addText($x, $this->y($y) - Font_Metrics::get_font_height($font, $size), $size, $text, $angle, $adjust);
     //$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust);
     //$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust);
     $this->_pdf->addText($x, $this->y($y) - $this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3] * $size / 1000, $size, $text, $angle, $adjust);
 }
     $DisplayTax = locale_number_format($myrow['ovgst'], $myrow['decimalplaces']);
     $DisplayTotal = locale_number_format($myrow['ovfreight'] + $myrow['ovgst'] + $myrow['ovamount'], $myrow['decimalplaces']);
 } else {
     $DisplaySubTot = locale_number_format(-$myrow['ovamount'], $myrow['decimalplaces']);
     $DisplayFreight = locale_number_format(-$myrow['ovfreight'], $myrow['decimalplaces']);
     $DisplayTax = locale_number_format(-$myrow['ovgst'], $myrow['decimalplaces']);
     $DisplayTotal = locale_number_format(-$myrow['ovfreight'] - $myrow['ovgst'] - $myrow['ovamount'], $myrow['decimalplaces']);
 }
 /*Print out the invoice text entered */
 $YPos = $Bottom_Margin + 3 * $line_height;
 /* Print out the payment terms */
 $pdf->addTextWrap($Left_Margin, $YPos + 3, 280, $FontSize, _('Payment Terms') . ': ' . $myrow['terms']);
 $FontSize = 8;
 $LeftOvers = explode("\r\n", DB_escape_string($myrow['invtext']));
 for ($i = 0; $i < sizeOf($LeftOvers); $i++) {
     $pdf->addText($Left_Margin, $YPos - 8 - $i * 8, $FontSize, $LeftOvers[$i]);
 }
 $FontSize = 10;
 $LeftOvers = $pdf->addTextWrap($Page_Width - $Right_Margin - 220, $YPos + 5, 72, $FontSize, _('Sub Total'));
 $LeftOvers = $pdf->addTextWrap($Page_Width - $Left_Margin - 72, $YPos + 5, 72, $FontSize, $DisplaySubTot, 'right');
 $LeftOvers = $pdf->addTextWrap($Page_Width - $Right_Margin - 220, $YPos + 5 - $line_height, 72, $FontSize, _('Freight'));
 $LeftOvers = $pdf->addTextWrap($Page_Width - $Left_Margin - 72, $YPos + 5 - $line_height, 72, $FontSize, $DisplayFreight, 'right');
 $LeftOvers = $pdf->addTextWrap($Page_Width - $Right_Margin - 220, $YPos + 5 - $line_height * 2, 72, $FontSize, _('Tax'));
 $LeftOvers = $pdf->addTextWrap($Page_Width - $Left_Margin - 72, $YPos + 5 - $line_height * 2, 72, $FontSize, $DisplayTax, 'right');
 /*rule off for total */
 $pdf->line($Page_Width - $Right_Margin - 222, $YPos - 2 * $line_height, $Page_Width - $Right_Margin, $YPos - 2 * $line_height);
 /*vertical to separate totals from comments and ROMALPA */
 $pdf->line($Page_Width - $Right_Margin - 222, $YPos + $line_height, $Page_Width - $Right_Margin - 222, $Bottom_Margin);
 $YPos += 10;
 if ($InvOrCredit == 'Invoice') {
     $LeftOvers = $pdf->addTextWrap($Page_Width - $Right_Margin - 220, $Bottom_Margin + 5, 144, $FontSize, _('TOTAL INVOICE'));
            $pdf->setLineStyle(1);
        }
        $pdf->line($left_margin, $c, $note_section_width, $c);
        $c = $c + $line_height;
    }
}
// Set the line color/style
$pdf->setStrokeColor(0, 0, 0);
if (isset($_GET['use_light_lines'])) {
    $pdf->setLineStyle(0.5);
} else {
    $pdf->setLineStyle(1);
}
// Draw the title
$note_title_left_margin = round($note_section_width / 2, 2);
$pdf->addText($note_title_left_margin, $note_section_height, 10, "Notes", 0, 0);
//+----------------------------------------------------------------------+
//| DRAW THE PAGE BOX
//+----------------------------------------------------------------------+
// Calculate page width using margins
$page_width = 580 - $left_margin;
$pdf->rectangle($left_margin, $bottom_margin, $page_width, 752);
// Page box
//+----------------------------------------------------------------------+
//| DRAW THE ACTION ITEMS BOX
//+----------------------------------------------------------------------+
// Calculate the width using margins
$action_width = 230;
// Draw the rectangle
$pdf->rectangle($note_section_width, $bottom_margin, $action_width, 752);
// Action items section box
 $YPos = $Bottom_Margin + 3 * $line_height;
 /* Print out the payment terms */
 $pdf->addTextWrap($Left_Margin + 5, $YPos + 3, 280, $FontSize, _('Payment Terms') . ': ' . $myrow['terms']);
 //      $pdf->addText($Page_Width-$Right_Margin-392, $YPos - ($line_height*3)+22,$FontSize, _('Bank Code:***** Bank Account:*****'));
 //	$FontSize=10;
 $FontSize = 8;
 $LeftOvers = $pdf->addTextWrap($Left_Margin + 5, $YPos - 12, 280, $FontSize, $myrow['invtext']);
 if (mb_strlen($LeftOvers) > 0) {
     $LeftOvers = $pdf->addTextWrap($Left_Margin + 5, $YPos - 24, 280, $FontSize, $LeftOvers);
     if (mb_strlen($LeftOvers) > 0) {
         $LeftOvers = $pdf->addTextWrap($Left_Margin + 5, $YPos - 36, 280, $FontSize, $LeftOvers);
         /*If there is some of the InvText leftover after 3 lines 200 wide then it is not printed :( */
     }
 }
 $FontSize = 10;
 $pdf->addText($Page_Width - $Right_Margin - 220, $YPos + 15, $FontSize, _('Sub Total'));
 $LeftOvers = $pdf->addTextWrap($Left_Margin + 642, $YPos + 5, 120, $FontSize, $DisplaySubTot, 'right');
 $pdf->addText($Page_Width - $Right_Margin - 220, $YPos + 2, $FontSize, _('Freight'));
 $LeftOvers = $pdf->addTextWrap($Left_Margin + 642, $YPos - 6, 120, $FontSize, $DisplayFreight, 'right');
 $pdf->addText($Page_Width - $Right_Margin - 220, $YPos - 10, $FontSize, _('Tax'));
 $LeftOvers = $pdf->addTextWrap($Left_Margin + 642, $YPos - $line_height - 5, 120, $FontSize, $DisplayTax, 'right');
 /*rule off for total */
 $pdf->line($Page_Width - $Right_Margin - 222, $YPos - 2 * $line_height, $Page_Width - $Right_Margin, $YPos - 2 * $line_height);
 /*vertical to separate totals from comments and ROMALPA */
 $pdf->line($Page_Width - $Right_Margin - 222, $YPos + $line_height, $Page_Width - $Right_Margin - 222, $Bottom_Margin);
 $YPos += 10;
 if ($InvOrCredit == 'Invoice') {
     $pdf->addText($Page_Width - $Right_Margin - 220, $YPos - $line_height * 2 - 10, $FontSize, _('TOTAL INVOICE'));
     $FontSize = 9;
     $YPos -= 4;
     $LeftOvers = $pdf->addTextWrap($Left_Margin + 280, $YPos, 220, $FontSize, $_SESSION['RomalpaClause']);
$pdf = 0;
if ($pdf == 1) {
    include_once $pathvars["libraries"] . "xtra.pdf.php";
    $pdf = new Cpdf(array(0, 0, 595.28, 841.89));
    $pdf->selectFont('./fonts/Helvetica.afm');
    $pdf->openHere("Fit");
    #$pdf->setPreferences( "HideToolbar", true);
    #$pdf->setPreferences( "HideMenubar", true);
    #$pdf->setPreferences( "HideWindowUI", true);
    #$pdf->setPreferences( "FitWindow", true);
    #$pdf->setPreferences( "CenterWindow",true);
    #$pdf->setPreferences( "NonFullScreenPageMode",True); // UseNone, UseOutlines, UseThumbs
    $unten = 50;
    $links = 20;
    $oben = 820;
    $pdf->addText($links, $oben, 11, 'links oben');
    $pdf->addText($links, $unten, 11, 'links unten');
    $pdf->addText(500, $oben, 11, 'rechts oben');
    $pdf->addText(500, $unten, 11, 'rechts unten');
    $row = $oben;
    for ($i = 1; $i <= 10; $i++) {
        $row = $row - 10;
        $pdf->addText($links, $row, 11, $i . ' drunter');
    }
    $pdf->addJpegFromFile($pathvars["fileroot"] . "/images/net/vdmvd/otto.jpg", 70.86, 420.94, 100);
    $pdf->rectangle($links, $unten, 540, 780);
    /*
    $pdf->newPage();
    $pdf->addText(0,830,'10pt','links oben');
    $pdf->addText(540,830,10,'rechts oben');
    $pdf->addText(0,5,10,'links unten');
     $DisplayTax = locale_number_format($myrow['ovgst'], $myrow['decimalplaces']);
     $DisplayTotal = locale_number_format($myrow['ovfreight'] + $myrow['ovgst'] + $myrow['ovamount'], $myrow['decimalplaces']);
 } else {
     $DisplaySubTot = locale_number_format(-$myrow['ovamount'], $myrow['decimalplaces']);
     $DisplayFreight = locale_number_format(-$myrow['ovfreight'], $myrow['decimalplaces']);
     $DisplayTax = locale_number_format(-$myrow['ovgst'], $myrow['decimalplaces']);
     $DisplayTotal = locale_number_format(-$myrow['ovfreight'] - $myrow['ovgst'] - $myrow['ovamount'], $myrow['decimalplaces']);
 }
 /*Print out the invoice text entered */
 $YPos = $Bottom_Margin + 3 * $line_height;
 /* Print out the payment terms */
 $pdf->addTextWrap($Left_Margin + 5, $YPos + 3, 280, $FontSize, _('Payment Terms') . ': ' . $myrow['terms']);
 $FontSize = 8;
 $LeftOvers = explode('\\r\\n', DB_escape_string($myrow['invtext']));
 for ($i = 0; $i < sizeOf($LeftOvers); $i++) {
     $pdf->addText($Left_Margin + 5, $YPos - 8 - $i * 8, $FontSize, $LeftOvers[$i]);
 }
 $FontSize = 10;
 $pdf->addText($Page_Width - $Right_Margin - 220, $YPos + 12, $FontSize, _('Sub Total'));
 $LeftOvers = $pdf->addTextWrap($Left_Margin + 450, $YPos + 5, 72, $FontSize, $DisplaySubTot, 'right');
 $pdf->addText($Page_Width - $Right_Margin - 220, $YPos + 12 - $line_height + 5, $FontSize, _('Freight'));
 $LeftOvers = $pdf->addTextWrap($Left_Margin + 450, $YPos - $line_height + 5, 72, $FontSize, $DisplayFreight, 'right');
 $pdf->addText($Page_Width - $Right_Margin - 220, $YPos + 12 - 2 * $line_height + 5, $FontSize, _('Tax'));
 $LeftOvers = $pdf->addTextWrap($Left_Margin + 450, $YPos - 2 * $line_height + 5, 72, $FontSize, $DisplayTax, 'right');
 /*rule off for total */
 $pdf->line($Page_Width - $Right_Margin - 222, $YPos - 2 * $line_height, $Page_Width - $Right_Margin, $YPos - 2 * $line_height);
 /*vertical to separate totals from comments and ROMALPA */
 $pdf->line($Page_Width - $Right_Margin - 222, $YPos + $line_height, $Page_Width - $Right_Margin - 222, $Bottom_Margin);
 $YPos += 10;
 if ($InvOrCredit == 'Invoice') {
     $pdf->addText($Page_Width - $Right_Margin - 220, $YPos + 6 - $line_height * 3, $FontSize, _('TOTAL INVOICE'));
Exemple #9
0
include_once 'pdfClass/class.pdf.php';
$util = new Util();
//echo "JJJJJJJJJJJJJJJJJJJJ";
//$util->securAdmin($_SESSION);
//echo "KKKKKKKKKKKKKK";
//exit;
//$pdf = new Cpdf(array(0,0,684,297));
$pdf = new Cpdf(array(0, 0, 684, 297));
$pdf->selectFont('pdfClass/fonts/Helvetica');
for ($i = 1; $i <= $_POST[total]; $i++) {
    $login = $util->createPassword();
    //$pass=$util->createPassword();
    $sql = "insert into tbcard values('cardId','{$login}',NOW(),'{$balance}','1','none','')";
    mysql_query($sql);
    //$util->insertAccount($login,$pass,$_POST[balance]);
    //echo "HHHH";
    if ($i != 1) {
        $pdf->newPage();
    }
    $pdf->addText(60, 235, 14, '<b>PREPAID CARD</b>');
    $pdf->addText(60, 200, 12, '<b>Balance</b>: ' . number_format($_POST[balance], 2));
    $pdf->addText(60, 160, 12, '<b>Code</b>: ' . $login);
    //$pdf->addText(40,190,12,'<b>Password</b>: '.$pass);
}
$pdfcode = $pdf->output();
@chmod("accounts", 777);
$file = 'file-' . date('Ymd-his');
$fp = fopen('accounts/' . $file . '.pdf', 'wb');
fwrite($fp, $pdfcode);
fclose($fp);
header('location: accounts/' . $file . '.pdf');
Exemple #10
0
//$pdf = new Cpdf(array(0,0,684,297));
$pdf = new Cpdf(array(0, 0, 684, 297));
$pdf->selectFont('pdfClass/fonts/Helvetica');
for ($i = 1; $i <= $_POST[total]; $i++) {
    $preCode = $util->createPassword();
    //$pass=$util->createPassword();
    $sql = "insert into prepaid values('','{$preCode}','{$balance}','1',NOW())";
    mysql_query($sql);
    //$util->insertAccount($login,$pass,$_POST[balance]);
    /*$login=$util->createPassword();
    	$pass=$util->createPassword();
            $sql="insert into tbcardtransaction values('id','$login','$pass',NOW(),'$balance')";
            mysql_query($sql); 
    	$util->insertAccount($login,$pass,$_POST[balance]);
    	*/
    //echo "HHHH";
    if ($i != 1) {
        $pdf->newPage();
    }
    $pdf->addText(40, 235, 14, '<b>PREPAID CARD</b><br><br>');
    $pdf->addText(40, 225, 12, '<b>Balance</b>: ' . number_format($_POST[balance], 2));
    $pdf->addText(40, 200, 12, '<b>Code </b>: ' . $preCode);
    //$pdf->addText(40,190,12,'<b>Password</b>: '.$pass);
}
$pdfcode = $pdf->output();
@chmod("accounts", 777);
$file = 'file-' . date('Ymd-his');
$fp = fopen('accounts/' . $file . '.pdf', 'wb');
fwrite($fp, $pdfcode);
fclose($fp);
header('location: accounts/' . $file . '.pdf');