Create pdf from image with original proportions

Hi.
Who could help me to solve my problem?
We are using the Aspose Imaging to create pdf from image. If we set PdfOptions.PageSize to any non empty value (A4 size for example) the whole page is filled with a image without observing the original proportions of width and height.
Is it possible to create pdf with required page size and with image zoomed in this size with original proportions?
Regards,
Sr. Software dev Andrey Demyanov, BluecieloECM solutions.

@AndreyDemyanov

Can you please share the source file along with generated PDF and used sample code reproducing the issue.

Hi. This is my sample: Sample.zip (68.7 KB)

Regards,
AndreyD

@AndreyDemyanov

I have worked with sample code and files shared. This is not an API issue. The image size is different and the size of page you are setting is different. It will certainly change the aspect ratio of the image w.r.t new page size in PDF. You may use the suggested sample code on your end.

    private static void DoImage(string SourceName, string TargetName)
    {
        using (var image = Aspose.Imaging.Image.Load(SourceName))
        {
            Aspose.Imaging.ImageOptions.PdfOptions exportOptions = new Aspose.Imaging.ImageOptions.PdfOptions();
            Aspose.Imaging.SizeF pSize = new Aspose.Imaging.SizeF(image.Width, image.Height); // A4 portret

            //                Aspose.Imaging.SizeF pSize = new Aspose.Imaging.SizeF((float)595.3, (float)841.9); // A4 portret
            exportOptions.PageSize = pSize;

            image.Save(TargetName, exportOptions);
        }
    } 

Generated.pdf (57.7 KB)

Hi @mudassir.fayyaz.
Please see attached image. This is what I want to get. Sample1.jpg (2.7 KB)

Regards,
AndreyD

@AndreyDemyanov

In this scenario, I suggest you to please use Aspose.PDF for .NET on your end. Please visit this documentation link for your convenience. You can set the size as per your convenience.

A lot of thanks for your time. You have confirmed my assumptions that we need to switch to the Aspose.Pdf.

Regards,
AndreyD

@AndreyDemyanov

You are always welcome.