[OpenLayers-Users] printing...

Stephen Woodbridge woodbri at swoodbridge.com
Sat Mar 24 15:20:28 EDT 2007


John,

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.

-Steve W

John Cole wrote:
> 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!
> 
> John 
> 
> -----Original Message-----
> From: Christopher Schmidt [mailto:crschmidt at metacarta.com] 
> Sent: Saturday, March 24, 2007 11:46 AM
> To: John Cole
> Cc: openlayers
> Subject: Re: [OpenLayers-Users] printing...
> 
> On Sat, Mar 24, 2007 at 10:14:58AM -0600, John Cole wrote:
>> 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).
> 
>> 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?
> 
> I highly recommend not depending on browsers for printing.
> 
> 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.
> 
> http://mumbai.freemap.in/ uses this technique.
> 
> That's always been my recommendation, and I'm sticking to it :) 
> 
> Regards,




More information about the Users mailing list