With pageSize you specify target document (paper) format.
With htmlWidth you define “virtual HTML browser” frame width to be mapped to the chosen paper Format width.

So if your images are cut right side, try to increase htmlWidth parameter correspondingly (to scale down the content).

If the image width is not known, there is a handy pd4ml.adjustHtmlWidth() API call (but in the case a document scale will depend on the content, which is not always desired)