Inline inline = imagePart.createImageInline(null, null, 0, 1, false);
Inline inline;
Long cx = (box.getStyle().valueByName(CSSName.WIDTH) == IdentValue.AUTO) ? null :
UnitsOfMeasurement.twipToEMU(box.getWidth());
Long cy = (box.getStyle().valueByName(CSSName.HEIGHT) == IdentValue.AUTO) ? null :
UnitsOfMeasurement.twipToEMU(box.getHeight());
if (cx == null && cy == null) {
inline = imagePart.createImageInline(null, e.getAttribute("alt"), 0, 1, false);
}
else {
if (cx == null){
cx = imagePart.getImageInfo().getSize().getWidthPx() *
(cy / imagePart.getImageInfo().getSize().getHeightPx());
}
else if (cy == null){
cy = imagePart.getImageInfo().getSize().getHeightPx() *
(cx / imagePart.getImageInfo().getSize().getWidthPx());
}
inline = imagePart.createImageInline(null, e.getAttribute("alt"), 0, 1, cx, cy, false);
}
Siilk wrote:Initially, the problem was in determining the proper place to take image modified size from, as it wasn't obvious how flying saucer keeps them.
So we tried to recalculate the dimensions manually, adjusting the actual formula depending on the type of the value sued in the original html. but that lead to the overcomplicated code that would've been hard to maintain.
Thus we had to rely on flyingsaucer's mechanics and UnitsOfMeasurement#twipToEMUAdditionally to convert the dimensions.
Unfortunately that was complicated by saucer not keeping any exact data for the image dimension that hasn't been resized in the html, and the fact that saucer has it's DocxRenderer initialized with DEFAULT_DOTS_PER_POINT = DEFAULT_DOTS_PER_PIXEL = 20. The latter is currently causing all the pt-based size units(inches, cms etc) being distorted.
Siilk wrote:On top of that, image resizing function CxCy#scale that is used in BinaryPartAbstractImage#createImageInline to scale image that has no set dimensions is using artificially set dpi value for images with no internally set dps.
This value is calculated depending on the current screen resolution which also contributes to the image scale distortion.
jason wrote:Siilk wrote:Initially, the problem was in determining the proper place to take image modified size from, as it wasn't obvious how flying saucer keeps them.
So we tried to recalculate the dimensions manually, adjusting the actual formula depending on the type of the value sued in the original html. but that lead to the overcomplicated code that would've been hard to maintain.
Thus we had to rely on flyingsaucer's mechanics and UnitsOfMeasurement#twipToEMUAdditionally to convert the dimensions.
Unfortunately that was complicated by saucer not keeping any exact data for the image dimension that hasn't been resized in the html, and the fact that saucer has it's DocxRenderer initialized with DEFAULT_DOTS_PER_POINT = DEFAULT_DOTS_PER_PIXEL = 20. The latter is currently causing all the pt-based size units(inches, cms etc) being distorted.
So Flying Saucer is using these values to calculate CSSName.HEIGHT and CSSName.WIDTH?
jason wrote:Is it using DEFAULT_DOTS_PER_POINT, DEFAULT_DOTS_PER_PIXEL, or both?
Note that there is a constructor:Using java Syntax Highlightingpublic DocxRenderer(float dotsPerPoint, int dotsPerPixel)Parsed in 0.014 seconds, using GeSHi 1.0.8.4
Does XHTMLImporter need to be using that?
jason wrote:Siilk wrote:On top of that, image resizing function CxCy#scale that is used in BinaryPartAbstractImage#createImageInline to scale image that has no set dimensions is using artificially set dpi value for images with no internally set dps.
This value is calculated depending on the current screen resolution which also contributes to the image scale distortion.
Are you talking about org.apache.xmlgraphics.image.loader.ImageInfo here?
Siilk wrote:As for if the XHTMLImporter should use explicit DocxRenderer(dotsPerPoint, dotsPerPixel), it's a tough question as there are probably a lot of code already depending on equal value for dpp and dppx, both inside the importer itself and in all those projects that are using it.
Siilk wrote:box.getWidth() and box.getHeight(). CSSName.HEIGHT and CSSName.WIDTH store unmodified original values of width and height, derived for html tag.
jason wrote:Hi, a couple of questions:
first, did you investigate how Flying Saucer actually uses DEFAULT_DOTS_PER_POINT and DEFAULT_DOTS_PER_PIXEL? I had a quick look (see earlier in this thread), but probably not as thoroughly as you
jason wrote:second, ignoring for the moment code which may already be depending on equal value for dpp and dppx, what do you think would be the correct thing for docx4j to be doing? we can analyse the impact of any change based on q1 above; if a fix seems warranted, the 3.0 release is a good time to be making the change.
jason wrote:Please correct me if I'm wrong, but since your contribution uses these "unmodified original values", we're currently not reliant on the values of DEFAULT_DOTS_PER_POINT and DEFAULT_DOTS_PER_PIXEL in Flying Saucer?
Siilk wrote: I guess rewriting that code to use Docx4jProperties.getProperty("docx4j.DPI", "96") to have a consistent project wide dpi value would be a good idea.
Users browsing this forum: Google [Bot] and 34 guests