What is the easiest way of getting OpenLayers to configure itself for printing?

What is the easiest way of getting OL to configure itself for printing?  The
issue I have is that when printing with overlays and controls, the base map
gets covered and doesn't show (try a print preview on one of the example
pages with multiple layers).

Ideally, I'd like layers and controls to be able to use a @media print
stylesheet and turn on/off.  Perhaps even have a hidden print layer that
only displayed when the print styelsheet was used that combined all the
active layers (if they were from the same wms/other source).

So far, my only idea is to have two maps defined, one with a single layer
that is only enabled in the print stylesheet while the other is disabled,
and have some JS to keep the two in sync.  Any other suggestions?

Thanks,

John


Answer this question

a.
Instead, I recommend using some other tool to render a PDF out of your
backend: MapServer, for example, has a PDF output. Using PDF output
(instead of browser-based printing) means that your renderer is in
control of styling of the map, and you don't have the issues with
overlays or anything else.


b.
Printing to a pdf via mapserver is ideal when you only need the map output,
but when dealing with the contents of a web based application, the map is
rarely the sole contents of the page.

In my case, I have additional information associated with the map that needs
to be included in the report, which rules out using mapserver's pdf output.
I'll also have to create a legend which isn't supported with a mapserver
pdf.

I tried my idea of having two maps and div tags, turning one off with the
screen stylesheet and vice versa with the print sytlesheet, but apparently
the OL map object overrides the display value of the div tag, turning both
on at the same time.

As another approach, I was thinking of just having a div tag and setting
it's background image property to the value of a WMS request pulled from one
of the layers.  I believe that I will have to have a print button in order
to have JS turn off the map visibility so that it will be replaced by the
div with the wms background when using the print stylesheet.  I'd love to
get this working just through the stylesheets, since then users could simply
use the browsers file->print rather than rely on a page element (I know I'll
get calls about file-print not working :-) )

Still open to suggestions though!


c.
Another approach is to render a new page the does the print layout on it
and to use mapserver to render a single image equivalent of what is
being displayed in open layers. You also might want to take a look at
what ka-map is doing for the printing.


D.
Yea, our current IMS based app does that, but I was hoping to avoid that
method; all that duplicating complex code and such.  I'll check out ka-map,
I haven't played with that in a while, so I don't remember how it's doing
it.

  I've have most of the printing stuff worked out with css, except for the
map itself.  I was hoping for an elegant solution :-)  

Thanks,


F.
I've try this link for PDF saving, but I'm getting an error message.
I'm very new to openlayer and i'ts quite difficult for me to see what this message means.
Could anyone explain me how to make this PDF saving works?

here is the error message : "loadOutputFormat(): General error message. OUTPUTFORMAT clause references driver pdf, but this driver isn't configured. "

Thanks


if you have any question don't hesitate to contact me
Contact Us


你可能感兴趣的:(OpenLayers)