Aspose Pdf format does not preserve image aspect ratio

I am using Aspose Cells 7.0.2.0 to create an Excel document which will contain some map images. The document is to be saved to pdf format. However, the map images are stretched horizontally by about 5-10%, which degrades the value of the map.

The code to reproduce this problem is simple:

      // Get Map Bitmap resource...
Bitmap image = Properties.Resources.MapImage;
System.IO.MemoryStream imageStream = new System.IO.MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Bmp);

// Create Aspose worksheet and add Map Bitmap as picture...
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets.Add("Map Image");
int index = sheet.Pictures.Add(0, 0, imageStream);
//var picture = sheet.Pictures[index];
//picture.WidthScale = 92;

String outputPath = "MapImageTest.pdf";
workbook.Save(outputPath, SaveFormat.Pdf);

System.Diagnostics.Process.Start(outputPath);
The resulting pdf does not properly render the map circle as seen in the attachment.
If I enable the picture.WidthScale = 92; line in the above example, the map is better.
Is this a bug or is there a standard way to maintain proper aspect ratio that will work for all images?
I look forward to hearing from you.
Regards,
Sig Isaac
 

Hi,

Thanks for your posting and considering Aspose.Cells for .NET.

Please also attach your source/input xls file which you are trying to convert to PDF using Aspose.Cells for .NET.

Please also test your issue with the latest version:
Aspose.Cells for .NET v7.0.3.2

I am not using a source/input xls file -- I am creating the Aspose Workbook dynamically in code, adding an image, then saving it with FileFormat.Pdf, as you can see in the example code I included in my original post.

The example code uses a bitmap resource of a sample map image with a circle. I will attach that for your reference. It is very important that the circle in the image appears truly round rather than a slightly squashed oval.

I can send you a simple VS project to illustrate the problem if it is not already clear to you.

Hi,

Thanks for your illustrating it.

Yes, please also provide sample project which you are using to add the image in the workbook. It will help us look into this problem.

Please try the attached project that illustrates the problem.

Please note that you may have to change the reference to Aspose.Cells in the project References list.

Hi,
Thanks for your sample code. We have logged this issue in our database. We will look into it and update you asap.

This issue has been logged as CELLSNET-40137.

Hi,

Please try the fixed version: v7.0.3.3. Your issue should be fixed in it now.


I downloaded and referenced version 7.0.3.3 but am unable to compile. I get the following error in VS 2010 SP1:

Error 1 The type or namespace name 'Aspose' could not be found (are you missing a using directive or an assembly reference?) C:\Sandbox\PCensus\PCFramework.NET\PdfMapImageTest\Form1.cs 10
v

If I switch back to 7.0.3.0 I do not have a problem.

Please advise,

Sig Isaac

Hi,

The fix that I sent is compiled on .NET framework2, it will work on any .NET framework version => 2 (e.g 2.x, 3.5, 4.x) except .NET client profile version. What is your project’s target .framework set in VS.NET, if this is the case, we can provide you the client profile .net framework version accordingly.

Thank you.

Our project's target framework is set to ".NET Framework 4" with x86 as the platform target.
The file size of the Aspose.Cells.dll for version 7.0.3.3 that I got was 6,680,920 bytes. The previous version I had, 7.0.3.0, was 7,185,240 bytes. Is it possible that I got the wrong dll?
Please provide a link to the .NET client profile version for 7.0.3.3.
Regards,
Sig Isaacv

Hi,


Please find attached the client profile version and try it (if your project’s framework is client profile version (3.5, 4.0 etc.)).

Thank you.