XpsFlowText
XpsFlowText

The XpsFlowText sample program demonstrates how to place a DirectWrite text layout on an XPS Canvas and then save it as an XPS document.

This topic contains the following sections:

Description

The XpsFlowText sample program uses the DirectWrite API to create a text object.

The program starts by calling MakeTextLayout to create a DirectWrite text layout object, textLayout, that contains some hard-coded text strings. Next, the program creates an object for adding content to an XPS OM canvas object, and formats the DirectWrite text layout object for the canvas object.

The SaveCanvasToXpsViaPackage method writes the resulting canvas object to the disk as a page in an XPS document. To write the XPS document to the disk, the program creates an empty XPS OM to represent the package. To the XPS OM, the program adds the necessary components of an XPS document, including the new canvas that contains the document text. Finally, the program writes XPS OM to a file by calling the IXpsOMPackage::WriteToFile method.

Requirements

ProductVersion
Microsoft WindowsWindows 7
Windows SDKWindows 7 Platform Software Development Kit (SDK)
Microsoft Visual StudioVisual Studio 2008 or later

 

Downloading the Sample

LocationPath/URL
Windows SDK\Program Files\Microsoft SDKs\Windows\v7.0\samples\xps\FlowText
Code Galleryhttp://go.microsoft.com/fwlink/?LinkId=152529

 

Building the Sample

To build the sample by using Visual Studio:

  1. Open Windows Explorer and navigate to the directory that contains the sample code files.

  2. Open the FlowText.sln file in Visual Studio by double-clicking the FlowText.sln file icon.

    Note  The solution file in this sample is compatible with Visual Studio 2008 and later versions of Visual Studio.

  3. In the Build menu, select Build Solution.

The application will be built in the default \Debug or \Release directory.

Running the Sample

To run the sample after it has been built:

  1. Use Windows Explorer or the Command Prompt window to navigate to the directory that contains the new executable file.
  2. Run the program, either from the Command Prompt window or from Windows Explorer.

    • In the Command Prompt window, type FlowText.exe.
    • In Windows Explorer, double-click the FlowText.exe icon.

Additional Information

FlowText.exe creates a single-page XPS document and writes the document to SDKSample_FlowText_Output.xps on your desktop.

To see all of the XPS programming sample programs, see the XPS Programming Samples on MSDN Code Gallery.

See Also

IDWriteFactory
IDWriteFontFace
IDWriteFontFileLoader
IDWriteFontFileStream
IDWriteTextFormat
IDWriteTextLayout
IOpcPartUri
IXpsOMCanvas
IXpsOMDictionary
IXpsOMDocument
IXpsOMDocumentCollection
IXpsOMDocumentSequence
IXpsOMFontResource
IXpsOMFontResourceCollection
IXpsOMGeometry
IXpsOMGeometryFigure
IXpsOMGeometryFigureCollection
IXpsOMGlyphs
IXpsOMGlyphsEditor
IXpsOMObjectFactory
IXpsOMPackage
IXpsOMPage
IXpsOMPageReference
IXpsOMPageReferenceCollection
IXpsOMPartResources
IXpsOMPath
IXpsOMSolidColorBrush
IXpsOMVisualCollection
XPS_COLOR
XPS_GLYPH_INDEX
XPS_GLYPH_MAPPING
XPS_POINT
Common XPS Document Programming Tasks
Using the XPS Object Model

Send comments about this topic to Microsoft

Build date: 11/17/2009

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View