# How to Generate a PDF Document from Images with RadFixedDocumentEditor

## Environment

| Version    | Product          | Author                                                                          |
| ---------- | ---------------- | ------------------------------------------------------------------------------- |
| 2024.1.124 | RadPdfProcessing | [Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova) |

## Description

This article demonstrates how to generate a PDF document from a collection of images in a local folder.

![Folder with images](https://www.telerik.com/document-processing-libraries/documentation/assets/eadf5b88b9870f7d4eb86c22b8c6f322/images-folder.png)

## Solution

To create the PDF document, use the [`RadFixedDocumentEditor`](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/radfixeddocumenteditor) class. This class generates content in a flow-like manner and automatically distributes it across pages.

```csharp
         private static void GeneratePdfFromImagesWithRadFixedDocumentEditor(string imageFolderPath)
        {
            Padding pageMarginsValue = new Padding(
                Unit.MmToDip(20),//left
                 Unit.MmToDip(0),//top
                  Unit.MmToDip(0),//right
                   Unit.MmToDip(0));//bottom
            Size pageSize = new Size(Unit.MmToDip(210), Unit.MmToDip(297));
            RadFixedDocument fixedDocument = new RadFixedDocument();
            RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument);
            documentEditor.SectionProperties.PageSize = pageSize;
            documentEditor.SectionProperties.PageMargins = pageMarginsValue;
            string[] imageFiles = Directory.GetFiles(imageFolderPath);

            foreach (string imageFilePath in imageFiles)
            {
                FileStream fileStream = new FileStream(imageFilePath, FileMode.Open);
                Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource _imageSource = new Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource(fileStream);
                documentEditor.InsertImageInline(_imageSource);
                documentEditor.InsertLineBreak();
            }
            documentEditor.Dispose();

            PdfFormatProvider provider = new PdfFormatProvider();
            string outputFilePath = @"..\..\sample.pdf";
            File.Delete(outputFilePath);
            using (Stream output = File.OpenWrite(outputFilePath))
            {
                provider.Export(fixedDocument, output);
            }
            Process.Start(outputFilePath);
        }        
```

The following screenshot shows the produced document:

![PDF with images](https://www.telerik.com/document-processing-libraries/documentation/assets/2286e7c6ade92bb0fbcf8e2b39c4a713/pdf-document-with-images.png)

## See Also

* [RadFixedDocumentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/radfixeddocumenteditor)
* [PdfFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/pdf/pdfformatprovider/pdfformatprovider)
* [RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/overview)
* [Converting Colored PDF Documents to Grayscale](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/convert-color-pdf-to-black-and-white-telerik-document-processing)
