[Geoserver-users] Print to PDF with legend?

Hello--I am new to GeoServer and using it with OpenLayers on the
client side. I am very pleased with how user-friendly it is--great
program!

My question is:

I have a map I want to output to a PDF, and I want to include a
legend. Format=application/pdf will get me a PDF, GetLegendGraphic
will get me a legend.
Both of those work great! But I really want to combine the legend
graphic with the map in the same PDF--is there any way to do this?

Or, alternately, is there a way to make a sort of phony-WMS layer that
can contain a legend?

Thanks,
Eleanor

eleanor tutt ha scritto:

Hello--I am new to GeoServer and using it with OpenLayers on the
client side. I am very pleased with how user-friendly it is--great
program!

My question is:

I have a map I want to output to a PDF, and I want to include a
legend. Format=application/pdf will get me a PDF, GetLegendGraphic
will get me a legend.
Both of those work great! But I really want to combine the legend
graphic with the map in the same PDF--is there any way to do this?

Or, alternately, is there a way to make a sort of phony-WMS layer that
can contain a legend?

Hum... none of the above unfortunately. By combining the two functionalities, we could put a legend somewhere above the map, yet I'm not too sure this would be a good idea for the long term. First,
it would take quite a bit of configuration: where do you put the legend
compared to the map (outside, which side, inside, which corner),
trasparent or solid color background, what about the border, does
it have a title, if so, which text, which font, and so on.
Real world requirements would then escalate to have a full map layout with company logo, title and subtitle, legend, graticule, scalebar and
whatnot. That won't be small job, we should use an external, user editable template (a SVG file with named rectangles to host map and legend would do I think).

Long story short, I don't know of a quick solution that you could
apply right away. The few times I've seen this done, it was done
with custom programming in order to respect a full layout that was provided by the customer as his "carthographic standard".

If you have programming skills and want to tackle this by yourself,
we can try to help you cook your own specific solution, otherwise
if you're in a hurry and need a solution done quickly you can turn to geoserver commercial support.

If any other user has rolled his own custom solution and can talk
about it, I would be curious to hear, maybe I'm overlooking a simpler
solution using thirdy party tools :slight_smile:

Cheers
Andrea

Thanks for the response--I was afraid there wouldn't be a simple answer.

Ultimately, I am looking to be able to add all the "real world
requirements" to the PDF--logo, title, legend, etc. I am not an adept
programmer, but I have more will and persistence and coffee than I
have money, so I would like to avoid commercial support if possible.

Just in case no one on the list has a custom solution they are willing
to share, would you mind giving me some further ideas about how the
SVG template and GeoServer would fit together conceptually? Sort of a
rough outline of the steps I would need to take? (I am using
OpenLayers on the client side if that affects anything.) Of course, I
will make any solution that I come up with available to other users--I
have a feeling I am not the only one who needs something like this!

Thanks,
Eleanor

On 6/17/07, Andrea Aime <aaime@anonymised.com> wrote:

Hum... none of the above unfortunately. By combining the two
functionalities, we could put a legend somewhere above the map, yet I'm
not too sure this would be a good idea for the long term. First,
it would take quite a bit of configuration: where do you put the legend
compared to the map (outside, which side, inside, which corner),
trasparent or solid color background, what about the border, does
it have a title, if so, which text, which font, and so on.
Real world requirements would then escalate to have a full map layout
with company logo, title and subtitle, legend, graticule, scalebar and
whatnot. That won't be small job, we should use an external, user
editable template (a SVG file with named rectangles to host map and
legend would do I think).

Long story short, I don't know of a quick solution that you could
apply right away. The few times I've seen this done, it was done
with custom programming in order to respect a full layout that was
provided by the customer as his "carthographic standard".

If you have programming skills and want to tackle this by yourself,
we can try to help you cook your own specific solution, otherwise
if you're in a hurry and need a solution done quickly you can turn to
geoserver commercial support.

If any other user has rolled his own custom solution and can talk
about it, I would be curious to hear, maybe I'm overlooking a simpler
solution using thirdy party tools :slight_smile:

Cheers
Andrea

eleanor tutt ha scritto:

Thanks for the response--I was afraid there wouldn't be a simple answer.

Ultimately, I am looking to be able to add all the "real world
requirements" to the PDF--logo, title, legend, etc. I am not an adept
programmer, but I have more will and persistence and coffee than I
have money, so I would like to avoid commercial support if possible.

Just in case no one on the list has a custom solution they are willing
to share, would you mind giving me some further ideas about how the
SVG template and GeoServer would fit together conceptually? Sort of a
rough outline of the steps I would need to take?

Of course, here is a rough outline.
SVG came to mind because it is vector based, fully featured graphics wise, and each element can have an ID we can use in order to perform
on the fly replacement (templating).

So, the first step user wise would be to gather Inkscape and create a
template with the right paper size, with a couple of rectangles whose
id are "map" and "legend".

Then, programming wise, we could load the svg with batik, gather
somehow the extents of the legend and map placeholders, and then
render the svg on top of the Graphics object provided by iText
(that will generate out the PDF). Once you have done that, you
render the map, and then the legend, onto the pdf, knowing were
to place those.

Code wise, I think you can alter the PDF output format class.
I know this leaves large holes on how to really do that, but that's
just because I don't really know much about the details, I would
have to figure them out myself.

To simplify things a little, I would render the map and legend
boxes as is (if people want them to be transparent, they can
set them up to be so in the svg), so that you only have to query
the svg, but not to manipulate it.

Other background information can be found on the iText and iBatis
sites. Oh, I guess the easiest way to code against Geoserver
would be to grab the sources out of the 1.5.1 tag at
https://svn.codehaus.org/geoserver/tags/1.5.1/, so that you don't
need a geotools checkout as well.
More information on how to setup a Geoserver dev environment
can be found at: https://svn.codehaus.org/geoserver/tags/1.5.1/

If you need quick hints, you can also reach us in the GeoServer
irc channel at freenode, or write some other mails here.

Good luck :slight_smile:
Cheers
Andrea

Andrea Aime ha scritto:

Other background information can be found on the iText and iBatis
sites.

Hmm... guess I had a little too much wine during lunch... it's Batik,
not iBatis :slight_smile:

Cheers
Andrea

Ahhh, wine at lunch! A wonderful thing!

Thanks so much for the outline! I will be in touch with specific
questions later (once I get frustrated). In the meantime, you can
assume I am hard at work!

Thanks again,
Eleanor

On 6/17/07, Andrea Aime <aaime@anonymised.com> wrote:

Andrea Aime ha scritto:
> Other background information can be found on the iText and iBatis
> sites.

Hmm... guess I had a little too much wine during lunch... it's Batik,
not iBatis :slight_smile:

Cheers
Andrea

To me it seems like all the bits & pieces are there to relatively easilly
construct xsl->xsl-fo->pdf chain that could format your output any way you
want. I like xslt.

Regards
Jason.

Quoting Andrea Aime <aaime@anonymised.com>:

eleanor tutt ha scritto:
> Thanks for the response--I was afraid there wouldn't be a simple answer.
>
> Ultimately, I am looking to be able to add all the "real world
> requirements" to the PDF--logo, title, legend, etc. I am not an adept
> programmer, but I have more will and persistence and coffee than I
> have money, so I would like to avoid commercial support if possible.
>
> Just in case no one on the list has a custom solution they are willing
> to share, would you mind giving me some further ideas about how the
> SVG template and GeoServer would fit together conceptually? Sort of a
> rough outline of the steps I would need to take?

Of course, here is a rough outline.
SVG came to mind because it is vector based, fully featured graphics
wise, and each element can have an ID we can use in order to perform
on the fly replacement (templating).

So, the first step user wise would be to gather Inkscape and create a
template with the right paper size, with a couple of rectangles whose
id are "map" and "legend".

Then, programming wise, we could load the svg with batik, gather
somehow the extents of the legend and map placeholders, and then
render the svg on top of the Graphics object provided by iText
(that will generate out the PDF). Once you have done that, you
render the map, and then the legend, onto the pdf, knowing were
to place those.

Code wise, I think you can alter the PDF output format class.
I know this leaves large holes on how to really do that, but that's
just because I don't really know much about the details, I would
have to figure them out myself.

To simplify things a little, I would render the map and legend
boxes as is (if people want them to be transparent, they can
set them up to be so in the svg), so that you only have to query
the svg, but not to manipulate it.

Other background information can be found on the iText and iBatis
sites. Oh, I guess the easiest way to code against Geoserver
would be to grab the sources out of the 1.5.1 tag at
https://svn.codehaus.org/geoserver/tags/1.5.1/, so that you don't
need a geotools checkout as well.
More information on how to setup a Geoserver dev environment
can be found at: https://svn.codehaus.org/geoserver/tags/1.5.1/

If you need quick hints, you can also reach us in the GeoServer
irc channel at freenode, or write some other mails here.

Good luck :slight_smile:
Cheers
Andrea

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users