Merge PNG to PDF in C#

Combine PNG images into PDF documents with a cross-platform .NET API.

Merge PNG to PDF using Aspose.Slides

Aspose.Slides for .NET lets you create, convert, merge, and manipulate presentations, PDFs, images, and other files. You can place PNG images on slides and save the result as a single PDF document.

Merge PNG to PDF in C#

Using Aspose.Slides for .NET , you can add PNG images to a Presentation object and save the presentation with SaveFormat.Pdf.

C# code for merging PNG to PDF

using var presentation = new Presentation();
presentation.Slides.RemoveAt(0);

var layoutSlide = presentation.LayoutSlides[0];

foreach (var imagePath in new[] { "image1.png", "image2.png" })
{
    var slide = presentation.Slides.AddEmptySlide(layoutSlide);

    var imageData = File.ReadAllBytes(imagePath);
    var presentationImage = presentation.Images.AddImage(imageData);
    slide.Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, 720, 540, presentationImage);
}

presentation.Save("merged.pdf", SaveFormat.Pdf);

How to merge PNG to PDF in C#

  1. Install Aspose.Slides for .NET. See Installation .

  2. Add the library as a reference in your project.

  3. Create a Presentation object.

  4. Add each source PNG image to a slide as a picture frame.

  5. Save the presentation with SaveFormat.Pdf.

Merge other files

You can also combine files in other formats to get a single file