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

Free Support Forum - aspose.com

Converted image size is varing compared to the original image

When I am converting a file to PDF the size of the image in the file is not of the actual uploaded size. How to get the actual loaded image size when converted.


Which file format (DOC/DOCX, XLS/XLSX, PDF, PPT/PPTX, etc.) you are using? Could you please share your sample file and paste your sample code that you are using here. We will check your issue and help you through.

PS. please zip the file(s) prior attaching here.

I am putting a BMP filebmp sample RajIDSS#'18 -.zip (6.5 MB)


Thanks for the image file.

You have not shared details on which file format you are using. Also, you did not share your sample code that you are using. Please provide required details and resource file. This will help us to evaluate your issue on our end.

We want to convert to pdf

I assume you are converting it to PDF via Aspose.Words API. I am moving your thread to respective forum where one of our fellow colleagues will assist you soon.

Any update on this

@rvarjun15 You can do this with Aspose.Words.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertImage("C:\\Path\\to\\your\\project\\bmp sample RajIDSS#'18 -.bmp.bmp");

I am getting the converted PDF file. That is not my problem. The size of the actual image when converted to PDF is changing. I want the image size to be same as that provided in the .bmp file

@rvarjun15 Please consider the following code.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Your image data.
int imageWidth = 2480;
int imageHeight = 3229;
int imageResolution = 150;

PageSetup ps = builder.getPageSetup();
ps.setPageWidth(ConvertUtil.pixelToPoint(imageWidth, imageResolution));
ps.setPageHeight(ConvertUtil.pixelToPoint(imageHeight, imageResolution));

builder.insertImage("C:\\Path\\to\\your\\project\\bmp sample RajIDSS#'18 -.bmp.bmp", 0, RelativeHorizontalPosition.MARGIN, 0, RelativeVerticalPosition.MARGIN, imageWidth, imageHeight, WrapType.SQUARE);