A rectangle, filled or outlined

Place a rectangle: a coloured band behind a heading, a frame around an area, or both, with the stroke you choose.

Summary

The simplest brick there is: four corners, and the choice of what goes inside them. Filled, it makes the grey band behind a section heading or the coloured cell of a table; outlined alone, it marks out a photograph, or an area meant to be cut. When you ask for both, the fill goes down first, so the outline stays visible over it.

Technically

Asked for with "type": "rect"

A rect is a closed path whose four points you are spared: one re operator, then the same painting keys as a free path, the same clips, the same graphics state, the same placement. Its corners take expressions, which gives a band hugging the margins of a page whose width is unknown when the request is written. The fill takes a declared gradient, which makes it the usual carrier of a graded background. Drawing order follows item order: a rectangle placed after a text covers it.

Request schema

Required key: rect, an object of llx, lly, urx, ury, each a number or an expression. Optional: fill, a colour or {"shading": "name"}; stroke, an object with a required width plus color, dash, cap and join; clip, an object with a required segments and a rule (nonzero by default, even_odd); graphics_state, the name of a declared graphics state; pages, an array of one-based integers, default empty; transform, six numbers; rotate, degrees counter-clockwise about the centre of the rectangle; layer, the name of a declared layer. Cross refusals: transform together with rotate; a clip whose segments are empty. A rectangle takes fill, stroke, or both.

A whole request that creates a PDF

{
  "items": [
    {
      "type": "rect",
      "rect": {"llx": 72, "lly": 700, "urx": 523, "ury": 740},
      "fill": [0.85, 0.89, 0.95],
      "stroke": {"width": 1.0, "color": [0.11, 0.31, 0.55]}
    }
  ]
}

The line that sends it, in three languages

Shapes

A free path: lines, curves and filled shapes A straight line between two points A drawing declared once and placed as often as wanted

Where to go next

Every JSON key of a request, in one page The other twenty-two things you can draw

See the prices See the examples