You need to decrease parameter value of setHtmlWidth() to match HTML document content width.

adjustHtmlWidth() is intended to automatically decrease the value. (in other words to cut blank space right side) But if your document has elements with width=100% attributes (or for example

elements), that would mean there is no blank space – nothing to cut.

I assume you did not call fitPageVertically()