翻譯|使用教程|編輯:李顯亮|2021-06-25 09:56:56.007|閱讀 280 次
概述:PDF是許多組織用于通過 Internet 共享文檔的流行格式。有時可能會發(fā)現(xiàn)自己需要從掃描文檔或發(fā)票的圖像創(chuàng)建 PDF 文件。有鑒于此,本文將介紹如何使用 C++ 將圖像轉(zhuǎn)換為 PDF 格式。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
PDF是許多組織用于通過 Internet 共享文檔的流行格式。有時可能會發(fā)現(xiàn)自己需要從掃描文檔或發(fā)票的圖像創(chuàng)建 PDF 文件。有鑒于此,本文將介紹如何使用 C++ 將圖像轉(zhuǎn)換為 PDF 格式。
Aspose.PDF for C++是一個 C++ 庫,允許您創(chuàng)建、閱讀和修改 PDF 文檔。此外,API 支持將圖像轉(zhuǎn)換為 PDF 文件。點擊下方按鈕可下載試用。
以下是將圖像轉(zhuǎn)換為 PDF 格式的步驟。
以下示例代碼演示了如何使用 C++ 將圖像轉(zhuǎn)換為 PDF 文件。
// Create an instance of the Document class auto pdfDocument = MakeObject(); // Add a page System::SharedPtrpage = pdfDocument->get_Pages()->Add(); // Set margins page->get_PageInfo()->get_Margin()->set_Bottom(0); page->get_PageInfo()->get_Margin()->set_Top(0); page->get_PageInfo()->get_Margin()->set_Left(0); page->get_PageInfo()->get_Margin()->set_Right(0); // Set CropBox page->set_CropBox(MakeObject(0, 0, 400, 400)); // Create an instance of the Image class System::SharedPtrimage = MakeObject(); // Specify the image path image->set_File(u"SourceDirectory\\Images\\AsposeLogo.png"); // Add the image to the PDF page page->get_Paragraphs()->Add(System::DynamicCast(image)); // Save the PDF file pdfDocument->Save(u"OutputDirectory\\Image2PDF.pdf");
如果你想試用Aspose的全部完整功能,可聯(lián)系在線客服獲取30天臨時授權(quán)體驗。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn