Calculate pneumatic cylinder dimensions from work done

I have a project for which I need a pneumatic cylinder to impart an impact force in such a way that work-done/energy is 4.5 Joules, and the input pressure is 10 bar. How can I solve this so that I can derive bore & stroke of piston?

It is possible to calculate this under the assumption that all of the energy from the expansion goes into mechanical energy instead of being lost to heat transfer through the walls. In this case the process is called adiabatic, and the work done is given by $$W = P_0V_0^\gamma\frac{V_f^{1-\gamma}-V_0^{1-\gamma}}{1-\gamma},$$ where $$\gamma=\frac{C_p}{C_v}$$ is the ratio of the specific heat capacities of the gas.
If the cross-sectional area (bore) is given by $A$ and the initial and final lengths of the piston (stroke) are $\ell_0$ and $\ell_f$, then the volume can be written as $V_0=A\ell_0$ and $V_f=A\ell_f$. Plugging this in gives $$W=P_0A\frac{\ell_0 - \frac{\ell_0^\gamma}{\ell_f^{\gamma-1}}}{\gamma-1}.$$ If the gas you are using is air at room temperature, then gamma is given by $$\gamma=\frac{1.005}{0.718}=1.400.$$