fpdf
Piero Cavalieri
piero.cavalieri at HEIDI.IT
Mon Aug 29 09:18:04 PDT 2005
Carlos Eduardo Sibaja Salazar ha scritto:
>Hi list.
>I need to know if someone has an example code using fpdf with
>php_mapscript to create a pdf document when i want to print a map.
>
>thanks
>
Don't remember if worked or not...
<?php
include("include/header.php");
include("include/dcmconfig.php");
include("include/dcmmaputil.php");
$map_path="./";
$map = ms_newMapObj($map_path.$_SESSION["strMapFile"]);
if(array_key_exists("PATH_TRANSLATED", $_SERVER)) {
$map->set("shapepath", str_replace("pdfPrint.php", "data",
str_replace("\\", "/", $_SERVER["PATH_TRANSLATED"])));}
$map->set("width", 650);
$map->set("height", 450);
localizeMapLabels($map);
adjustScalebar($map);
$map->setextent($_REQUEST["minx"],$_REQUEST["miny"],
$_REQUEST["maxx"],$_REQUEST["maxy"]);
$glrLayer = $map->getLayerByName("AreaOfInterest");
$glrLayer->setFilter ("id = ".$_SESSION["WorkorderID"]);
$glrLayer->set("status", MS_ON);
$glrLayer = $map->getLayerByName("Maintenance");
$glrLayer->set("status", MS_OFF);
showLayers($map, $_SESSION);
$image=$map->draw();
$image_url=$image->saveWebImage();
$legend_img = $map->drawLegend();
$legend_url = $legend_img->saveWebImage();
$key_img = $map->drawreferencemap();
$keymap_url = $key_img->saveWebImage();
/* PDF Stuff */
define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdf.php');
$pdf=new FPDF("L", "pt", "A4" );
$pdf->AddPage();
//$pdf->SetFont('Arial','B',16);
$pdf->Image("C:/tmp$image_url",5, 20, 600, 400 );
$pdf->Image("C:/tmp$keymap_url",655,20 );
$pdf->Image("C:/tmp$legend_url",655,150 );
$pdf->Output();
?>
This will not work for you, however key is to use
$image=$map->draw();
$image_url=$image->saveWebImage();
(and similar for reference, scalebar, legend)
Then when you have the image url, use the pdf library functions
to include images in pdf. If png format give you problems with fpdf, it's
due to alpha channel => try jpg format.
Ciao
Piero
More information about the MapServer-users
mailing list