A page of a supplied PDF, placed on the page

Take one page of a PDF sent with the request and place it in a frame, at its own proportions, among the other items.

Summary

You already have a warranty slip, a plan or a receipt as a PDF. Rather than making it again, you send it as it is. The page grows until it meets the nearest edge of the frame and centres in what is left, unsquashed. Around it you carry on writing, drawing and placing tables as usual.

Technically

Asked for with "type": "pdf_page"

The source PDF's bytes travel with the request, in a supplied part; the pdf key repeats that name, from the same pool the templates come from, so one supplied file serves both as a page background and as a placed item. The page number counts from 1. That page is copied, with the resources it uses, into a form XObject, then painted inside the frame: it keeps its proportions, scaled until it meets the frame's width or height, then centred in the rest. Unlike a template, which lines the whole page under the content, this item is one element among the others, placed in a box, and so combines with text beside it.

Request schema

Required keys: pdf, a string naming the supplied part; rect. Optional: page, a one-based integer, default 1; pages, an array of one-based integers, default empty for every page of the finished document; transform, six numbers; rotate, degrees counter-clockwise about the centre of the rectangle; layer, the name of a declared layer. Cross refusal: transform together with rotate. The imported page always keeps its proportions: the images' fit key has no counterpart here.

A whole request that creates a PDF

{
  "items": [
    {
      "type": "pdf_page",
      "pdf": "receipt.pdf",
      "page": 1,
      "boundary": "crop",
      "clip": "crop",
      "rect": {"llx": 72, "lly": 480, "urx": 523, "ury": 780}
    }
  ]
}

The line that sends it, in three languages

Pictures and imported pages

A picture placed in a rectangle

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