function hae_saldovahvistus_pdf($saldovahvistus, $boss = false)
{
    global $kukarow, $yhtiorow, $pdf, $kala, $sivu, $norm, $pieni, $kieli, $bold, $lask, $rectparam, $sivu_numero_obj_ids;
    $sivu_numero_obj_ids = array();
    //PDF parametrit
    $pdf = new pdffile();
    $pdf->set_default('margin-top', 0);
    $pdf->set_default('margin-bottom', 0);
    $pdf->set_default('margin-left', 0);
    $pdf->set_default('margin-right', 0);
    $rectparam = array();
    $rectparam["width"] = 0.3;
    $lask = 1;
    $sivu = 1;
    $norm["height"] = 10;
    $norm["font"] = "Times-Roman";
    $pieni["height"] = 8;
    $pieni["font"] = "Times-Roman";
    $bold["height"] = 10;
    $bold["font"] = "Times-Bold";
    //Otetaan tässä asiakkaan kieli talteen
    $kieli = $saldovahvistus['asiakas']['kieli'];
    $firstpage = alku($saldovahvistus);
    $firstpage = rivit($firstpage, $saldovahvistus['laskut'], $saldovahvistus, $boss);
    $kala -= 20;
    $pdf->draw_text(250, $kala, t('Avoin saldo yhteensä', $kieli), $firstpage, $bold);
    $pdf->draw_text(452.5, $kala, $saldovahvistus['avoin_saldo_summa'], $firstpage, $bold);
    $pdf->draw_text(500, $kala, $saldovahvistus['valkoodi'], $firstpage, $bold);
    loppu($firstpage, $saldovahvistus);
    if (!empty($sivu_numero_obj_ids)) {
        foreach ($sivu_numero_obj_ids as $sivu_numero_obj_id) {
            $pdf->objects[$sivu_numero_obj_id]['text'] .= $pdf->currentPage['number'] + 1;
        }
    }
    //keksitään uudelle failille joku varmasti uniikki nimi:
    list($usec, $sec) = explode(' ', microtime());
    mt_srand((double) $sec + (double) $usec * 100000);
    $pdffilenimi = "/tmp/saldovahvistus-" . md5(uniqid(mt_rand(), true)) . ".pdf";
    //kirjoitetaan pdf faili levylle..
    $fh = fopen($pdffilenimi, "w");
    if (fwrite($fh, $pdf->generate()) === FALSE) {
        die("PDF kirjoitus epäonnistui {$pdffilenimi}");
    }
    fclose($fh);
    return $pdffilenimi;
}
Esempio n. 2
0
 function alku()
 {
     global $yhtiorow, $firstpage, $pdf, $rectparam, $norm, $norm_bold, $pieni, $ytunnus, $asiakasid, $kukarow, $kala, $tid, $otsikkotid;
     static $sivu;
     $sivu++;
     if (!isset($pdf)) {
         //PDF parametrit
         $pdf = new pdffile();
         $pdf->enable('template');
         $pdf->set_default('margin-top', 0);
         $pdf->set_default('margin-bottom', 0);
         $pdf->set_default('margin-left', 0);
         $pdf->set_default('margin-right', 0);
         $rectparam["width"] = 0.3;
         $norm["height"] = 12;
         $norm["font"] = "Courier";
         $norm_bold["height"] = 12;
         $norm_bold["font"] = "Courier-Bold";
         $pieni["height"] = 8;
         $pieni["font"] = "Courier";
         $query = "SELECT *\n                 FROM asiakas\n                 WHERE yhtio = '{$kukarow['yhtio']}'\n                 and tunnus  = '{$asiakasid}'";
         $assresult = pupe_query($query);
         $assrow = mysql_fetch_assoc($assresult);
         // Tehdään firstpage
         $firstpage = $pdf->new_page("a4");
         //  Tehdään headertemplate
         $tid = $pdf->template->create();
         $pdf->template->rectangle($tid, 20, 20, 0, 580, $rectparam);
         $pdf->template->text($tid, 30, 5, $yhtiorow["nimi"], $pieni);
         $pdf->template->text($tid, 170, 5, "{$assrow['nimi']} {$assrow['nimitark']} ({$ytunnus}) " . t("alennustaulukko"));
         $pdf->template->place($tid, $firstpage, 0, 800);
         //  Tehdään otsikkoheader
         $otsikkotid = $pdf->template->create();
         $pdf->template->text($otsikkotid, 30, 20, t("Osasto"), $norm_bold);
         $pdf->template->text($otsikkotid, 30, 0, t("Tuoteryhmä") . "/" . t("Tuotenumero"), $norm_bold);
         $pdf->template->text($otsikkotid, 330, 0, t("Aleryhmä"), $norm_bold);
         $pdf->template->text($otsikkotid, 450, 0, t("Alennus"), $norm_bold);
         if ($yhtiorow['myynnin_alekentat'] > 1) {
             $pdf->template->text($otsikkotid, 520, 0, t("Alelaji"), $norm_bold);
         }
         $pdf->template->place($otsikkotid, $firstpage, 0, 665, $norm_bold);
         $kala = 650;
         //  Asiakastiedot
         //$pdf->draw_rectangle(737, 20,  674, 300, $firstpage, $rectparam);
         $pdf->draw_text(50, 759, t("Osoite", $kieli), $firstpage, $pieni);
         $pdf->draw_text(50, 747, $assrow["nimi"], $firstpage, $norm);
         $pdf->draw_text(50, 737, $assrow["nimitark"], $firstpage, $norm);
         $pdf->draw_text(50, 727, $assrow["osoite"], $firstpage, $norm);
         $pdf->draw_text(50, 717, $assrow["postino"] . " " . $assrow["postitp"], $firstpage, $norm);
         $pdf->draw_text(50, 707, $assrow["maa"], $firstpage, $norm);
     } else {
         //  Liitetään vaan valmiit templatet uudelle sivulle
         $firstpage = $pdf->new_page("a4");
         $pdf->template->place($tid, $firstpage, 0, 800);
         $pdf->template->place($otsikkotid, $firstpage, 0, 760);
     }
     $pdf->draw_text(520, 805, t("Sivu") . ": {$sivu}", $firstpage, $norm);
 }
Esempio n. 3
0
   Helvetica-Oblique
   Helvetica-BoldOblique
   Times-Roman
   Times-Bold
   Times-Italic
   Times-BoldItalic
   Symbol
   ZapfDingbats
 * These names must be exact, and are case-
 * sensitive.  Default is Helvetica
 */
$param["font"] = "Times-Italic";
// Rotate the text 60 degrees
$param["rotation"] = 60;
/* Now we'll place our text string on the page */
$pdf->draw_text(10, 200, "This is red, italic text", $firstpage, $param);
// Alter some parameters and place more text
$param["font"] = "Courier-Bold";
$param["mode"] = "fill+stroke";
$param["height"] = 32;
$param["rotation"] = 0;
$pdf->draw_text(10, 100, "This is red, Courier-Bold text", $firstpage, $param);
/* By omitting the final parameter, we get the same
 * text placed with default text settings
 */
$pdf->draw_text(10, 150, "This is not red text", $firstpage);
/* simply draws a rectange on the page.
 * Specify the top,left,bottom,right locations
 * (in that order) and the ID of the page to place
 * it on
 */
Esempio n. 4
0
function siirtokehoitus_pdf($pdf_data)
{
    //PDF:n luonti ja defaultit
    require_once "pdflib/phppdflib.class.php";
    //PDF parametrit
    $pdf = new pdffile();
    $pdf->set_default('margin-top', 0);
    $pdf->set_default('margin-bottom', 0);
    $pdf->set_default('margin-left', 0);
    $pdf->set_default('margin-right', 0);
    //fontit
    $pieni["height"] = 11;
    $pieni["font"] = "Times-Roman";
    $bold["height"] = 11;
    $bold["font"] = "Times-Bold";
    // sitten aletaan piirtämään itse PDF sisältöä
    $sivu = $pdf->new_page("a4");
    $x = 40;
    $y = 800;
    $xx = array(20, 580);
    $pdf->draw_text($x, $y, 'Tyyppi', $sivu, $bold);
    $pdf->draw_text($x + 100, $y, 'Tuotenumero', $sivu, $bold);
    $pdf->draw_text($x + 200, $y, 'Tuotepaikka', $sivu, $bold);
    $pdf->draw_text($x + 300, $y, 'Hyllyssä', $sivu, $bold);
    $pdf->draw_text($x + 400, $y, 'Hälytysraja', $sivu, $bold);
    $y -= 20;
    $yy[0] = $yy[1] = $y;
    $pdf->draw_line($xx, $yy, $sivu);
    $y -= 20;
    foreach ($pdf_data as $row) {
        $korkeus = 20 + count($row['varapaikat']) * 20;
        if ($korkeus > $y) {
            $sivu = $pdf->new_page("a4");
            $y = 800;
            $pdf->draw_text($x, $y, 'Tyyppi', $sivu, $bold);
            $pdf->draw_text($x + 100, $y, 'Tuotenumero', $sivu, $bold);
            $pdf->draw_text($x + 210, $y, 'Tuotepaikka', $sivu, $bold);
            $pdf->draw_text($x + 320, $y, 'Hyllyssä', $sivu, $bold);
            $pdf->draw_text($x + 420, $y, 'Hälytysraja', $sivu, $bold);
            $y -= 15;
            $yy[0] = $yy[1] = $y;
            $pdf->draw_line($xx, $yy, $sivu);
            $y -= 20;
        }
        $pdf->draw_text($x, $y, 'Oletuspaikka', $sivu, $pieni);
        $pdf->draw_text($x + 100, $y, $row['tuoteno'], $sivu, $pieni);
        $pdf->draw_text($x + 210, $y, $row['tuotepaikka'], $sivu, $pieni);
        $pdf->draw_text($x + 320, $y, $row['myytavissa'], $sivu, $pieni);
        $pdf->draw_text($x + 420, $y, $row['haly'], $sivu, $pieni);
        foreach ($row['varapaikat'] as $vararow) {
            $y -= 20;
            $pdf->draw_text($x, $y, 'Varapaikka', $sivu, $pieni);
            $pdf->draw_text($x + 210, $y, $vararow['tuotepaikka'], $sivu, $pieni);
            $pdf->draw_text($x + 320, $y, $vararow['myytavissa'], $sivu, $pieni);
        }
        $y -= 15;
        $yy[0] = $yy[1] = $y;
        $pdf->draw_line($xx, $yy, $sivu);
        $y -= 20;
    }
    //keksitään uudelle failille joku varmasti uniikki nimi:
    $pdffilenimi = "/tmp/kuitti-" . md5(uniqid(rand(), true)) . ".pdf";
    //kirjoitetaan pdf faili levylle..
    $fh = fopen($pdffilenimi, "w");
    if (fwrite($fh, $pdf->generate()) === FALSE) {
        die("PDF kirjoitus epäonnistui {$pdffilenimi}");
    }
    fclose($fh);
    return $pdffilenimi;
}
require "../phppdflib.class.php";
// Starts a new pdffile object
$pdf = new pdffile();
$pdf->set_default('margin', 0);
$pdf->set_default('font', 'Courier');
$pdf->set_default('height', 10);
$fname = "../phppdflib.class.php";
$fh = fopen($fname, "r");
$data = fread($fh, filesize($fname));
fclose($fh);
$start = gettimeofday();
$p = explode("\n", $data);
$top = 720;
$page = $firstpage = $pdf->new_page("letter");
foreach ($p as $one) {
    while (is_string($one)) {
        $one = $pdf->draw_one_paragraph($top, 72, 72, 540, $one, $page);
        if (is_string($one)) {
            $page = $pdf->new_page("letter");
            $top = 720;
        } else {
            $top = $one;
        }
    }
}
$end = gettimeofday();
$elapsed = $end['sec'] - $start['sec'] + ($end['usec'] - $start['usec']) / 1000000;
$pdf->draw_text(72, 730, "Time taken : {$elapsed}", $firstpage);
header("Content-Disposition: attachment; filename=example-wrap.pdf");
header("Content-Type: application/pdf");
echo $pdf->generate(9);
Esempio n. 6
0
$p['scale']["y"] = 150;
$p['rotation'] = 270;
$pdf->image_place($image, 690, 400, $firstpage, $p);
$p['fillcolor'] = $pdf->get_color('white');
$p['mode'] = 'fill';
$pdf->draw_rectangle(792, 0, 792 - 75, 612, $firstpage, $p);
$param["height"] = 32;
$param["font"] = "Times-Bold";
$param["mode"] = "fill+stroke";
$param['fillcolor']["red"] = 0;
$param['fillcolor']["blue"] = 0;
$param['fillcolor']["green"] = 0.5;
$param['strokecolor']["red"] = 0;
$param['strokecolor']["blue"] = 0;
$param['strokecolor']["green"] = 0;
$pdf->draw_text(70, 680, "Dynamically generated PDF files", $firstpage, $param);
$text = <<<EOT
Dynamically generated PDF files can enhance your website by making it more interesting and useful to your target audience.  Any time you want to deliver a print-ready document across the Internet, the PDF format is the correct delivery medium.  Whether it be downloadable or emailed, a document in PDF format is virtually guaranteed to display and print properly on any computer.
HTML can't promise this, and neither can proprietary formats, such as Word or Wordperfect documents.
EOT;
$pdf->draw_paragraph(660, 50, 300, 380, $text, $firstpage);
$pdf->draw_rectangle(650, 450, 600, 500, $firstpage, array('mode' => 'stroke'));
$x[0] = 53;
$x[1] = 503;
$x[2] = 303;
$y[0] = 447;
$y[1] = 567;
$y[2] = 347;
unset($p);
$p['mode'] = 'fill';
$p['fillcolor']['red'] = $p['fillcolor']['green'] = $p['fillcolor']['blue'] = 0.4;
Esempio n. 7
0
     alku();
 }
 $pi = 0;
 foreach ($sarakkeet_px as $arvo) {
     if ($pi == 0) {
         $sisennys = 10 + (strlen($arvo) - 1) * 3;
         if ($sarakkeet_px[1] != "") {
             $nimi = $sarakkeet_px[1] . " - " . $sarakkeet_px[2];
         } else {
             $nimi = $sarakkeet_px[2];
         }
         if (isset($teexls) and $teexls == "OK") {
             $worksheet->writeString($excelrivi, $pi, $nimi, $format_bold);
         }
         if (isset($teepdf) and $teepdf == "OK") {
             $pdf->draw_text($sisennys, $bottom, $nimi, $firstpage, $b);
         }
     } elseif ($pi > 2) {
         if (isset($teexls) and $teexls == "OK") {
             $worksheet->writeNumber($excelrivi, $pi - 2, (double) str_replace(" ", "", str_replace(",", ".", $arvo)));
         }
         if (isset($teepdf) and $teepdf == "OK") {
             $oikpos = $pdf->strlen($arvo, $p);
             $pdf->draw_text($leveysarray[$pi - 3] - $oikpos, $bottom, $arvo, $firstpage, $p);
         }
     }
     $pi++;
 }
 if (isset($teexls) and $teexls == "OK") {
     $excelrivi++;
 }