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
| Product | Version |
| Microsoft Windows | Windows 7 |
| Windows SDK | Windows 7 Platform Software Development Kit (SDK) |
| Microsoft Visual Studio | Visual Studio 2008 or later |
Downloading the Sample
Building the Sample
To build the sample by using Visual Studio:
-
Open Windows Explorer and navigate to the directory that contains the sample code files.
-
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.
-
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:
- Use Windows Explorer or the Command Prompt window to navigate to the directory that contains the new executable file.
- 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