pdfHTML: Added full background support
In release version 3.0.3 of the pdfHTML add-on, we have added full support for the background property, this includes HTML as well as background-related CSS properties.
Features like multiple backgrounds (background: url(“image1.jpg”),url(“image2.jpg”) ), background-repeat, background-size, background-position(X and Y) and background-box were added.
You can consult the w3 website https://www.w3.org/TR/css-backgrounds-3/#backgrounds for more information, and a full list of the supported background tags and CSS properties.
In addition, the existing background CSS property support was thoroughly tested and some bugs were fixed.
As a highlighted example, below is a screenshot of some simple HTML where a div element has a CSS declared multi-image background:
In previous versions, pdfHTML would select the first image only, now with the new release a result is shown with both images present.
The pdfHTML code for generating the HTML remains the same:
JAVA
public void generatePdf(String src, String dest) throws IOException {
//A converter properties with a base uri set
// to point to the directory where images can be retrieved
ConverterProperties converterProperties = new ConverterProperties().setBaseUri(RESOURCES_DIR);
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));
try (FileInputStream fileInputStream = new FileInputStream(src)) {
HtmlConverter.convertToPdf(fileInputStream, pdfDocument, converterProperties);
}
}
C#
public void GeneratePdf(string src, string dest)
{
//A converter properties with a base uri set
// to point to the directory where images can be retrieved
var properties = new ConverterProperties().SetBaseUri(RESOURCES_DIR);
var pdfDocument = new PdfDocument(new PdfWriter(dest));
var fileInputStream = new FileStream(src, FileMode.Open);
HtmlConverter.ConvertToPdf(fileInputStream, pdfDocument, properties);
}