Question 4796
Let L = Length of printed matter
Let W = Width of printed matter
let M = Margin
Area of printed matter = 40 = L*W Length of page = 18cm = 2M+L
Width of page =  12cm = 2M+W

Using the elimination method:
18=2M+L
12=2M+W

Subtract the 2nd equation from the first to get
6=L-W
add w to both sides:
6+W=L

Use the substitution method on the area equation to get:
40=(6+W)*W

Clear the parentheses:
{{{40=6W+W^2}}}
Subtract 40 from both sides to set equal to zero and solve for x:
{{{0=W^2+6w-40}}}
Factor:
(w+10)(w-4)
w=-10, w=4

We can eliminate the negative because this is a distance we are discussing, so the width of the printed matter is 4cm
the length of the printed matter is 10 cm

Going back to the system of equations, we know the page length is 
18=2M+L
18=2M+10
8=2M
4=M

The margin is 4 cm.  
Check by adding the margins to the width and length.