IXpsOMPackage::WriteToFile method (xpsobjectmodel.h)

Writes the XPS package to a specified file.

Syntax

HRESULT WriteToFile(
  [in] LPCWSTR               fileName,
  [in] LPSECURITY_ATTRIBUTES securityAttributes,
  [in] DWORD                 flagsAndAttributes,
  [in] BOOL                  optimizeMarkupSize
);

Parameters

[in] fileName

The name of the file to be created. This parameter must not be NULL.

[in] securityAttributes

The SECURITY_ATTRIBUTES structure, which contains two distinct but related data members:

  • lpSecurityDescriptor: an optional security descriptor
  • bInheritHandle: a Boolean value that determines whether the returned handle can be inherited by child processes
If lpSecurityDescriptor is NULL, the file or device that is associated with the returned handle will be assigned a default security descriptor.

For more information about the securityAttributes parameter, refer to CreateFile.

[in] flagsAndAttributes

Specifies the settings and attributes of the file to be created. For most files, a value of FILE_ATTRIBUTE_NORMAL can be used.

For more information about the flagsAndAttributes parameter, refer to CreateFile.

[in] optimizeMarkupSize

A Boolean value that indicates whether the document markup is to be optimized for size when it is written to the file.

Value Meaning
TRUE
The package writer will attempt to optimize the markup for minimum size.
FALSE
The package writer will not attempt any optimization.

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_POINTER
fileName is NULL.
 

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

Remarks

The optimizeMarkupSize value determines whether the markup inside the individual document parts is to be optimized. It has no effect on how the parts are interleaved.

Note  Writing an XPS OM to a file does not automatically create a thumbnail for the XPS document. To create a thumbnail of the XPS document, use the IXpsOMThumbnailGenerator interface.
 

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

CreateFile

IXpsOMPackage

Packaging Errors

SECURITY_ATTRIBUTES

XML Paper Specification

XPS Document Errors