<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>That is very useful ram282, I succeeded to do what you did in java using iText, but the quality of the resulting image is not very good.</DIV>
<DIV> </DIV>
<DIV>I saw in your code that you generated a view of the map as a PNG file, mapguide allows you to generate a view of the map as a DWF file, that act's as a SVG file, the quality is just perfect.</DIV>
<DIV> </DIV>
<DIV>I have found that Autodesk is giving for free the DWF Toolkit, and we ca use that two read the contents of a DWF file and write it in a PDF file, and the resulting PDF file will contain the map as a SVG rather than  a PNG picture.</DIV>
<DIV> </DIV>
<DIV>I am working on an application that will do that, but I do not know if our clients will allow me to post the code after I finish it. :(<BR></DIV>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt">
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 13px"><FONT size=2 face=Tahoma>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> ram282 <ram282@gmail.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> mapguide-users@lists.osgeo.org<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Fri, July 9, 2010 7:18:25 AM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> [mapguide-users] Re: Generate a pdf view of the current map<BR></FONT><BR><BR>I had successfully generated pdf in this way.... <BR><BR>In this, I am temporarily saving the image files and after generating the<BR>pdf, I am deleting them. Yo should require the php file called fpdf.php,<BR>through which u are going to generate the pdf.  <BR><BR>And I also changed some configuration settings in the php.ini (LOCATED AT<BR>C:\Program Files\OSGeo\MapGuide\Web\Php\php.ini)<BR><BR>remove the semicolon at the start of the lines<BR>;extension=php_curl.dll<BR>;extension=php_gd2.dll    in the php.ini file....<BR><BR>Here is the
 code..<BR><BR><?php<BR><BR>$fusionMGpath = '../../layers/MapGuide/php/';<BR>include $fusionMGpath . 'Common.php';<BR>require($fusionMGpath . 'fpdf.php'); <BR><BR><BR>  $locale = "en";<BR>    $mapName = "";<BR>    $sessionId = "";<BR>    $isTitle = "";<BR>    $isLegend = "";<BR>    $isArrow = "";<BR>    $title = "";<BR>    $scale = "";<BR>    $centerX = "";<BR>    $centerY = "";<BR>    $dpi = "";<BR>    $Server= "";<BR>    <BR>    $clAgent = "Fusion%20Viewer";<BR>    $tempMapImgPath="";<BR>    GetRequestParameters();<BR>    $agent = GetRootVirtualFolder() . "/mapagent/mapagent.fcgi";<BR>    <BR>    $imgRequest = $Server . $agent .<BR>"?OPERATION=GETMAPIMAGE&VERSION=1.0.0&FORMAT=PNG&LOCALE=en&MAPNAME=" .<BR>$mapName . "&SESSION=" . $sessionId
 .<BR>"&SETDISPLAYWIDTH=480&SETDISPLAYHEIGHT=580&SETDISPLAYDPI=" . $dpi .<BR>"&SETVIEWSCALE=" . $scale . "&SETVIEWCENTERX=" . $centerX .<BR>"&SETVIEWCENTERY=" . $centerY . "&SEQ=0.2873515576651681&CLIENTAGENT=" .<BR>$clAgent;<BR><BR>    $LegendImgRequest = $Server . $agent .<BR>"?OPERATION=GETMAPLEGENDIMAGE&VERSION=1.0.0&MAPNAME=" . $mapName .<BR>"&SESSION=" . $sessionId . "&CLIENTAGENT=" . $clAgent .<BR>"&WIDTH=180&HEIGHT=580&FORMAT=PNG";<BR>    <BR><BR>// declaring the abcissa and ordinates of the images for the pdf.<BR>    $LegendA=10;<BR>    $LegendO=20;<BR>    $MapA=45;<BR>    $MapO=20;<BR>    $NorthA=145;<BR>    $NorthO=120;<BR><BR>class PDF extends FPDF<BR>{<BR>//Page header<BR>function Header()<BR>{<BR>  global  $isTitle;<BR>  global $title;<BR>  if($isTitle=='1')<BR>  {<BR> 
   $this->SetFont('Arial','B',15);<BR>    $this->Cell(80);<BR>    $this->Cell(30,10,$title,0,1,'C');<BR>    $this->Ln(20);<BR>  }<BR>}<BR>//Page footer<BR>function Footer()<BR>{<BR>    //Position at 1.5 cm from bottom<BR>    $this->SetY(-15);<BR>    //Arial italic 8<BR>    $this->SetFont('Arial','I',8);<BR>    //Page number<BR>    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');<BR><BR>}<BR>}<BR><BR><BR>//Instanciation of inherited class<BR>$pdf=new PDF();<BR>$pdf->AliasNbPages();<BR>$pdf->AddPage();<BR><BR>if($isTitle=='0')<BR>{ <BR>    $LegendO=$LegendO-10;<BR>    $MapO=$MapO-10;<BR>    $NorthO=$NorthO-10;<BR>    <BR>  <BR>}<BR>if($isLegend=='0')<BR>{ <BR>    $MapA=$MapA-40;<BR>    $NorthA=$NorthA-40;<BR>   
 saveImage($imgRequest,$sessionId,"Map",".png");<BR>    $pdf->Image($tempMapImgPath,$MapA,$MapO,100,100);<BR>    unlink($tempMapImgPath);<BR>  <BR>}<BR><BR>if($isLegend=='1')<BR>{<BR>    saveImage($LegendImgRequest,$sessionId,"Legend",".png");<BR>    $pdf->Image($tempMapImgPath,$LegendA,$LegendO,35,100);<BR>    unlink($tempMapImgPath);<BR>}<BR>    saveImage($imgRequest,$sessionId,"Map",".png");<BR>    $pdf->Image($tempMapImgPath,$MapA,$MapO,100,100);<BR>    unlink($tempMapImgPath);<BR>    <BR>if($isArrow=='1')<BR>{ <BR>    <BR>  $pdf->Image("pr_north.gif",$NorthA,$NorthO,15,15);<BR>}<BR><BR>$pdf->Output();<BR><BR><BR>function saveImage($imageSource,$sessionId,$ImageType,$ImageFormat)<BR>{  <BR>    global  $tempMapImgPath;<BR>    $ch = curl_init($imageSource);<BR>   
 curl_setopt($ch,CURLOPT_HEADER,0);<BR>    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);<BR>    curl_setopt($ch,CURLOPT_BINARYTRANSFER,1);<BR>    $rawdata=curl_exec($ch);<BR>    curl_close($ch);<BR>    $tempMapImgPath = $ImageType.$sessionId.time().$ImageFormat;<BR>    $fp = fopen($tempMapImgPath,'w');<BR>    fwrite($fp, $rawdata);<BR>    fclose($fp);<BR>}<BR><BR>function GetParameters($params)<BR>{<BR>    global $mapName, $sessionId, $title, $locale;<BR>    global $scale, $centerX, $centerY, $dpi;<BR>    global $isTitle, $isLegend, $isArrow;<BR>    global $Server;<BR><BR>    if(isset($params['LOCALE']))<BR>        $locale = $params['LOCALE'];<BR>    $mapName = $params['MAPNAME'];<BR>    $sessionId = $params['SESSION'];<BR>    $isTitle = $params['ISTITLE'];<BR>   
 $isLegend = $params['ISLEGEND'];<BR>    $isArrow = $params['ISARROW'];<BR>    $title = $params['TITLE'];<BR>    $scale = $params['SCALE'];<BR>    $centerX = $params['CENTERX'];<BR>    $centerY = $params['CENTERY'];<BR>    $dpi = $params['DPI'];<BR>    $Server = $params['SERVER'];<BR>}<BR><BR>function GetRequestParameters()<BR>{<BR>    if($_SERVER['REQUEST_METHOD'] == "POST")<BR>        GetParameters($_POST);<BR>    else<BR>        GetParameters($_GET);<BR>}<BR><BR>?><BR><BR><BR><BR>save the above code as some file  mappdf.php in the folder  C:\Program<BR>Files\OSGeo\MapGuide\Web\www\fusion\widgets\Print<BR><BR><BR>I will call this pdf file from print.js (widget) <BR><BR>showPdf: function() {<BR><BR>        var mainMap = this.getMap();<BR><BR>//  this.printablePdfURL  is 
 Fusion.getFusionURL() + widgetTag.location +<BR>'Print/mappdf.php';<BR><BR>        var url = this.printablePdfURL + '?';<BR>        var extents = mainMap.getCurrentExtents();<BR>        var centerX = (extents.left + extents.right) / 2;<BR>        var centerY = (extents.top + extents.bottom) / 2;<BR>        var dpi = mainMap._nDpi;<BR>        var scale = mainMap.getScale();<BR>        var maps = mainMap.getAllMaps();<BR>        url = url + 'MAPNAME=' + mainMap.getMapName();<BR>        url = url + '&SESSION=' + maps[0].getSessionID();<BR>        url = url + '&CENTERX=' + centerX;<BR>        url = url + '&CENTERY=' + centerY;<BR>        url = url + '&DPI=' + dpi;<BR>        url = url +
 '&SCALE=' + scale;<BR>        url = url + '&ISTITLE=' + (this.showTitle != '' ? '1' : '0');<BR>        url = url + '&ISLEGEND=' + (this.showLegend ? '1' : '0');<BR>        url = url + '&ISARROW=' + (this.showNorthArrow ? '1' : '0');<BR>        url = url + '&SERVER=' +<BR>Fusion.getFusionURL().split('/mapguide')[0];<BR>        if (this.pageTitle != '') {<BR>            url = url + '&TITLE=' + this.pageTitle;<BR>        }<BR><BR>        window.open(url, 'printablepdf', '');<BR>    }<BR><BR><BR>-- <BR>View this message in context: http://osgeo-org.1803224.n2.nabble.com/Generate-a-pdf-view-of-the-current-map-tp5264270p5272913.html<BR>Sent from the MapGuide Users mailing list archive at <A href="http://nabble.com/"
 target=_blank>Nabble.com</A>.<BR>_______________________________________________<BR>mapguide-users mailing list<BR><A href="mailto:mapguide-users@lists.osgeo.org" ymailto="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</A><BR>http://lists.osgeo.org/mailman/listinfo/mapguide-users<BR></DIV></DIV></div><br>
      </body></html>