You may check if the WPS (like GeoServer) has an option to return you a PDF
directly? Other than that working with pixels is a pain when printing - it
would be great if we could read and render one of the vector formats like
kml.
The java printing callback system is hooked pretty deeply into the printer
drivers. You may not have to make an image the size of your page. You will
see different request patterns based on the driver - you can capture each
one of these requests and draw just that section of the image. This is a
tough problem.
--
Jody
--
Jody Garnett
On 15 January 2015 at 05:33, mroguski <mrogu...@megabit.com.pl> wrote:
> Hello,
>
> recently I came accross a problem with printing WMS layer. The printing is
> fine when the size of the result image is not too large. When larger - it
> crashes.
> I use Geotools 12.1.
>
> But let me explain more in details:
>
> Here is a piece of code that prepares the WmsLayer that will be passed to
> MapContent.
>
> // layer is an instance of my own class that has the layer properties
> read from database
> URL url = new URL(layer.getWmsUrl() + "?request=getCapabilities");
> WebMapServer wms = new WebMapServer(url);
> List<org.geotools.data.ows.Layer> tileLayers =
> wms.getCapabilities().getLayerList();
> org.geotools.data.ows.Layer wmsLayer = ...;//here I select a proper
> layer from 'tileLayers'
> return new WMSLayer(wms, wmsLayer);
>
> I store the result in *wmsLayer* variable.
>
> I create the print bounding box in this way:
> ReferencedEnvelope extent = new
> ReferencedEnvelope(printArea.getExtent(), targetCrs);
>
> The reference system (*targetCrs*) of the bounding box is EPSG:3857
> (Pseudo
> Mercator).
>
> After the layer and printing area are ready I do the followig to print it:
>
> MapContent mapContent = new MapContent();
> mapContent.addLayer(wmsLayer);
> mapContent.setViewport(new MapViewport(extent));
> renderer.paint(gr, renderSize, extent);
>
> where:
> *gr *is an instance of Graphics2D class
> *renderSize *is an instance of java.awt.Rectangle
>
> The render size is: width = 3390, height = 2363.
>
>
> The problem has its beggining in WMSCoverageReader class in this method:
> ReferencedEnvelope initMapRequest(ReferencedEnvelope bbox, int width,
> int height, Color backgroundColor);
> It starts at line: 322
>
> The reference system of the wms layer is EPSG:4326. It is different from
> the
> *bbox* of the print viewport which is EPSG:3857 (as mentioned above).
> This method tries to transform the *bbox* to the layer's CRS and along with
> it it changes the size of the drawn picture.
> >From the initial values: 3390 x 2363 they change to 3390 x *8073*.
> And here is the root of the problem. The new size of the image exceeds the
> maximum image size that WMS server can produce.
> The GetCapabilities request clearly states the maximum image size.
>
> Is there any way to solve such problem ?
> Currently I can print an image that would fit A4 paper sheet assuming that
> its resolution is not too high.
> If I set the resolution to about 300dpi (which increases the size of the
> image in pixels) I get this error.
>
> I am aware that the post is long so if there is anything unclear - please
> let me know.
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/Problem-with-printing-WMS-tp5181673.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
> GigeNET is offering a free month of service with a new server in Ashburn.
> Choose from 2 high performing configs, both with 100TB of bandwidth.
> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
> http://p.sf.net/sfu/gigenet
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users