[Mapserver-users] PHP/mapscript - Inserting vector maps into PDF documents

Antti.Roppola at brs.gov.au Antti.Roppola at brs.gov.au
Thu Jan 30 18:45:18 EST 2003


Thanks for the info, I have not yet had a close look at the 3.7 PDF code.

Yes, I can see how position and scale controls could be added to the PDF doc
generator, but I'd like to do as little as possible inside Mapscript and
manipulate the drawing placement in PHP/PDFLib since it appears that
the required funtionality already exists there. Of course, I have not
investigated this in any detail and there may be good reasons why it
should not be done this way. :o)

BTW,

Assuming that by "plot resolution" you are talking about the density
of vertices in the output PDF (which in typical default map states produces
a pretty ugly "jaggy" vector), it is possible to control the density of
vertices by manipulating map->height and map->width since these also control
the resampling of shapes when they are read in for rendering:

Default w. 600x600 image size	http://data.brs.gov.au/mapserv/dev/pdfcell7000.png
Bump size to 1200 x 1200 http://data.brs.gov.au/mapserv/dev/pdfcell3500.png
Then to 3000 x 3000 http://data.brs.gov.au/mapserv/dev/pdfcell1400.png

Cheers,

Antti

-----Original Message-----
From: Zak James [mailto:zak-ms at aiya.dhs.org]
Sent: Friday, 31 January 2003 8:43 AM
To: Antti.Roppola at brs.gov.au
Cc: mapserver-users at lists.gis.umn.edu
Subject: Re: [Mapserver-users] PHP/mapscript - Inserting vector maps
into PDF documents


In the 3.7 branch, the DrawMapPDF() function has been removed in favour  
of integrating PDF output into the new OUTPUTFORMAT system  
(http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?OutputFormat) which is  
supported from mapscript. In 3.6.x, the pdf rendering is done by custom  
functions - like DrawMapPDF(), so there isn't any support for them in  
the mapscript bindings.

I agree that more control over the PDF rendering is needed and should  
be handled using the FORMATOPTION field, so that mapscript doesn't have  
to be modified to take advantage of it. As an example, the 3.7 flash  
support uses this approach. I am hoping to add pdf plot resolution  
control through this mechanism, but it would also be possible to  
control rendering size and position, or allow the use of pdf template  
files.

I'm not sure if my changes will make the 3.7 release.

zj

On Tuesday, January 28, 2003, at 11:43  pm, Antti.Roppola at brs.gov.au  
wrote:

> Hi all,
>
> Around this time last year, there was some discussion on the Mapserver  
> list about
> how you'd go about including Mapserver elements in arbitrary places on  
> a PDF being
> created in PHP/Mapscript.
>
> 	http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0202/ 
> msg00240.html
> 	http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0202/ 
> msg00239.html
>
> I've just spent quite a while browsing the mappdf source and there's a  
> DrawMapPDF() function
> that skips the creation of a new PDF object if an existing one is  
> given as an argument,
> but I can't find a hook into it through PHP/Mapscript. Nor can I see  
> anything in this function that
> would allow me to control the placement of the map in my pdf object. I  
> guess I'd really like an
> outputformat that returns PDF instructions rather than a whole  
> document, this way I could
> use pdf_translate() and pdf_scale() to do the placement myself:
>
>
> 	$map->selectOuputFormat("pdf_instructions");	// as opposed to a  
> complete PDF doc
>
> 	$pdf_instructions=$map->draw();
> 	place($my_pdf, $pdf_instructions, $pos_xmin, $pos_ymin, $pos_xmax,  
> $pos_ymax, $angle);
>
> 	function place ($my_pdf, $pdf_elements, $pos_ymin, $pos_xmax,  
> $pos_ymax, $angle) {
> 		pdf_save($my_pdf);	// save default state
> 		if($angle) {
> 			pdf_rotate($my_pdf, $angle)
> 		}
> 		pdf_translate($my_pdf, $pos_xmin, $pos_ymin);
> 		...			// stuff happens to calc scaling
> 		pdf_scale($my_pdf, $pos_dx, $pos_dy );
> 		include $pdf_elements;	// you get the idea...
> 		pdf_restore($my_pdf);	// restore default state
> }
>
>
>
> Has anyone got any insights on where things are at?
>
> Cheers,
>
> Antti
> N.B. I do have all the other PDF functionality such as 3.7  
> outputformat working, I just
> want to be able to write my map objects into an existing PDF as  
> vectors.
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>





More information about the mapserver-users mailing list