Embed Attachment to PDF with C++

Contents
[ ]

In Excel, you can insert an Ole Object with source data (embedded-attachments-example.xlsx). Double‑click the Ole Object, and the embedded file will be opened.

Generally, while converting to PDF, the Ole Object is rendered as an icon or a thumbnail without the Ole Object’s source data. With the option PdfSaveOptions.GetEmbedAttachments(), you can embed the Ole Object’s source data as an attachment in the PDF. You can double‑click the icon or the thumbnail in the PDF to open the source file of the Ole Object.

#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();
}

embedded-attachment.png