PD4ML 3.12.0-SNAPSHOT API Documentation
PD4ML converts HTML and CSS to PDF (and to images) from Java applications, servlets and JSP pages.
Getting started
PD4ML is the converter. Configure an instance, then call one of its
render(...) methods with the HTML source and the stream the PDF is written to:
PD4ML pd4ml = new PD4ML();
pd4ml.setPageSize(PD4Constants.A4);
pd4ml.setPageInsetsMM(new Insets(20, 10, 10, 10));
pd4ml.setHtmlWidth(950);
OutputStream out = new FileOutputStream("result.pdf");
try {
pd4ml.render(new URL("http://example.com/page.html"), out);
} finally {
out.close();
}
Main classes
PD4ML- The converter: page format and insets, fonts (
useTTF), headers and footers, security, bookmarks, PDF merging, output to PDF or images. PD4Constants- Page formats, permission flags and the other constants the API takes.
PD4PageMark- Page header and footer definitions for
PD4ML.setPageHeader(org.zefer.pd4ml.PD4PageMark)andPD4ML.setPageFooter(org.zefer.pd4ml.PD4PageMark). PD4Document- An existing PDF document, opened from bytes or a stream; the operations are in
PD4DocumentBase. PD4ProgressListener- Receives progress and status messages of a conversion
(
PD4ML.monitorProgress(org.zefer.pd4ml.PD4ProgressListener)). PD4Cache,ResourceCache- Caching of the images, style sheets and fonts loaded during conversions.
ResourceProvider,DynamicImageHandler,CookieManager- Extension points for loading resources from custom locations and for generated images.
Editions
The API is the same in every edition (Standard, Pro, DMS and their evaluation versions); the editions differ in the features behind it. The evaluation versions add a watermark to the output.
Servlet containers
The same PD4ML jar runs in javax.servlet containers (Java EE, Tomcat 9 and older) and in jakarta.servlet
containers (Jakarta EE 9 and newer, Tomcat 10 and newer):
PD4ML.useHttpRequest(Object, Object) and
PD4ML.useServletContext(Object) take the objects of either API and recognize it at
run time. The JSP tag library comes in one jar per servlet API.
JSP tag library
The pd4ml JSP tags are documented separately: PD4ML JSP Tag Library.
| Package | Description |
|---|---|
| org.zefer.cache | |
| org.zefer.pd4ml | |
| org.zefer.pd4ml.npdf |