Skip to content

[Feature]: Vector PDF export: layouts, reports and map frames as vectors #1342

Closed

Description

@Mavrick-F

Before you start

  • I searched the existing issues and the roadmap and did not find a duplicate request.

What problem does this solve?

A layout, report or printed map exported to PDF is one picture per page (crates/render/src/pdf.rs). At 11×17 or 24×36 inches that picture is either soft or very large, text can't be searched or copied, and nothing can be adjusted afterwards in a vector editor. The roadmap lists this under Expressions and cartography: "Layouts and reports exported as vector PDF, with text and map frames as vectors".

I'd like to take it on, and since it reaches into the map renderer, I'd like a maintainer's view on the approach before I write the large part.

Proposed solution

One renderer, two outputs. The map renderer draws straight onto a tiny_skia::Pixmap: about 65 functions on the flat path take &mut Pixmap, and labels are drawn as glyph coverage. Rather than write a second, vector renderer beside it (every symbol feature — dashes, offsets, line markers, patterns, curved labels — would then exist twice and drift apart), the drawing functions would take a small Canvas instead. On screen it forwards to the pixmap exactly as today; for export it records what is drawn — paths with their fill or stroke, colours, linear and radial gradients, clips, transforms, glyph runs and placed images — into a display list that a PDF writer turns into page content.

What becomes what in the PDF:

  • Vectors: basemap, polygons, lines (dashes, caps, joins, stacked and offset strokes), markers and line markers, aggregation bins, extrusions, selection, grids, the extent indicator, and every surround: text, shapes, legend, scale bar, north arrow, colour bar, table, chart, report pages.
  • PDF features, not pixels: layer opacity, the six blend modes (Multiply, Screen, Overlay, Darken, Lighten, Difference are PDF blend modes), layer masks as clip paths, shaped map frames as clip paths.
  • Text: each face used becomes a PDF Type 3 font whose glyphs are their outlines (as glyphs.rs already reads them), with a ToUnicode map so the text is searchable and copyable. No dependency, no font subsetting, and the PDF looks like the PNG export, synthetic italics and variable weights included. Halos are stroked outlines. Embedding the actual font files (editable text in a design tool) would need a font subsetter; I'd evaluate that dependency separately, later.
  • Pictures inside the PDF: rasters and hillshade, web tiles, view effects, shapeburst and sweep gradients, legend images from map services. Each is drawn at the export dpi and placed where it belongs, as now.

Screen-only shortcuts (stamped marker sprites, single-pixel splats for sub-pixel features) switch off when recording, and the 0.35 px point thinning uses the export's resolution. A page has a size budget, like PDF_BUDGET today: a layer that would pass it is drawn as a picture instead, with a notice naming the layer.

No command changes: layout.export, report.export and Print Map keep their ids and parameters; a .pdf simply becomes vector. The PDF writer stays hand-written in rustgis-render, extending pdf.rs.

Three stacked pull requests:

  1. The renderer draws through Canvas; screen and PNG output unchanged, shown by the existing pixel tests.
  2. Recording and the PDF writer: layouts, reports, presentations and Print Map write vector PDFs.
  3. SVG map frames and surrounds as vectors from the same display list (the roadmap's "SVG layout export with map frames and surrounds as vectors"), and the docs.

Estimated scope

Large

Crates and dependencies

rustgis-render (most of it), rustgis-engine (export plumbing, notices), docs. No new dependency and no new crate. rustgis-tiles keeps drawing into pixmaps; its output is placed as pictures.

Testing

  • Step 1: the existing render and layout pixel tests, unchanged.
  • Step 2: PDF structure tests (objects, xref, content operators, fonts and ToUnicode), and checks that a page's paths and text match what the PNG render draws; the export of the sample World Atlas layout opened in a PDF viewer and compared with the PNG; notices tested both ways (a layer over the budget gives one, a normal page none); hostile layouts and huge pages stay bounded.

Alternatives considered

  • A separate vector renderer for export: smaller first change, but two renderers to keep in step.
  • Embedding real fonts through a PDF and font-subsetting library: editable text, at the cost of new dependencies; left for a later evaluation.
  • A coarse split, each layer either all vector or all picture: the per-call recording gives it for free where it's needed, and keeps everything else vector.

@giswqs, does this approach work for you, in particular the Canvas change to the renderer and the three-step plan?

Activity

  1. added
    enhancement
    on Nov 2, 2026
  2. self-assigned this
    on Nov 2, 2026
  3. giswqs commented on Nov 2, 2026

    @giswqs
    Member

    Sounds good to me. One minor caveat is that Vectors: basemap probably only works for verctor-tile basemaps. Traditional raster tile basemaps like USGS Imagery and OpenStreetmap XYZ tiles would only be drawn as pictures.

    I would be great to have a comparsion of PDF file sizes before and after the change for various scenarios.

  4. Mavrick-F commented on Nov 2, 2026

    @Mavrick-F
    MemberAuthor

    Thanks! Agreed on the basemap: by "basemap" I meant the built-in land outlines the map draws itself. XYZ and other raster tile basemaps stay pictures, and in this plan so do vector-tile basemaps, since the renderer draws them from cached tile pictures; drawing those as vectors could come later.

    The PDF pull request (step 2) will include a table of file sizes before and after, with export time, for:

    • the sample World Atlas layout;
    • a layout of a dense vector layer (a county's parcels);
    • a layout over a raster tile basemap;
    • a labelled map with many labels;
    • a report;
    • a 20-page map series.

    Today's PDFs at 150 and 300 dpi will be the "before". I'm starting on step 1, the Canvas change, now.

  5. arielsrossi commented on Nov 2, 2026

    @arielsrossi

    This improvement can be combined with the #1191

    In the future, an enhancement similar to ArcGIS’s "Driven Pages" could be added.

  6. Mavrick-F commented on Nov 2, 2026

    @Mavrick-F
    MemberAuthor

    Definitely @arielsrossi. My first priority is to get basic vector features, but I've got my eye on GeoPDFs and will get to them in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions