Aspose.Cells does not preserve image aspect ratio when converting to pdf format

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.

I realize this is a very old post, but we are seeing this same issue in version 24.5.0 of the Cells library.

Excel template with image smart maker saved as excel: image.png (18.5 KB)

The same Excel template with image smart maker saved as PDF:
image.png (17.7 KB)

Please advise.

@TimothyBlue
Would you like to provide your sample file and executable test code? We will check it soon.

AsposeExcelPDF.zip (21.6 KB)

Here is the example code to see this issue.

@TimothyBlue,

I tested your scenario/case using your sample project, template Excel file and image file. It works Ok and I could not spot significant difference. I guess you might not be using 100% zoom when viewing into Adobe acrobat reader. It seems images in both Excel file and PDF are same, see the screenshot for your reference.
sc_shot1.png (115.5 KB)

Please also find attached the output Excel file and PDF file for your reference.
files1.zip (33.9 KB)

If you still think it is an issue with Aspose.Cells, kindly do provide more details and output files for reference. We will check your issue soon.

I cannot see the files.

When I click on then I see: “Sorry, this file is private. Only visible to topic owner and staff members.”

@TimothyBlue,

Since you are not the owner of the issue, you may not be able to download the attachments in this thread. It would be better for you to start a new thread or create a new one and ask us to provide the attachments (please refer to this thread in your new thread). We will then provide you with the attachments in your new thread.