When I use WorkSheet.SheetToImage and set left, right, top and bottom margins all equal to zero, there is no whitespace around the image. However, when I use WorkSheet.SheetToImageByPage, I always get white space around the image regardless of what the margins are set to. Attached is some example code.
Please try to change your code as following, hopefully it will fit your need.
Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets;
ws.PageSetup.CenterHorizontally = false;
ws.PageSetup.CenterVertically = false;
ws.PageSetup.LeftMargin = 0;
ws.PageSetup.RightMargin = 0;
ws.PageSetup.TopMargin = 0;
ws.PageSetup.BottomMargin = 0;
Bitmap bitMap = ws.SheetToImage();
Bitmap bitMaps = ws.SheetToImageByPage();
This doesn’t solve the issue. I need the image of the worksheet without any white space around it. The work around you suggested just moves the worksheet image to the left upper right with all the white space on the right and lower part of the image.
Well, this is how the SheetToImageByPage method works. If you need to fetch only data without white space around it, you should use SheetToImage method instead. Actually the SheetToImageByPage method renders the images based on the default page settings. Anyways, we need to check and analyze if the SheetToImage method should support in other way or not. We will get back to you soon.
We have added your feature request to log into our issue tracking system with an issue id: CELLSNET-12630. We will be on it soon. We might add a property for ImageOrPrintOption to control/implement your desired results for SheetToImageByPage method.
<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p>
Thank you for considering Aspose.
Please try the attached latest version of Aspose.Cells. We have added IsImageFitToPage property to ImageOrPrintOptions as per your requirement.
Thank You & Best Regards,