I am forming a pdf file. When generating a file locally in Idea - pdf is generated correctly. And if you send this file to MiniO S3 - instead of Russian letters, the symbols '#' are generated
I myself tried to specify the encoding explicitly via metadata.setContentType ("application / pdf; charset = utf-8"); Does not help :-(
Now I'm more inclined to add fonts. Tell me how I can add this to the existing code.
Thank you in advance!
@SneakyThrows
public byte[] createDocument(PaymentInstructionModel model) {
WordprocessingMLPackage word = Docx4J.load(new ClassPathResource("template.docx").getInputStream());
MainDocumentPart mainDocumentPart = word.getMainDocumentPart();
Map<String, String> variables = objectMapper.convertValue(model, new TypeReference<>() {});
mainDocumentPart.variableReplace(variables);
ByteArrayOutputStream os = new ByteArrayOutputStream();
Docx4J.toPDF(word, os);
return os.toByteArray();
}
byte[] document = documentService.createDocument(model);
String key = String.format("%s/%d-%d-%d_Платёж_№%s.pdf",
event.getPaymentNumber(),
event.getPaymentDate().getYear(),
event.getPaymentDate().getMonthValue(),
event.getPaymentDate().getDayOfMonth(),
event.getPaymentNumber());
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(document.length);
amazonS3.putObject(S3Buckets.CLIENT_PAYMENT_PDF_BUCKET, key, new ByteArrayInputStream(document), metadata);