Partager via


IXpsOMPackage::WriteToFile method

Writes the XPS package to a specified file.

Syntax

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

Parameters

  • fileName [in]
    The name of the file to be created. This parameter must not be NULL.

  • securityAttributes [in]
    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.

  • flagsAndAttributes [in]
    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.

  • optimizeMarkupSize [in]
    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

Minimum supported client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | Windows Store apps]

Header

Xpsobjectmodel.h

IDL

XpsObjectModel.idl

See also

IXpsOMPackage

CreateFile

SECURITY_ATTRIBUTES

Packaging Errors

XPS Document Errors

XML Paper Specification