Code brushes and gradients of XPS

C++ API solution to work with brushes and gradients of XPS files.

 

Aspose.Page API Solution for C++ provides you with the capability to manipulate the vector graphics of XPS files. It lets you create various geometric shapes with different colors and textures. Learn also Aspose.Page documentation about how to work with brushes .

To manipulate brushes and gradients of XPS files, we need:

  • 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

Work with visual brushes with C++

The Aspose.Page for C++ API allows you to add a grid to your XPS files using a few lines of code. This can be done for both new and existing documents. The XpsVisualBrush class is utilized to set the properties of the grid, utilizing XpsPathGeometry and XpsCanvas objects. To add a grid to your XPS document, you will need to follow these steps:

  1. Using the XpsDocument Class create a Document object
  2. Create an XpsPathGeometry object with the necessary segments defined.
  3. Utilize the XpsCanvas Class to set the rendering transformation.
  4. Adjust the Fill and Opacity properties as desired.
  5. Save the document by calling the Save() Method.
Namespaces in use
using Aspose::Page::XPS;
using Aspose::Page::XPS::XpsModel;
using System::Drawing;
Using the visual brush to create grid

Add a horizontal gradient with C++.

The Aspose.Page API Solution for C++ allows you to add different types of gradients to your XPS documents using the XpsGradientBrush Class. This class is used to specify the XpsGradientStop and XpsPath information to the XpsDocument object which represents the XPS file. Here’s an example of how to do this:

  1. Initialize an XpsDocument object.
  2. Define the XpsGradientStop and XpsPath parameters for the XPS document.
  3. Set the rendering information.
  4. Save the document using the Save() Method.
Insert horizontal gradient to an XPS

XPS What is XPS File Format

XPS (XML Paper Specification) is Microsoft’s open‑source alternative to PDF. It uses XML/HTML markup to describe page layout, fonts, and images, ensuring consistent rendering across Windows platforms and other operating systems.