In PDF, we can insert image to make the contents be colorful and attractive. And it is possible that one image is one PDF document, especially in PDF form. Therefore, we may need to convert image to PDF sometimes.

Except Adobe Acrobat, which is the professional tool to manipulate PDF, there are lots of converters which specialize in converting image to PDF online. The tools are easy to use and the developers will show the guide about how to use the converters. Choose the image you want to convert and then follow the guide. You can get the PDF documents soon.

For programmers, they may pay much attention on how to develop a good tool to convert image to PDF. It is wonderful that some programmers share their methods on forum, blog or article websites. Also, readers can give their suggestions, which can make the program be better.

After reading many articles in this aspect and suggestions by others, I want to share my own program.

The following code shows how to convert image to PDF by using C#.


In this method, I use one third party add-in, Spire.PDF.


PdfDocument doc = new PdfDocument();

            PdfSection section = doc.Sections.Add();          

            PdfPageBase page = doc.Pages.Add();

            PdfImage image = PdfImage.FromFile("test.png");


            float widthFitRate = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width;

            float heightFitRate = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height;

            float fitRate = Math.Max(widthFitRate, heightFitRate);

            float fitWidth = image.PhysicalDimension.Width / fitRate;

            float fitHeight = image.PhysicalDimension.Height / fitRate;


            page.Canvas.DrawImage(image, 0, 0, fitWidth, fitHeight);



In addition, I find that the developers of Spire.PDF release a small tool, Spire PDF Converter, which can be used to convert various format documents to PDF. During converting, we can encrypt and add watermark during converting. It is great that the beta version is free. If you want to convert documents to PDF, you can try to use it.