<< back
PD4ML document imagesPD4ML supports conversion to PDF of the following image formats: JPEG, GIF, PNG, popular BMP species and fax-specific TIFF.In most of the cases source HTML document needs no adjustments for correct image processing. If for some reason images are missing in the resulting PDF, the first diagnostic step is to enable debug info output and to inspect application console or server's log. pd4ml.enableDebugInfo();PD4ML supports the following image references: 1. Relative path. Image is located in the same or a neighbor directory where
the main document is. 2. Absolute path. Not recommended. A quick hack is to change the path to a relative one or to extend the URL to a fully-specified one: http://localhost/webappname/images/logo.gif (would only work if the server does not host multiple domains, otherwise it must be a real server name instead of localhost). A more sophisticated approach is to pass ServletContext instance to pd4ml.useServletContext() method or HttpServletRequest/Response instances to pd4ml.useHttpRequest() and to let PD4ML to try to resolve the web application paths. 3. Fully specified URL.<img src="http://pd4ml.com/i/logo.png"> Potential problems can happen in web application scenarios, when the server, where PD4ML is, cannot resolve URL server name to IP address or has no routing to the remote server. Also PD4ML oficially does not support HTTPS protocol. In most of the cases HTTPS references to image work. There is a number of application servers (i.e. Weblogic, WebSphere) implement their own SSL layer, not derived from the standard JDK classes. In the case ClassCastExceptionon is thrown. A possible workaround is PD4ML custom resource loaders.
4. data protocol makes possible to embed image bytes into HTML document
text. The "reference" starts with "data:image/gif;base64," prefix,
followed by base64-encoded image bytes.
5. Proprietary java protocol allows to extract image from Java application resources using
a variety of Java ClassLoaders. Internally PD4ML tries to load an image, referenced that way, in three attempts. ... resource = Thread.currentThread().getContextClassLoader().getResource(resourcePath); ... resource = this.getClass().getClassLoader().getResource(resourcePath); ... resource = callingClass.getClassLoader().getResource(resourcePath); ... |