Add a new embedded file attachment to a document
Source:R/attachment_authoring.R
pdf_attachment_new.RdCreates a new /EmbeddedFile entry in doc's name tree, with the
given filename. The returned handle is a pdfium_attachment that
you can pass to pdf_attachment_set_data() to populate the file
bytes, and pdf_attachment_set_dict_value() to populate dictionary
metadata ("Subtype", "Desc", etc.).
Arguments
- doc
A
pdfium_docfrompdf_doc_open()orpdf_doc_new(). Must be readwrite.- name
Character scalar — the attachment's filename. UTF-8 accepted.
Value
A pdfium_attachment handle. The attachment is empty —
call pdf_attachment_set_data() to populate its contents.
Details
Wraps FPDFDoc_AddAttachment. The new attachment is appended to
the end of the document's existing attachment list, and its
$index field reflects the resulting 1-based index. PDFium will
refuse the creation (returning NULL, which we surface as an R
error) if:
nameis empty;nameis the name of an existing embedded file indoc;the document's name tree is at its depth limit.
See also
pdf_attachments() for the read side,
pdf_attachment_delete() to remove an attachment.