[mapserver-users] PDF Output: How?

Rodrigo Cabral cabral at yadata.net
Sat Feb 16 13:58:06 EST 2002


Apparently PDF support is drawing lots of interest recently =) I, for one,
have also successfully drawn map images in PDF files to generate reports,
although I haven't used MapServer's PDF extension for a few reasons. Using
PHP/MapScript, I embeded a 1800x1800 image in the PDF report, which is
generated using mapscript plus a different mapfile than the one used for web
browsing (created specifically for printing). The image is big enough to
avoid seeing pixel artifacts in the print out, and the result is quite
pleasant.

HOWEVER, this approach will never match the quality of vector
images drawn directly in PDF, and also makes the PDF file larger (I think).
So, what I'm doing right now is just waiting for the PDF+MapScript support
to be written....

BUT.... I was thinking about the msDrawMapPDF(...) function arguments, and
noticed that you cannot control the position (X,Y) of where the map is going
to be drawn, it's always centered in the page and apparently the size of the
map is defined with the mapfile SIZE statement.

SO, I have a few suggestions to make, if ~frank~ (author of mappdf.c) would
concur... Hope I'm not intruding about it.

1) Include X, Y coordinates in msDrawMapPDF function. So, in MapScript, one
would simply do this:

$pdf = pdf_new();
$map = ms_newMapObj( $pdf_mapfile );
// *** lots of processing here ***
$map->drawMapPDF( $pdf_handler, $x, $y );
// *** now, simply return the created PDF report

2) Assume that the width and height of the map (as defined in the mapfile
SIZE statement) is in the same metrics of the PDF file. Therefore, the
actual place where the map should be drawn in the PDF page is:
  Left: $x
  Top: $y
  Right: ($x + $map->{width})
  Bottom: ($y + $map->{height})
I trust that most people would have a different mapfile for printing (rather
than using the same one for browsing), so it wouldn't be much of a problem
to use the mapfile image SIZE to store PDF targeted values.

In time, the other draw methods could also be implemented with the same
assumptions. Thus, one would be able to create a report with georeferenced
information right alongside report text, plus legend, scalebar, etc...

Any comments?

Rod.

----- Original Message -----
From: "Steve Lime" <steve.lime at dnr.state.mn.us>
To: <Antti.Roppola at brs.gov.au>
Cc: <mapserver-users at lists.gis.umn.edu>
Sent: Friday, February 15, 2002 1:21 AM
Subject: RE: [mapserver-users] PDF Output: How?


The landview piece simply embeds a image rendered in mapserver into a pdf. I
can share code.

However, there are opportunities to create vector PDFs with MapServer. The
shp2pdf program is an example. You can easily wrap that with perl or
whatever pretty easily. I'll add scripting access to that once a C wrapper
to writing a PDF file is done.

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937
>>> <Antti.Roppola at brs.gov.au> 02/14/02 21:33 PM >>>
Concidentally, Rasmus was here this week and talked about this. :o)

Have a look at slide 51 onward at http://conf.php.net/oz2002/
(BTW, I couldn't get the slide browser to work under IE, only  Netscape).

Slide 57 has an example of placing an image into a PDF.
Putting Mapserver stuff into a PDF this way looks to be easy (it's on my
list of things to try). Keeping vector map layers as vectors using
SVG or something would be cooler still.

The Shockwave stuff is even more interesting, animated maps anyone?

Cheers,

Antti

Eliot wrote:

> Basically I just want to have a print to pdf button on my application much
> like the landview site. Could someone point me to some examples of how to
do
> this, or give me some clues and I can go from there?

> I see the landview site is done with perl. Can the pdf functions be called
> from php/mapscript as well?















More information about the mapserver-users mailing list