image export: pixels to points

This commit is contained in:
Bernaldo Mihasi 2022-03-18 16:55:41 +02:00
parent 3101cf0e42
commit ba55881830
1 changed files with 3 additions and 3 deletions

View File

@ -171,11 +171,11 @@ public class WordBuilder {
if (readers.hasNext()) {
ImageReader reader = readers.next();
reader.setInput(iis);
int pageWidth = Math.round(mainDocumentPart.getDocument().getBody().getSectPr().getPgSz().getW().intValue() / (float)20);
int imageWidth = reader.getWidth(0);
int pageWidth = Math.round(mainDocumentPart.getDocument().getBody().getSectPr().getPgSz().getW().intValue() / (float)20); // dxa to points
int imageWidth = Math.round(reader.getWidth(0) * (float)0.75); // pixels to points
int width = Math.min(imageWidth, pageWidth);
int pageHeight = Math.round(mainDocumentPart.getDocument().getBody().getSectPr().getPgSz().getH().intValue() / (float)20);
int imageHeight = reader.getHeight(0);
int imageHeight = Math.round(reader.getHeight(0) * (float)0.75);
int height = Math.min(imageHeight, pageHeight);
run.addPicture(image, format, fileName, Units.toEMU(width), Units.toEMU(height));
}