Why Convert Image to PDF?Since 1993 PDF format had been introduced by Adobe Systems it has rapidly become the number one universal document format on the internet.
1. Compatible Across platforms
2. Compact & Small
3. Can be created from any source document/application
4. Securable, avoid people from modifying & redistributing your work
6. Easy and quick to create when using the right software
7. Software to view PDF Files is completely free
8. Viewable within most web-browsers
9. PDF Files meet legal document requirements.
10. Compatible with modern portable reader systems
With the Top 10 advantages of PDF, you should be clear that why we convert files from image to PDF.
How to Use C# Convert Image to PDF?In this article, I will introduce you a solution of how to use C# fast converting files from image to PDF. First, please allow me to introduce you a .NET component,
Spire.Doc for .NET, which is available to use C# convert files from all images to PDF. Download Spire.Doc for .NET and install on your system. With the code below, you will soon learn how to use your C# to convert image to PDF.
Convert Image to PDF with C#
[C#]
using System;
using Spire.Pdf;
using Spire.Pdf.Graphics;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
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);
doc.SaveToFile("test.pdf"

;
doc.Close();
}
}
}
Related Articles:•
How to Use C# Convert HTML to PDF•
How to Use C# Convert Doc to PDF•
How to Use C# Convert Text to PDF•
How to Use C# Convert XML to PDF