4

This is not the first time trying to solve this problem, which is why I'm writing a self-answered question, after spending another hour to re-discover a solution.

How do I force Asymptote to output a PDF or EPS with a given exact page size, regardless of what graphical elements are drawn into it and without scaling the content?

2
  • 1
    Your contribution is appreciated, but would be more helpful if you could explain how you need more than the size(width, height) command, e.g., size(50mm, 10mm); Jan 11, 2016 at 1:43
  • 1
    @CharlesStaats AIFCT, size() does not prevent the output page to be smaller than requested. Also, its documentation talks about scaling of the graphic, which I do not want to happen. Jan 11, 2016 at 2:56

1 Answer 1

4

Use this:

// Requested page boundaries.
pair page_min = (0mm, 0mm);
pair page_max = (50mm, 10mm);

// Label sticking out of the requested frame.
label("Lorem ipsum", (0, 0), E);

// Line, shorter in one direction of the frame, longer in the other.
draw((0mm, 0mm) -- (20mm, 20mm), 1mm + black);

// Clip the elements in the current picture. Prevents the page from being enlarged and needs to be called after all drawing commands.
clip(box(page_min, page_max));

// Set the page size. Prevents the page from being shrunken.
fixedscaling(page_min, page_max);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .