# 在 C# 中将图像合并为 PDF

> 在 C# 中将图像合并为 PDF。使用 .NET 库 API 组合图像和 PDF

Source: https://products.aspose.com/slides/zh/net/merger/image-to-pdf/
Updated: 2023-04-07



## 使用 Aspose.Slides 将图像合并为 PDF

[**Aspose.Slides for .NET**](https://products.aspose.com/slides/zh/net/) 是一个功能强大的 .NET 库，用于创建、转换、合并和操作演示文稿、PDF、图像、和其他文件。当您将图像合并为 PDF 时，您实际上是在组合图像以获得单个 PDF 文件。

## 在 C# 中将图像合并为 PDF

使用 [**Aspose.Slides for .NET**](https://products.aspose.com/slides/zh/net/)，您只需几行代码即可快速将图像合并为 PDF

### 用于将图像合并为 PDF 的 C# 代码

```cs
using (Presentation pres = new Presentation())
{
    IPPImage image = pres.Images.AddImage(File.ReadAllBytes("image1.png"));
    pres.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, 100, 100, image);

    IPPImage image2 = pres.Images.AddImage(File.ReadAllBytes("image2.png"));
    pres.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 200, 100, 100, image2);

    pres.Save("MergedFile.pdf", SaveFormat.Pdf);
}
```

## 如何在 C# 中将图像合并为 PDF

安装 **Aspose.Slides for .NET**。请参阅 [**安装**](https://docs.aspose.com/slides/net/installation/)。

将库添加为项目中的参考。

创建一个 Presentation 类的实例。

加载要合并为相框的图像。

保存生成的 PDF。

## 合并其他文件
