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;
}
    $x1 = $xorigin + ($col - 1) * (round(PREF_ETIQ_HSIZE * 2.835) + round(PREF_ETIQ_HSPACE * 2.835));
    $x2 = $x1 + round(PREF_ETIQ_HSIZE * 2.835);
    $y1 = $yorigin - ($row - 1) * (round(PREF_ETIQ_VSIZE * 2.835) + round(PREF_ETIQ_VSPACE * 2.835));
    $y2 = $y1 - round(PREF_ETIQ_VSIZE * 2.835);
    $nom_adh_ext .= " " . strtoupper($resultat->fields[1]) . " " . ucfirst(strtolower($resultat->fields[2]));
    $concatname = $concatname . " - " . $nom_adh_ext;
    $param["font"] = "Helvetica-Bold";
    $pdf->draw_paragraph($y1 - 10, $x1, $y1 - 10 - round(PREF_ETIQ_VSIZE * 2.835) / 5 + 5, $x2, $nom_adh_ext, $firstpage, $param);
    $param["font"] = "Helvetica";
    $pdf->draw_paragraph($y1 - 10 - round(PREF_ETIQ_VSIZE * 2.835) / 5, $x1, $y1 - 10 - round(PREF_ETIQ_VSIZE * 2.835) / 5 - round(PREF_ETIQ_VSIZE * 2.835) * 4 / 5, $x2, $resultat->fields[3] . "\n" . $resultat->fields[8] . "\n" . $resultat->fields[5] . "  -  " . $resultat->fields[6] . "\n" . $resultat->fields[7], $firstpage, $param);
    $pdf->draw_rectangle($y1, $x1, $y2, $x2, $firstpage, $param);
    $resultat->MoveNext();
    $col++;
    if ($col > PREF_ETIQ_COLS) {
        $col = 1;
        $row++;
    }
    if ($row > PREF_ETIQ_ROWS) {
        $col = 1;
        $row = 1;
        $firstpage = $pdf->new_page("a4");
    }
    $nb_etiq++;
}
$resultat->Close();
//dblog("Generation of "." ".$nb_etiq." "."label(s)",$concatname);
header("Content-Disposition: attachment; filename=labels.pdf");
header("Content-Type: application/pdf");
$temp = $pdf->generate(0);
header('Content-Length: ' . strlen($temp));
echo $temp;
    $malli = "PDF";
    $pdf = new pdffile();
    $toim = "SARJA";
    $pdf->set_default('margin-top', 0);
    $pdf->set_default('margin-bottom', 0);
    $pdf->set_default('margin-left', 0);
    $pdf->set_default('margin-right', 0);
    $query = "SELECT sarjanumero, tuoteno\n            FROM sarjanumeroseuranta\n            WHERE yhtio = '{$kukarow["yhtio"]}'\n            AND tunnus  IN ({$valitut_sarjat})";
    $sarja_result = pupe_query($query);
    while ($sarjarow = mysql_fetch_assoc($sarja_result)) {
        $tuoteno = $sarjarow["tuoteno"];
        require "inc/tulosta_tuotetarrat_pdf.inc";
    }
    $filename = "/tmp/sarjanumerotarra-" . md5(uniqid(mt_rand(), true)) . ".pdf";
    $file = fopen($filename, "w");
    fwrite($file, $pdf->generate());
    fclose($file);
    echo file_get_contents($filename);
    unlink($filename);
    exit;
}
// ekotetaan javascriptiä jotta saadaan pdf:ät uuteen ikkunaan
js_openFormInNewWindow();
echo "<SCRIPT type='text/javascript'>\n    <!--\n      function sarjanumeronlisatiedot_popup(tunnus) {\n        window.open('{$PHP_SELF}?tunnus='+tunnus+'&toiminto=sarjanumeronlisatiedot_popup', '_blank' ,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,left=0,top=0,width=800,height=600');\n      }\n    //-->\n    </SCRIPT>";
$sarjalopetus = "";
if ($lopetus != "") {
    $sarjalopetus .= "{$lopetus}/SPLIT/";
}
$sarjalopetus .= "{$palvelin2}tilauskasittely/sarjanumeroseuranta.php?ostorivitunnus={$ostorivitunnus}//from={$from}//aputoim={$aputoim}//muut_siirrettavat={$muut_siirrettavat}//toiminto=//sarjatunnus={$sarjatunnus}//otunnus={$otunnus}//sarjanumero_haku={$sarjanumero_haku}//tuoteno_haku={$tuoteno_haku}//nimitys_haku={$nimitys_haku}//varasto_haku={$varasto_haku}//ostotilaus_haku={$ostotilaus_haku}//myyntitilaus_haku={$myyntitilaus_haku}";
if ($toiminto == "sarjanumeronlisatiedot_popup") {
    @(include 'sarjanumeron_lisatiedot_popup.inc');
             } elseif ($malli == 'PDF24' or $malli == 'PDF40' or $malli == 'PDF') {
                 require "inc/tulosta_tuotetarrat_pdf.inc";
             }
         }
     } else {
         require "inc/tulosta_tuotetarrat_zebra.inc";
     }
 }
 if ($malli == 'PDF24' or $malli == 'PDF40' or $malli == 'PDF') {
     //keksitään uudelle failille joku varmasti uniikki nimi:
     list($usec, $sec) = explode(' ', microtime());
     mt_srand((double) $sec + (double) $usec * 100000);
     $pdffilenimi = "/tmp/tuotetarrat_ean_pdf-" . 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);
     //Työnnetään tuo pdf vaan putkeen!
     echo file_get_contents($pdffilenimi);
     //poistetaan tmp file samantien kuleksimasta...
     unlink($pdffilenimi);
 }
 if ($malli == "Hintalappu PDF") {
     $tuotteet = array($trow);
     $params = array("kpl" => $tulostakappale);
     require "tilauskasittely/tulosta_hintalaput.inc";
     list($tiedostonimi, $kaunisnimi) = tulosta_hintalaput($tuotteet, $params);
     echo file_get_contents("/tmp/{$tiedostonimi}");
 }
$pdf->draw_circle(150, 200, 50, $secondpage, array('mode' => 'stroke', 'strokecolor' => $pdf->get_color('blue'), 'width' => 5));
$pdf->draw_circle(300, 200, 35, $secondpage, array('mode' => 'fill'));
$pdf->draw_circle(450, 200, 50, $secondpage, array('mode' => 'fill+stroke', 'fillcolor' => $pdf->get_color('red')));
/* Uses the absolute page size notation to create
 * a notecard sized page
 */
$thirdpage = $pdf->new_page("5x3in");
$pdf->draw_rectangle(198, 18, 18, 342, $thirdpage);
$pdf->draw_text(150, 100, "Page #3", $thirdpage);
/* Uses the absolute page size notation to create
 * a 50x30 centimeter page
 */
$fourthpage = $pdf->new_page("50x30cm");
$pdf->draw_text(150, 100, "Page #4", $fourthpage);
/* These headers do a good job of convincing most
 * browsers that they should launch their pdf viewer
 * program
 */
header("Content-Disposition: filename=example.pdf");
header("Content-Type: application/pdf");
$temp = $pdf->generate();
header('Content-Length: ' . strlen($temp));
/* You can now do whatever you want with the PDF file,
 * which is returned from a call to ->generate()
 * This example simply sends it to the browser, but
 * there's nothing to stop you from saving it to disk,
 * emailing it somewhere or doing whatever else you want
 * with it (such as email it somewhere or store it in
 * a database field)
 */
echo $temp;
Beispiel #6
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;
}
// 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);
$pdf->draw_line($x, $y, $firstpage, $p);
$x[0] = 50;
$x[1] = 500;
$x[2] = 300;
$y[0] = 450;
$y[1] = 570;
$y[2] = 350;
unset($p);
$p['mode'] = 'fill+stroke';
$p['fillcolor'] = $pdf->get_color('white');
$pdf->draw_line($x, $y, $firstpage, $p);
$fh = fopen("../doc/ptlogo.jpg", "r");
$data = fread($fh, filesize('../doc/ptlogo.jpg'));
fclose($fh);
$image = $pdf->jfif_embed($data);
$size = $pdf->get_image_size($image);
$pdf->image_place($image, 792 - $size['height'], 0, $firstpage);
$fh = fopen("../doc/powerby.png", "r");
$data = fread($fh, filesize('../doc/powerby.png'));
fclose($fh);
$image = $pdf->png_embed($data);
if (!$image) {
    echo $pdf->pop_error($n, $s);
    echo "<p>{$s}</p>";
    exit;
}
$pdf->image_place($image, 735, 380, $firstpage);
header("Content-Disposition: attachment; filename=showoff.pdf");
header("Content-Type: application/pdf");
echo $pdf->generate();
 * If you're wondering, this is a silly way to do this.
 * It would be easier and smarter to use filled rectangles,
 * but this is not intended as a "best practice" example,
 * but only to illustrate capibilities.
 */
$d = "ÿ";
$im[0] = $pdf->image_raw_embed($d, '/DeviceRGB', 8, 1, 1);
$d = "ÿ";
$im[1] = $pdf->image_raw_embed($d, '/DeviceRGB', 8, 1, 1);
$d = "ÿ";
$im[2] = $pdf->image_raw_embed($d, '/DeviceRGB', 8, 1, 1);
// Now we'll attach a red rectangle to the template
$pdf->template->image($t1, 280, 5, 20, 20, $im[0]);
/* Now we'll place an "image field" (i.e. a "variable" image)
 * next to the previous image.  When the band is placed, an
 * image will be dynamically selected to insert into the
 * space we create here
 */
$pdf->template->ifield($t1, 310, 5, 20, 20, 'image');
/* Now got through a loop and manually place 7 of these
 * templates on this page
 */
$running = '';
for ($i = 0; $i < 8; $i++) {
    $running .= pow(4, $i) . ' ';
    $pdf->template->place($t1, $page, 0, $i * 80, array('var' => "number {$i}", 'image' => $im[$i % 3], 'para' => $running));
}
header("Content-Disposition: filename=template.pdf");
header("Content-Type: application/pdf");
echo $pdf->generate(0);