We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

LINQ Reporting Engine HTML images / .jpg dpi

We are using the LINQ Reporting Engine and when merging HTML with images to generate a word document .jpg files at 96 dpi are being exported to fit the word page. However .jpg at 72dpi are NOT fitting the page.

In Linq image -fitSize is not working as expected the response stated:

LINQ Reporting Engine uses the size of the image in inches (not pixels) while fitting the size of the corresponding text box so the image looks in MS Word bigger than in an image viewer (that does not consider an image resolution). This is by design.
Please change the DPI to standard 96 DPI.

So my question is, in the calculations that LINQ uses to determine the size of the image is it ALWAYS assuming 96dpi or does it look at the OS configuration?

If it is looking at the OS configuration we cannot just assume we need to convert the images to 96dpi so that they fit properly.

Also shouldn’t you be using the dpi of the jpg file that is being sized to calculate? We will have to support large resolution images at 300dpi, so we can’t resize the jpg file itself which would lose resolution.


Thanks for your inquiry. We are working over your query and will get back to you soon.


Thanks for your patience. LINQ Reporting Engine does consider DPI of an image. It has nothing to do with OS configuration.

The hint to use 96 DPI was addressed in other thread. The issue was image looks different when inserted by LINQ Reporting Engine and when opened in an image viewer that ignores DPI of an image and uses 96 DPI by default.

The point is that LINQ Reporting Engine uses the size of an image in inches (that is, the size in pixels divided by DPI) rather than the size in pixels while fitting. So if the same bitmap (that is, a 2D array of pixels) saved into two different files using different DPIs, then images inserted by the engine from these files will have different sizes (because their sizes in pixels are the same but sizes in inches are different). MS Word does the same when inserting such images, which can be easily checked.

We suggest you please use fitSizeLim switch instead of fitSize. Please refer to the following article for more detail.
Inserting Images Dynamically

Thank your for your quick reply.

However, we are not inserting images into the document using the IMAGE we are inserting HTML that contain img tags that reference local files.

I ran a test merging HTML using LINQ Reporting Engine that references 4 files. These were all of the same image only:

  • The first image is 600 x 400 pixels / 8.333 x 5.556 inches at 72 dpi.

  • The second image is 600 x 400 pixels / 6.250 x 4.167 inches at 96 dpi.

  • The third image is 1200 x 800 pixels / 12.500 x 8.333 inches at 96 dpi.

  • The fourth image is 1875 x 1250 pixels / 6.250 x 4.167 inches at 300 dpi.

    <p>72 DPI</p>
    <p><img src=“c:\TestImg_72dpi.jpg” /></p>
    <p> </p>
    <p><img src=“c:\TestImg_96dpi.jpg” /></p>
    <p> </p>
    <p>96DPI 200% size</p>
    <p><img src=“c:\TestImg_96dpi_200%.jpg” /></p>
    <p> </p>
    <p><img src=“c:\TestImg_300dpi.jpg” /></p>
    <p> </p>

The space on the page where the images are being inserted is 5.28" wide.

  • The 1st image did not fit properly on the page.
  • However the 2nd and 3rd did.
  • And the 4th at 300 dpi scaled up by 313%

If you look at the document generated in MS Word:
Image 1:

  • Original Width: 8.33", Original Height: 5.56"
  • Scaled Width: 6.25", Scaled Height: 4.17" (specified in docx file as EMUs)
  • scaled 75% (should have scaled down about 63% to fit 5.28")

Image 2:

  • Original Width: 6.25", Original Height: 4.17"
  • Scaled Width: 5.28". Scaled Height: 3.52" (specified in docx file as EMUs)
  • scaled 84%

Image 3:

  • Original Width: 12.5", Original Height: 8.33"
  • Scaled Width: 5.28". Scaled Height: 3.52" (specified in docx file as EMUs)
  • scaled 42%

Image 4:

  • Original Width: 6.25", Original Height: 4.17"
  • Scaled Width: 13.02". Scaled Height: 19.53" (specified in docx file as EMUs)
  • scaled 313%

Looking at the document.xml in the generated .docx file:

EMU = pixels * 914400 / Resolution
pixels = EMU * Resolution / 914400

The first picture (72 dpi) has the following in document.xml:
<a:xfrm><a:off x=“0” y=“0” /><a:ext cx=“5715000” cy=“3810000” /></a:xfrm>
width: 5715000 EMUs = 6.25 inches
height: 3810000 EMUs = 4.17 inches

The second picture has:
<a:xfrm><a:off x=“0” y=“0” /><a:ext cx=“4826000” cy=“3217333” /></a:xfrm>
width: 4826000 EMUs = 5.28 inches
height: 3217333 EMUs = 3.52 inches

The third picture has scaled correctly:
<a:xfrm><a:off x=“0” y=“0” /><a:ext cx=“4826000” cy=“3217333” /></a:xfrm>
width: 4826000 EMUs =
height: 3217333 EMUs = pixels * 914400 / Resolution

The fourth picture at 300 dpi LINQ did not attempt to resize and calculated the width and height using 96 dpi instead of the original 300 dpi:
<a:xfrm><a:off x=“0” y=“0” /><a:ext cx=“17859375” cy=“11906250” /></a:xfrm>
width: 17859375 EMUs = 1875 pixels * 914400 / 96 (NOT the 300 dpi of the image)
height: 11906250 EMUs = 1250 pixels * 914400 / 96 (NOT the 300 dpi of the image)

So there seems to be a calculation error when sizing an image to fit the MS Word page when the image isn’t at 96dpi. If I insert the same images into the word document using insert image they insert and scale properly.


Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Your input HTML document and images.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

As you have requested we have created a sample application that demonstrates the problem and attached it with the results in the uploaded .zip file.

At the top level in the zip is a README file with details on how to build and run the sample.

Also at the top level are the following folders:
data - contains the input document, generated document, and the inputs.
lib - contains the aspose words jdk
src - contains the source for the example

In the data folder:

  1. exampleOut.docx - the generated document showing the problem.
  2. exampleDoc.docx - the input document
  3. exampleData.xml - the input xml data containing the HTML
  4. 4 .jpg files referenced from the HTML

The exampleOut.docx generated document has the 4 image files:

  1. TestImg_72dpi.jpg - The height and width not properly set to fit the page
  2. TestImg_96dpi.jpg - This image was properly set to fit the page
  3. TestImg_96dpi_200%.jpg - This image properly fits the page
  4. TestImg_300dpi.jpg - The height and width was set 313% larger than the original file size

NOTE: I uploaded the .zip file twice but it isn’t appearing. It is 10.4 MB in size. So I created a .zip without the Aspose Words jar file in the lib folder. imagedemo wo Aspose Words.zip (927.8 KB)


Thanks for sharing the detail. We are investigating this issue and will get back to you soon.


Please note that Aspose.Words mimics the behavior of MS Word. Its mean that if you open the HTML in MS Word, you will get the same output as of Aspose.Words.

In this case, you are inserting the HTML into document using LINQ Reporting engine. The output is not correct according to MS Word’s behavior. We have logged this problem in our issue tracking system as WORDSNET-16634. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information about your query.

I have manually created the word document with the expected output showing all 4 images being scaled to fit the page regardless of the dpi of the image and uploaded it.

expectedOut.zip (466.5 KB)

Thank You!


Thanks for sharing the document. We will inform you via this forum thread once there is any update available on this issue.

A post was split to a new topic: Insert HTML using LINQ Reporting Engine