Adding image in its original size

Hi,

I am using aspose.pdf . I am adding an image to my document without applying any height or width scaling factors to get its original size in the document. But when I saw in the document that the image size is not in its exact dimensions. but when I copy the same image and paste it in the paint, I am able to see the original dimensions.

below is the code which I am using,

Aspose.Pdf.Generator.Pdf imagePdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section mainSection = imagePdf.Sections.Add();
Aspose.Pdf.Generator.Image myImage = new Aspose.Pdf.Generator.Image();
myImage .ImageInfo.File = path;
myImage .ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;
mainSection.Paragraphs.Add(myImage );


Please suggest the solution.

Thanks,
Jay

Hi Jay,
Thanks for your inquiry. Please note while image dimensions resides within page dimensions, it displayed in actual dimensions. If it exceeds than page dimension it is being trimmed according to page dimension, in that case you can either resize image to page dimensions or resize page dimensions to image size. Please check following code snippet for details. Hopefully it will serve the purpose. If there is any difference in my understanding and your requirements then please share the sample image and expected output document. So we will guide you accordingly.

Aspose.Pdf.Generator.Pdf imagePdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section mainSection = imagePdf.Sections.Add();
Aspose.Pdf.Generator.Image myImage = new Aspose.Pdf.Generator.Image();
myImage .ImageInfo.File = path;
myImage .ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;
// set image width equal to page width
//myImage.ImageInfo.FixWidth = mainSection.PageInfo.PageWidth;
//myImage.ImageInfo.FixHeight= mainSection.PageInfo.PageHeight;
Bitmap myimage = new Bitmap(path);
// set Page size according to Image width and height
mainSection.PageInfo.PageWidth=myimage.Width;
mainSection.PageInfo.PageHeight=myimage.Height;
mainSection.Paragraphs.Add(myImage );

Best Regards,