Click or drag to resize
Pdftools logo

FileReferenceCreate Method

Create a new file reference object

The newly created file reference object belongs to the document but is not (yet) used as an embedded file. The object can be added to the list of embedded files or to the list of associated files.

Namespace: PdfTools.Toolbox.Pdf
Assembly: PdfTools.Toolbox (in PdfTools.Toolbox.dll) Version: 1.4.0+02318d3e3f9645a1305b87026fb971a660079e54
Syntax
C#
public static FileReference Create(
	Document targetDocument,
	Stream data,
	string name,
	string mediaType,
	string description,
	DateTimeOffset? modificationDate
)

Parameters

targetDocument  Document
the output document with which the returned object is associated
data  Stream
A stream of the file to be added. Read access is required.
name  String
The name to be used for the embedded file. This name is presented to the user when viewing the list of embedded files.
mediaType  String
The mime type of the embedded file. Default: "application/octet-stream". Common values other than the default are "application/pdf", "application/xml", or "application/msword".
description  String
The description of the embedded file. This is presented to the user when viewing the list of embedded files.
modificationDate  NullableDateTimeOffset
The modify date of the file. Default: current time.

Return Value

FileReference
the newly created file reference object
Exceptions
ExceptionCondition
ArgumentExceptionif the targetDocument argument has already been closed
ArgumentExceptionif the targetDocument argument is read-only
ArgumentExceptionif the name argument is an empty string
ConformanceExceptionif the document's conformance is PDF/A-1
ConformanceExceptionif the document's conformance is PDF/A-2 and the given data contains a file other than PDF/A-1 or PDF/A-2
IOExceptionError reading from the stream.
ArgumentNullExceptionif targetDocument is .
ArgumentNullExceptionif data is .
ArgumentNullExceptionif name is .
See Also