2

QGIS reports appear to produce vector images for displayed maps when exporting to a PDF document. This is presumably an equivalent of exporting an atlas or single map to a PDF. This provides good quality output, but file sizes can be large. Is there a method to export a pdf 'report', but to tell QGIS to use raster rather than vector images for the actual mapping within that PDF?

Detail in my case: I'm using vector tiles for background mapping, which gives me control of the background mapping but increases the issues for a recipient needing to view a large PDF file. I'm looking for the benefits that the vector tiles provide in producing good quality mapping images, but there is no need for these to remain as vector images in the final product.

2 Answers 2

3

Print as raster

In the print layout composer (and its equivalent for reports) you will find a number of tabs: {Item properties|Layout|Guides|Atlas}.

On the Layout tab, scroll down to the Export settings.

Print as raster

There you can turn on rasterization of the output using the option Print as raster. As a bonus, you can also decrease the output resolution, substantially reducing the size of your output.

Export to PDF

Then, when you export to PDF, after picking a file name, you are shown a dialog that has the option: Always export as vectors so your previous choice can be undone if you want to export using vectors occasionally.

Export as vectors

Note that, as described by Rostranimin in a comment, there can be unexpected results (output shrunk so as not to fill a page properly) in reports. These issues seem to be associated with having different resolutions set for different sections.

4
  • Thank you, that works. I've not investigated deeply yet, but it's worth adding that there appears to be a bug (at version 3.16.16 ). If I set some pages to print at a lower resolution the content shrinks leaving empty space, rather than the resolution being lower. So the content on pages at 100dpi is only a third of the width of the created pdf page. I imagine this might be because some sections (or their headers) are set at 300dpi. I guess this might also be a function of how pdfs work? Anyway, irritating if its necessary to go individually through all sections to set resolution the same. Commented Dec 1, 2023 at 10:57
  • @Rostranimin: Thanks for the feedback. Perhaps my new answer can offer some help with this.
    – peter
    Commented Dec 1, 2023 at 15:47
  • 1
    I've added a short explanation about the issue to the answer. I'll do some further troubleshooting another time. My current project report has four field-group sections, each with headers. It was within some of the field group maps that I tried reducing resolution. I've confirmed that if the resolution is reduced on all the headers and on each field group body layout (to 200dpi) the pdf is produced correctly. Commented Dec 1, 2023 at 20:27
  • 1
    I don't see reports about this on Github, so I created an issue here: github.com/qgis/QGIS/issues/55485 Commented Dec 1, 2023 at 21:04
0

My previous answer is based on the Print layout, while the question is based on Reports. Luckily the relevant parts look very alike so in essence it worked.

Sadly in the reports engine this resolution change gives a problem where some items are incorrectly sized (See the comment by the OP). When a map is added in a section of the body and the layout resolution is reduced the map is not sized correctly. This happens in version 3.16.5 too.

When experimenting, I noticed that when I also add a map in the body of a Field-group section, both maps are 'magically' correctly sized.

For me this workaround seems to work:

  1. Add a dummy layer without any features to the project.
  2. Add a Field group section to the report, using this dummy layer.
  3. In the body of this group, add a map.

This second map will not be shown as the dummy layer is empty, but it seems sufficient to make the other map size correctly.

1
  • 1
    To confirm, this workaround appears to work for me too. The issue seems to go away if an extra field group section is added with a body set to print as a vector image (without 'print as raster' ticked). Commented Dec 1, 2023 at 21:14

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.