Add Text to XPS
C++ API Solution to work with text of xps files
Aspose.Page for C++ API solution lets you manipulate XPS files along with other Page Description Language format files. Among other features the Solution allows you to easily add text to an XPS document using C++ applications. You can do this by using the XpsGlyphs Class, which lets you add text to an XPS document by specifying the brush of your choice. Here’s an example of how to add text to an XPS document with just a few lines of code. For complete examples and data files, please go to our Github project
In order to code XPS files you need to have:
Aspose.Page for C++ API which is a feature-rich, powerful and easy to use document manipulation and conversion API for C++ platform.
You can download its latest version directly, just open NuGet package manager, and search for Aspose.Page.Cpp and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Page.Cpp
Steps to add text to an XPS file.
This C++ code demonstrates how to add text to an XPS document using the Aspose.Page for C++ API.
- Create a new XPS document using the XpsDocument Class.
- Add the glyph to the document object with the necessary font information. Create XpsGlyphs object, which is used to add text to the XPS document. The AddGlyphs() Method is used to add the text, and it takes in the font, font size, font style, X and Y position of the text and the text to be added.
- The brush created above is then set as the fill property of the glyphs object.
- Save the modified XPS document by calling the Save() Method of the XpsDocument Class and passing in the path to save the file.
Add text to XPS
FAQ
1. Can I add text to a XPS document?
Yes, it is possible to add text to XPS files. XPS is a fixed-layout document format developed by Microsoft, similar to PDF, and it supports the inclusion of text alongside other content such as images and shapes.
2. How do I add text with specific formatting in a XPS file?
To incorporate text into the XPS document using Aspose.Page API Solution, instantiate an XpsGlyphs object. This object serves as the conduit for adding textual content. Employ the AddGlyphs() Method for this purpose, which necessitates inputs including the font, font size, and font style, along with the X and Y coordinates dictating the position of the text. Finally, provide the actual text to be added as an argument.
3. Are there any limitations or considerations when adding text to XPS files?
There are some limitations and considerations to keep in mind. For example, the fonts used in the XPS document should be embedded or available on the system where the document is viewed to ensure proper rendering. Additionally, text formatting may vary depending on the software used to create or edit the XPS file, so it’s essential to test the document with different viewers to ensure consistent display across platforms.
XPS What is XPS File Format
XPS format is similar to PDF format. Both are page description language (PDL) formats. EPS is based on HTML and not on PostScript language. The .eps file is capable to contain a markup of the document's structure along with the information on how the document would look like. There are also added instructions on how to print and render the document. The feature of the format is that it fixes the document's description which means that it will look the same no matter who and from what operational system opens it.