在 C++ 中將 圖片轉換為PDF

用於將圖片轉換為PDF的高速軟件C++

使用C++獲得最大的圖片到PDF轉換速度。這是一個完整的專業軟件解決方案,可C++ 圖片, PDF和許多其他文檔格式。

查看代碼片段

使用 C++ 將圖像轉換為 PDF

需要以編程方式將圖像轉換為 PDF?借助Aspose.Words for C++,任何開發人員只需幾行 C++ 代碼即可將圖像轉換為 PDF 格式。

現代圖像處理 C++ API 從具有專業品質的圖像創建 PDF。直接在瀏覽器中測試最高質量的圖像到 PDF 的轉換。強大的 C++ 庫允許將圖像轉換為許多流行的格式。

在 C++ 中將圖像保存為 PDF

以下示例演示瞭如何在 C++ 中將圖像轉換為 PDF。

按照簡單的步驟將圖像文件轉換為 PDF 格式。從本地驅動器讀取圖像文件,然後將其保存為可移植文檔格式,並通過 PDF 擴展名指定所需的文件格式。對於圖像讀取和 PDF 寫入,您可以使用完全限定的文件名。

C++代碼示例將PNG轉換為PDF格式
上傳您要轉換的文件
運行代碼
從列表中選擇目標格式
using namespace Aspose::Words;

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

builder->InsertImage(u"Input.png");

doc->Save(u"Output.pdf");
using namespace Aspose::Words; auto doc = MakeObject<Document>(u"Input.png"); doc->Save(u"Output.pdf"); using namespace Aspose::Words; auto doc = MakeObject<Document>(u"Input.png"); for (int page = 0; page < doc->get_PageCount(); page++) { auto extractedPage = doc->ExtractPages(page, 1); extractedPage->Save(String::Format(u"Output_{0}.pdf", page + 1)); } using namespace Aspose::Words; auto doc = MakeObject<Document>(); auto builder = MakeObject<DocumentBuilder>(doc); builder->InsertImage(u"Input.png"); doc->Save(u"Output.pdf"); using namespace Aspose::Words; auto doc = MakeObject<Document>(); auto builder = MakeObject<DocumentBuilder>(doc); auto shape = builder->InsertImage(u"Input.png"); shape->GetShapeRenderer()->Save(u"Output.pdf", MakeObject<ImageSaveOptions>(SaveFormat::Svg));
運行代碼
在社交媒體上分享代碼:

如何將圖片轉換為PDF

  1. Aspose.Words for C++安裝 Aspose.Words。
  2. 將庫引用(導入庫)添加到您的C++項目。.
  3. 在C++打開源圖片文件。.
  4. 調用Save()方法,傳遞帶有PDF擴展名的輸出文件名。.
  5. 圖片轉換的結果PDF 。.

C++庫將圖片轉換為PDF

有三個選項可以將 Aspose.Words for C++ 安裝到您的開發人員環境中。請選擇符合您需求的一種,並按照分步說明進行操作:

系統要求

您可以使用這個 C++ 庫在 Microsoft Windows 、Linux 和 macOS 操作系統上開發軟件:

  • Linux 需要 GCC >= 6.3.0 和 Clang >= 3.9.1
  • Xcode >= 12.5.1 ,macOS 需要 Clang 和 libc++

如果您為 Linux 或 macOS 開發軟件,請查看產品文檔中 fontconfig 和 mesa-glu 開源包)的信息。

5%

訂閱 Aspose 產品更新

獲取直接發送到您的郵箱的每月通訊和優惠。

© Aspose Pty Ltd 2001-2024. 版權所有。