qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.63k stars 3.01k forks source link

QGIS Server: add support to disable tiled raster layers in PDF exports #51238

Open cxcandid opened 1 year ago

cxcandid commented 1 year ago

Feature description

When I export a layout to a PDF in QGIS client (3.28.1 Windows), I can select the advanced option to disable tiled raster layers. Unfortunately this option is missing in QGIS Server GetPrint requests.

It would be advantageous if we could disable tiled raster layers by default. Perhaps we could get a global setting like we have for raster resampling.

The raster tiles create unsightly effects and enlarge the output, if the map window is rotated.

raster_tiles

When I open the PDF in Inkscape and ungroup all the groups, I see that a large portion of the raster images are just hidden and use a lot of memory, which doesn't happen when the raster is not tiled. pdf_tiled

Additional context

No response

andreasneumann commented 1 year ago

@cxcandid - just a little side note to your problem - it doesn't exactly solve your issue.

But: there is an alternative data source for tiled background layers in the "Layer Properties" --> "QGIS Server" --> "WMS Print Layer":

image

That way you can specify an alternative WMS service that can potentially offer higher-resolution (e.g. 300 dpi) prints as a single image (or with fewer tiles, if you hit the width/height limit of a service).

cxcandid commented 1 year ago

@andreasneumann - thank you very much for the hint. It is really good to know this feature.

In the case of PDF exports, it probably won't help.

andreasneumann commented 1 year ago

@cxcandid - printing and PDF export is basically the same thing in QGIS server - so yes, the alternative WMS would be in the PDF export instead of the tiled background layers.

Also: have you tried the two settings "Publish WMS/WMTS data source URI" and "Advertise as background layer". It may be, if you turn the "Advertise as background layer" on, that it won't print / be part of the PDF export. Something to try, I am not sure.

cxcandid commented 1 year ago

@andreasneumann - the source of my raster layer is actually WMS. QGIS Server is tiling the raster automatically in GetPrint responses if format is PDF.

QGIS Server honors the setting for vector/raster export ("Always export as vectors") and for text export ("Always export Text as ...") but not the advanced option "Disable tiled raster layer export".

PDF_Export_options

cxcandid commented 1 year ago

Maybe we could have another export option for the layout (Disable tiled raster layer) which is respected by QGIS Server. export_settings

andreasneumann commented 1 year ago

Ah - sorry about the confusion. It makes sense to add this setting in the GetPrint command.

cxcandid commented 1 year ago

It looks like the flag QgsLayoutRenderContext::FlagDisableTiledRasterLayerRenders is missing in exportSettings.flags (qgswmsrenderer.cpp).

// Draw selections
      exportSettings.flags |= QgsLayoutRenderContext::FlagDrawSelection;

// Disable Raster Tiles
      if ( layout->customProperty( QStringLiteral( "pdfDisableRasterTiles" ), false ).toBool() ) 
      {
          exportSettings.flags |= QgsLayoutRenderContext::FlagDisableTiledRasterLayerRenders;
      }

I hope someone can incorporate this customization as it is unfortunately beyond my current capabilities. 🙏

cxcandid commented 1 year ago

Is there really none of the QGIS server developers interested in making these small changes? ... maybe @elpaso ?