To convert my html to pdf i use itext7's API convertToDocument, passing parameters the template's ByteArrayInputStream, the PDFDocument and convertProperties.
relevant code snippet:
HtmlConverter.convertToDocument(new ByteArrayInputStream(templateWritten), pdfDocument, converterProps);
As docs says, if I set baseURI of convertProperties there is no problem, but if I set PDF fonts this error shows up when the are many concurrent calls:
"Pdf indirect object belongs to other PDF document. Copy object to current pdf document.”
creation of convert properties
private ConverterProperties addResourcesForInitiative(String templateKey, FontProvider fontProvider) {
// CustomDefaultFontProvider cdfp = new CustomDefaultFontProvider();
ConverterProperties converterprops = new ConverterProperties();
// converterprops.setFontProvider(fontProvider);
converterprops.setBaseUri(ConfigurationManager.getParamValue("resource.path") + templateKey + "/resources/");
log.info("Properties for conversione are setted. Url of folder loaded " + converterprops.getBaseUri());
return converterprops;
}
the object is created each call before convertToDocument API
am I missing something?
thanks all for your help