IXpsOMPackageWriter::AddResource method (xpsobjectmodel.h)

Creates a new part resource in the package.

Syntax

HRESULT AddResource(
  [in] IXpsOMResource *resource
);

Parameters

[in] resource

The IXpsOMResource interface of the part resource that will be added as a new part in the package. See Remarks for the types of resources that may be passed in this parameter.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the table that follows. For information about XPS document API return values that are not listed in this table, see XPS Document Errors.

Return code Description
S_OK
The method succeeded.
E_INVALIDARG
A resource with the same name as the resource that is referenced by resource has already been added to the stream or there is no relationship that includes the resource that is referenced by resource.

After E_INVALIDARG is returned, the stream or file is no longer valid and Close will return XPS_E_UNAVAILABLE_PACKAGE.

XPS_E_UNAVAILABLE_PACKAGE
A severe error occurred and the contents of the XPS OM might be unrecoverable. Some components of the XPS OM might still be usable but only after they have been verified. Because the state of the XPS OM cannot be predicted after this error is returned, all components of the XPS OM should be released and discarded.
 

This method calls the Packaging API. For information about the Packaging API return values, see Packaging Errors.

Remarks

This method creates a new part in the document package that corresponds to resource, adds the contents of resource to the new part, and then closes the new part.

If this method returns an error, the package writer is no longer usable.

The resource parameter must be one of the following:

  • The IXpsOMFontResource interface of a font resource that is used in the current page or a page that has already been added.
  • The IXpsOMImageResource interface of an image resource that is used in the current page or a page that has already been added.
  • The IXpsOMColorProfileResource interface of color profile resource that is used in the current page or a page that has already been added.
  • The IXpsOMStoryFragmentsResource interface of a story fragments resource that is used in the current page or a page that has already been added.
  • The IXpsOMDocumentStructureResource interface of a document structure resource that is used in the current document or a document that has already been added.
  • The IXpsOMSignatureBlockResource interface of a signature block resource that is used in the current document or a document that has already been added.

This method returns an error if resource contains one of the following:

This method returns an error when resource references a resource that has the same name as a resource that has already been added to the stream or for which there is no existing relationship.

Requirements

Requirement Value
Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header xpsobjectmodel.h

See also

IXpsOMPackageWriter

IXpsOMPackageWriter3D

IXpsOMResource

Packaging Errors

Using the IXpsOMPackageWriter Interface

XML Paper Specification

XPS Document Errors