Warm tip: This article is reproduced from serverfault.com, please click

CSS unsupported key issue in iText pdf conversion

发布于 2020-12-04 08:55:07

I'm trying to create a pdf file using iText in Java. My HTML consists of CSS bootsrap version v4.3.1. During the conversion, I'm getting an error like this ERROR c.i.s.c.p.s.CssParserStateController - The rule @-webkit-keyframes is unsupported. All selectors in this rule will be ignored. I'm trying with Java HTML to pdf conversion using iText 7.1.9 maven dependency. How can I avoid these errors or include this CSS tag?. Since it is loading from the bootstrap I can't change that. My Code:

ConverterProperties props = new ConverterProperties();
props.setMediaDeviceDescription(new MediaDeviceDescription(MediaType.PRINT));
props.setCssApplierFactory(new DefaultCssApplierFactory());
HtmlConverter.convertToPdf("input.html", new FileOutputStream("output.pdf"), props);
Questioner
Sonu
Viewed
0
Sonu 2021-03-06 16:44:51

I couldn't find any perfect solution to the above, but I updated my HTML by removing unwanted resources, and that works for me.