Please take a look at my drawing:
To compute the area of the trapezoid, we need the two base lengths (which we have) and the height #h#.
If we draw the height #h# as I did in my drawing, you see that it builds two right angle triangles with the side and the parts of the long base.
About #a# and #b#, we know that #a + b + 12 = 40# holds which means that #a + b = 28#.
Further, on the two right angle triangles we can apply the theorem of Pythagoras:
#{ (17 ^2 = a ^2 + h^2), (25^2 = b^2 + h^2) :}#
Let's transform #a + b = 28# into # b = 28 - a# and plug it into the second equation:
#{ (17 ^2 = color(white)(xxxx)a ^2 + h^2), (25^2 = (28-a)^2 + h^2) :}#
#{ (17 ^2 = color(white)(xxxxxxxx)a ^2 + h^2), (25^2 = 28^2 - 56a + a^2 + h^2) :}#
Subtracting one of the equations from the other gives us:
#25^2 - 17^2 = 28^2 - 56a#
The solution of this equation is #a = 8#, so we conclude that #b = 20 #.
With this information, we can compute #h# if we plug either #a# in the first equation or #b# in the second one:
#h = 15 #.
Now that we have #h#, we can compute the area of the trapezoid:
#A = (12 + 40 )/2 * 15 = 390 " units"^2#