printImage.setWidth(element.getWidth());
printImage.setScaleImage(ScaleImageEnum.getByName(scaleType));
printImage.setHorizontalAlignment(HorizontalAlignEnum.getByName(horizontalAlignment));
printImage.setVerticalAlignment(VerticalAlignEnum.getByName(verticalAlignment));
FlyingSaucerXhtmlToImageRenderer renderer = new FlyingSaucerXhtmlToImageRenderer(getHtmlDocument(htmlContent), element.getWidth(), element.getHeight());
printImage.setRenderer(renderer);
if (printImage.getScaleImageValue() == ScaleImageEnum.REAL_HEIGHT || printImage.getScaleImageValue() == ScaleImageEnum.REAL_SIZE) {
printImage.setHeight(renderer.getComputedSize().height);
} else {
printImage.setHeight(element.getHeight());
}
return printImage;
}