I am new to iText 7 and trying to convert HTML page with external CSS file. The code:
@RequestMapping(path = "/pdf/{id}")
public ResponseEntity<?> getPDF(@PathVariable Long id,
HttpServletRequest request,
HttpServletResponse response) throws IOException {
Visit visit = visitService.getById(id);
List<Service> services = serviceService.getServicesByVisit(visit);
WebContext context = new WebContext(request, response, servletContext);
context.setVariable("visitEntity", visit);
context.setVariable("services", services);
String orderHtml = templateEngine.process("invoice", context);
ByteArrayOutputStream target = new ByteArrayOutputStream();
ConverterProperties converterProperties = new ConverterProperties();
converterProperties.setBaseUri("http://localhost:8080");
HtmlConverter.convertToPdf(orderHtml, target, converterProperties);
byte[] bytes = target.toByteArray();
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=invoice.pdf")
.contentType(MediaType.APPLICATION_PDF)
.body(bytes);
}
The PDF file is generated correctly with the external CSS style, but I also get some exceptions that do not stop the application.
The exceptions are: java.lang.IllegalArgumentException: Unsupported pseudo css selector: :-moz-placeholder and java.lang.IllegalArgumentException: Unsupported pseudo css selector: :-ms-input-placeholder
Thank you in advance!