2

Our application uses OpenLayers+PostGIS to visualize and process millions of spatial data files (GeoJSON).

We have a requirement to be able to export the processed final data as PDF/GeoPDF Vector maps.

Every solution, including the official OL example, first converts the OL canvas to a raster, then converts the image to PDF using something like jspdf. The raster conversion completely destroys the vector data, making the final PDF unusable for professional purposes (lines are pixelated, labels are blurred) (example below)

enter image description here

Is there a method that *preserves the Vector points/lines/labels in the map by skipping the raster conversion? Example: maps exported from AutoCAD/ArcGIS/QGIS have perfect, infinitely zoomable vector pdfs.

I've looked far and low for this, but couldn't find an answer, except for using 'gdal_translate', which seems cumbersome and poorly documented for programmatic usage.

1 Answer 1

0

Ensure that under Layout Properties (if yuo don't see a tab in the Map Layout window, go to Layout > Layout Properties), that 'Print to raster' is unchecked.

Sometimes it also helps to make sure 'Always export as vectors' is checked.

enter image description here

If you have certain layer effects enabled (transparency, blending modes) it may come up with a warning message saying print to raster is recommended; you can still override this but run the risk of your map not rendering as it does on the canvas.

Alternatively, if you are exporting a single PDF (i.e. not via atlas), you can use GeoPDF which in most cases seems to force it to vector.


However I recently encountered a problem in 3.16.1 and 3.16.3 where despite using the above options and not having layer effects enabled, there would be no warning message and all my maps would end up with the legend and other items as text objects/vector but the map itself and all the map objects would be raster.

Because it was an atlas export I couldn't use GeoPDF either.

After some trial and error I realised that using label masks seemed to force it to export the map to raster, so if that applies to your project check that as well.

EDIT: the software used in this screenshot is QGIS, specifically the "Layout" section of the QGIS Print Composer.

1
  • 1
    Hi, thanks for your response, but what software are you using in your example? I wanted to do the export directly from a webmap built with OpenLayers on a web browser.
    – raygun80
    Commented Aug 25, 2021 at 12:44

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.