使用C++将附件嵌入到PDF中
Contents
[
Hide
]
在Excel中,您可以插入带有源数据的Ole对象(embedded-attachments-example.xlsx)。双击Ole对象,嵌入的文件将被打开。
通常,在转换为PDF时,Ole对象将作为图标或缩略图渲染,而不显示Ole对象的源数据。使用选项PdfSaveOptions.GetEmbedAttachments(),您可以将Ole对象的源数据作为附件嵌入到PDF中。在PDF中双击图标或缩略图即可打开Ole对象的源文件。
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Open the template file
Workbook workbook(u"embedded-attachments-example.xlsx");
// Set to embed Ole Object attachment.
PdfSaveOptions pdfSaveOptions;
pdfSaveOptions.SetEmbedAttachments(true);
// Save the pdf file with PdfSaveOptions
workbook.Save(u"output.pdf", pdfSaveOptions);
std::cout << "PDF saved successfully with embedded attachments!" << std::endl;
Aspose::Cells::Cleanup();
}