Particle Systems adding margins and placing on top
We will be changing the origin position of the cube. The particle system works by attaching the origin point of the selected object to the surface of another. By changing the origin point, we can also change the position of every particle on the object.


Select the object to be used as a particle (the cube in your case).
Go into edit mode, and press A to select all vertices.
Move the cube geometry.
Go out of edit mode. As you can see, the geometry of the cube should have moved, but the origin point remains the same, effectively changing the origin point of the cube.




As for the part where you need to add a margin, a simple fix that I thought of (and should be easy to make using python) is to duplicate the plane and scale it up. There are no settings in the particle system that allows you to create a margin to my knowledge that doesn't involve using some sort of painting.