Exemplo n.º 1
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);
 }
}
$requete = "SELECT id_adh, nom_adh, prenom_adh, adresse_adh,\n\t\t\t\t\t\t\t\t\ttitre_adh, cp_adh, ville_adh, pays_adh, adresse2_adh\n\t\t\t\t\t\t\t\t\tFROM " . PREFIX_DB . "adherents\n\t\t\t       \t\t\t\tWHERE ";
$where_clause = "";
while (list($key, $value) = each($mailing_adh)) {
    if ($where_clause != "") {
        $where_clause .= " OR ";
    }
    $where_clause .= "id_adh=" . $DB->qstr($value, get_magic_quotes_gpc());
}
$requete .= $where_clause . " ORDER by nom_adh, prenom_adh;";
// echo $requete;
$resultat =& $DB->Execute($requete);
$pdf = new pdffile();
$pdf->set_default('margin', 0);
$param["height"] = PREF_ETIQ_CORPS;
$firstpage = $pdf->new_page("a4");
$param["fillcolor"] = $pdf->get_color('#000000');
$param["align"] = "center";
$param["width"] = 1;
$param["color"] = $pdf->get_color('#DDDDDD');
if ($resultat->EOF) {
    die;
}
$yorigin = 842 - round(PREF_ETIQ_MARGES_V * 2.835);
$xorigin = round(PREF_ETIQ_MARGES_H * 2.835);
$col = 1;
$row = 1;
$nb_etiq = 0;
$concatname = "";
while (!$resultat->EOF) {
    $nom_adh_ext = "";
Exemplo n.º 3
0
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   $Id: charts.php 221 2005-06-25 01:22:54Z deelight $
*/
/* This example illustrates the charting subclass
 * These features are still experimental
 */
require '../phppdflib.class.php';
// Starts a new pdffile object
$pdf = new pdffile();
$pdf->set_default('margin', 0);
$firstpage = $pdf->new_page("letter");
$pdf->enable('chart');
$pdf->chart->setcolor('background', 1, 0.5, 0.33);
for ($series = 1; $series < 4; $series++) {
    unset($points);
    switch ($series) {
        case 1:
            $color = 'black';
            break;
        case 2:
            $color = 'blue';
            break;
        case 3:
            $color = 'green';
            break;
    }
Exemplo n.º 4
0
// Starts a new pdffile object
$pdf = new pdffile();
/* Use the defaults system to turn off page
 * margins
 */
$pdf->set_default('margin', 0);
/* You can create as many pages as you want.
 * The parameter is the size of the page:
 * The following keywords are recognized:
 * "letter", "legal", "executive", "tabloid",
 * "a3", "a4", "a5"
 * or the actual size in the format:
 * "[width]x[height][in|cm]"
 * See examples at the end of this file.
 */
$firstpage = $pdf->new_page("letter");
/* Using the ->draw_text() method:
 * We're going to set up the text parameters,
 * first the height
 */
$param["height"] = 12;
/* Now we set the color to red
 */
$param["fillcolor"] = $pdf->get_color('#ff3333');
/* Set the font.  Possible values are:
   Courier
   Courier-Bold
   Courier-Oblique
   Courier-BoldOblique
   Helvetica
   Helvetica-Bold
Exemplo n.º 5
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;
}
$pdf->draw_rectangle(400, 150, 150, 300, $page);
$pdf->set_default('fillcolor', $pdf->get_color('green'));
$space = new field(400, 600, 600, 800);
$pdf->packer->allocate($space);
$pdf->draw_rectangle(800, 400, 600, 600, $page);
$pdf->set_default('fillcolor', $pdf->get_color('black'));
$pdf->set_default('height', 10);
$text = implode('', file('text.txt'));
$pdf->packer->fill_text($text);
$pdf->set_default('smode', 'stroke');
$pdf->set_default('strokecolor', $pdf->get_color('#cccccc'));
foreach ($pdf->packer->fields as $f) {
    $pdf->draw_rectangle($f->t, $f->l, $f->b, $f->r, $page);
    $x[0] = $f->l;
    $x[1] = $f->r;
    $y[0] = $f->b;
    $y[1] = $f->t;
    $pdf->draw_line($x, $y, $page);
}
$page = $pdf->new_page();
$pdf->set_default('height', 9);
$pdf->draw_paragraph(720, 72, 72, 540, $pdf->_print_r($pdf->packer->fields), $page);
/* 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(0);
header('Content-Length: ' . strlen($temp));
echo $temp;
Exemplo n.º 7
0
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   $Id: template.php 221 2005-06-25 01:22:54Z deelight $
*/
/* This example illustrates the template subclass
 * These features are still experimental
 */
require '../phppdflib.class.php';
// Starts a new pdffile object
$pdf = new pdffile();
$page = $pdf->new_page("letter");
$pdf->enable('template');
$t1 = $pdf->template->create();
/* Set the overall size of this template.
 * This will be important once auto-placement
 * is working
 */
$pdf->template->size($t1, 500, 80);
/* Put a rectangle at the lower left of the template
 */
$pdf->template->rectangle($t1, 0, 0, 20, 20);
// These next two will look like a lolipop
// A circle on the template
$pdf->template->circle($t1, 200, 5, 12, array('mode' => 'fill'));
// Add a line
$pdf->template->line($t1, array(0 => 200, 1 => 250), array(0 => 5, 1 => 25));