I'm struggling to make sense of the different options available that may help with finding the right balance between file size and image quality when exporting a Print Layout as a PDF from QGIS.

The options I have found are:

  • From layers panel on the main/map window, Layer Properties -> Rendering has a 'Simplify Geometry' options which is in turn has four configuration options: threshold, algorithm, simplify on provider side and maximum scale.
  • From the same Rendering tab as above, there is a checkbox to force layer to render as raster.
  • From the layout window, when exporting the layout, options are offered to always export as vector and simplify geometries.

My use case consists of 3-4 vector layers of which one is very large (~5 million non-overlapping polygons) and the others trivially small. When I disable all options to reduce file size I get a PDF of around 100MB. Yes this is huge but I want this output because I know it will look good printed at any scale.

The issue is that I also want to produce a more manageable PDF for distribution. I've messed around with the various options but the only one that makes an makes an appreciable difference (PDF of ~7MB) is the one is the 'Force layer to render as raster' for the large layer. However, for this option to make any difference at all I have to uncheck the 'Lock styles for layers' option on the layout, which means that any other tweaks I made to the styling get lost and have to be made again. It seems that the layer rendering properties are treated by the layout manager as part of the layer style, though they are not treated in this way in the map window.

To complicate matters further I would like to be able to script the generation of both PDFs, as the underlying data are constantly updating and I want to produce the outputs on demand.

One hacky solution would be to make two layouts - one for the large version and one for the small. But then any refinements that get made down the track have to be carefully managed to be made identically on the two layouts, which is far from ideal.

I'd be interested to hear of any alternative ways I could solve this problem.

  • You might look at ways to convert your large pdf to a smaller one, and thus only produce one map. I had Adobe Acrobat Pro available to me for many years and used that as it had many options. Adobe Acrobat Standard has a simpler tool to reduce pdf file size which you could test. There are online pdf file reducers from Adobe and others you might try to see how it goes.
    – John
    Nov 9, 2023 at 16:46
  • Other than the extra complication of using proprietary software, I imagine that compressing the PDF will do things like rasterise where it's not really appropriate (eg text).
    – Jonathan
    Nov 12, 2023 at 10:31
  • I thought I'd cracked it by using layer styles and map themes but either I don't understand how these are supposed to work or I've stumbled on a bug in QGIS. I'll ask a new question now.
    – Jonathan
    Nov 12, 2023 at 12:50

1 Answer 1


I found a (the?) solution.

Using Map themes instead of locked layers/styles, I could then use Python to modify the layer render "force raster" property. Sample code:

for item in layout.items():
    if type(item).__name__ == 'QgsLayoutItemMap':
        for layer in item.layersToRender():
            if type(layer).__name__ == 'QgsVectorLayer':

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.