I’ve got a HTML file with flexbox layout that looks fine in a browser but when rendered to PNG by aspose, the layout is nowhere near proper. I’m using the java API to force the output to a specific size, that same size is also what’s configured in the HTML file.
In the attached zip you’ll find the HTML file I’m using. It passes HTML validation rules and renders properly in every browser I’ve checked: Chrome, Firefox, Edge
There are also two images: one with the java code constraining the size of the image to a given dimension, one without. You’ll see there is different behavior in both images.
va4.zip (7.6 KB)
Here’s the code I’m using to do the rendering.
void gen_it() throws FileNotFoundException, Exception {
// Initialize License Instance
com.aspose.html.License license = new com.aspose.html.License();
// Set license from Stream
license.setLicense(this.getClass().getClassLoader().getResourceAsStream("licenses/Aspose.HTML.Java.lic"));
HTMLDocument doc = new HTMLDocument("/opt/aspose-test/va4/template.html");
ImageSaveOptions saveOpts = new ImageSaveOptions(ImageFormat.Png);
saveOpts.setSmoothingMode(SmoothingMode.None);
saveOpts.getText().setTextRenderingHint(TextRenderingHint.SingleBitPerPixelGridFit);
Page page = new Page();
page.setSize(new Size(Length.fromPixels(240), Length.fromPixels(128)));
PageSetup pageSetup = new PageSetup();
pageSetup.setAnyPage(page);
saveOpts.setPageSetup(pageSetup);
saveOpts.setBackgroundColor(Color.getWhite());
FileCreateStreamProvider fileCreateStreamProvider = new FileCreateStreamProvider("/opt/aspose-test/va4", "output");
Converter.convertHTML(doc, saveOpts, fileCreateStreamProvider);
}
Am I doing something improperly in either the template or the java code? Is this not HTML that Aspose will be able to convert?
Thanks