New to Telerik Document Processing? Download free 30-day trial

Create Pdf from Image

Product Version Product Author
2022.2.613 RadPdfProcessing Dimitar Karamfilov

Description

The example is showing how to create a PDF file by using an image.

Solution

In this example you will create a brand new PDF document, add a page to it, and draw the image using the FixedContentEditor.

// If you are working in a .NET Core application, you will need to also provide an image resolver. You can use the default implementation provided in Telerik.Documents.ImageUtils: 
// Telerik.Documents.ImageUtils.ImagePropertiesResolver defaultImagePropertiesResolver = new Telerik.Documents.ImageUtils.ImagePropertiesResolver(); 
// Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver = defaultImagePropertiesResolver; 
 
var doc = new RadFixedDocument(); 
var page = doc.Pages.AddPage(); 
var editor = new FixedContentEditor(page); 
 
using (FileStream fs = new FileStream(@"....\telerik_logo.jpg", FileMode.Open)) 
{ 
    editor.DrawImage(fs); 
} 
 
var provider = new PdfFormatProvider(); 
File.WriteAllBytes(@"result.pdf", provider.Export(doc)); 

See Also

In this article