With PD4ML v4 you’ve got two options: to use PD4ML v3 API wrapper (org.zefer.pd4ml), which translates v3 API calls to v4, or to use PD4ML v4 API (com.pd4ml). Both packages have PD4ML class.

In v4 API you may specify base URL in renderHTML() params. See JavaDoc.

In v3 API wrapper the API call pd4ml.render(reader, out, params.destDir.toURI().toURL()); should just work.