Some images are rotating in the PDF while others are working fine

Hi,

We are experiencing an issue where some images are rotating in the PDF while others are working fine. We are generating PDFs by adding content such as text and images. While adding large-dimension images, they are rotated. The same code snippet works fine for small-dimension images. Even facing the issue with 1644 kb image.
Testing with Aspose 21.4 version.

I extracted the code working with the template into a minimal console application and able to reproduce the problem with the template.

Sample console application: Aspose.zip (9.5 MB)

Template: Sample_Template.docx - Placed in the above zip file
Images: Placed in the above zip file both working and not working image - image folder.

  • sample2.jpg: NOT working image

  • sample3.jpg: working image.

Instruction to run the sample console application:

  • Go to the Main.java,

  • Verify the ‘fileTemplate’ path of the template and ‘bImage’ path of the image.

  • Run the Main.main().

Is there any restriction of image dimensions and what is the minimum and maximum image dimensions or size aspose support.

Is there a way to correct that in the letter template standpoint or in the code standpoint and please let us know the expected behavior as per the Aspose product.

Thank you

@jcash_casenetllc_com I have managed to reproduce the problem with the following simple code:

Document doc = new Document("C:\\Temp\\Sample_Template.docx");
// Get the placeholder shape.
Shape s = (Shape)doc.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_FIRST)
        .getChild(NodeType.SHAPE, 0, true);
// Set the image.
s.getFill().setImage("C:\\Temp\\sample2.jpg");
// Save the output.
doc.save("C:\\Temp\\out.docx");

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27309

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi,

We would appreciate it if you could inform us of the Aspose version that resolved the issue.

Thank you

@jcash_casenetllc_com Sure, we will be sure to keep you updated and let you know once the issue is resolved or we have more information for you.

Hi,

Is there any restriction of image dimensions and what is the minimum and maximum image dimensions or size aspose support.

Is there a way to correct that in the letter template standpoint or in the code standpoint and please let us know the expected behavior as per the Aspose product.

We would appreciate it if you could inform us if the Aspose version that resolved the issue.

Thank you

@jcash_casenetllc_com We have completed analyzing the issue and concluded this is not a bug. We’ve checked the ms.7z (6.7 MB) output in Word and this is the same as in Aspose.Words.
The problem is different EXIF in these images:
image.png (4.5 KB)
Seems Word does not consider it when renders JPEG.

Regarding images dimensions, Aspose.Words itself does not process images, images are processed by JAI in Java version and by System.Drawing or SkiaSharp in .NET version. So You should consider restrictions of these libraries when work with images.
Regarding maximum shape size in MS Word it is limited to 1584 points.