使用 C++ 将 PPT 转为 TIFF

标记图像文件格式 (TIFF) 是一种图像格式,由于其高质量,通常用于打印目的。在某些情况下,您可能需要将 PPTX 文件转换为 TIFF 格式以进行打印。为此,本文将教您如何使用 C++ 以编程方式将 PowerPoint PPTX/PPT 文件转换为 TIFF 格式。

C++ PowerPoint PPT to TIFF 转换器 - 免费下载

Aspose.Slides for C++ 是一个用于处理 PowerPoint 文件的 C++ API。它使您无需其他软件即可创建、阅读和修改 PPT 和 PPTX 文件。此外,API 支持将 PPTX/PPT 文件转换为 TIFF 图像格式。您可以通过 NuGet 安装 API,也可以直接从 Downloads 部分下载。

PM> Install-Package Aspose.Slides.Cpp

在 C++ 中将 PPT 转换为 TIFF

只需几行代码,您就可以将 PowerPoint PPTX/PPT 文件转换为 TIFF 格式。为此,请按照以下步骤操作。

以下示例代码展示了如何使用 C++ 将 PPT 转换为 TIFF 格式。

// 文件路径
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\ConvertToTiff_out.tiff";

// 加载演示文件
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);

// 保存 TIFF 文件
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Tiff);

C++ PPTX 到 TIFF - 自定义图像大小

以下是将 PowerPoint 文件转换为具有自定义图像大小的 TIFF 格式的步骤。

以下示例代码显示了如何在 C++ 中将 PPTX 转换为具有自定义图像大小的 TIFF。

// 文件路径
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\ConvertToTiffWithCustomImageSize_out.tiff";

// 加载演示文件
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);

// 创建 TiffOptions 类的实例
SharedPtr<Aspose::Slides::Export::TiffOptions> options = MakeObject<Aspose::Slides::Export::TiffOptions>();

// 设置压缩类型
options->set_CompressionType(Aspose::Slides::Export::TiffCompressionTypes::Default);

// 设置 DpiX
options->set_DpiX(200);

// 设置 DpiY
options->set_DpiY(100);

// 设置图像大小
options->set_ImageSize(System::Drawing::Size(1728, 1078));

// 保存 TIFF 文件
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Tiff, options);

C++ PowerPoint PPT to TIFF - 自定义像素格式

为了设置像素格式,我们将使用 ImagePixelFormat 枚举。 ImagePixelFormat 枚举提供以下值。

  • Format1bppIndexed:每像素 1 位,索引
  • Format4bppIndexed:每像素 4 位,索引
  • Format8bppIndexed:每像素 8 位,索引
  • Format24bppRgb:每像素 24 位,RGB
  • Format32bppArgb:每像素 32 位,ARGB

以下是使用 C++ 将 PPTX/PPT 文件转换为具有自定义像素格式的 TIFF 图像的步骤。

以下示例代码显示了如何将 PowerPoint PPT 转换为 C++ 中具有自定义像素格式的 TIFF。

// 文件路径
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\ConvertToTiffPixelFormat_out.tiff";

// 加载演示文件
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);

// 创建 TiffOptions 类的实例
SharedPtr<Aspose::Slides::Export::TiffOptions> options = MakeObject<Aspose::Slides::Export::TiffOptions>();

// 设置像素格式
options->set_PixelFormat(Aspose::Slides::Export::ImagePixelFormat::Format8bppIndexed);

// 保存 TIFF 文件
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Tiff, options);

PPTX 到 TIFF C++ 转换器 - 获得免费许可证

为了在没有评估限制的情况下使用 API,您可以获得 免费的临时许可证

结论

在本文中,您学习了如何在 C++ 中将 PowerPoint PPT 转换为 TIFF 图像。此外,您还学习了如何在 PPT 到 TIFF 转换中设置自定义图像大小和像素格式。此外,Aspose.Slides for C++ 是一个用于处理 PowerPoint 文件的强大 API。您可以通过访问 官方文档 来详细探索 API。如有任何疑问,请随时通过我们的 免费支持论坛 与我们联系。

也可以看看

提示:您可能需要在线查看 Aspose FREE PowerPoint 到海报转换器