Work with XPS Documents in Qt | C++

Aspose.Page for C++ can be used for creating cross-platform applications to create, read, and convert XPS files to other formats using Qt. Qt applications can target a variety of desktop, mobile, web, and embedded system applications. This article shows how to integrate our C++ Page library to work with XPS files in Qt applications.

Using Aspose.Page for C++ within Qt

To use Aspose.Page for C++ in your Qt application, download the latest version of the API from the downloads section (for Windows Operating System). The API can be used with Qt using two options:

In this article, we show to integrate and use Aspose.Page for C++ within a Qt console application using Qt Creator.

Create Qt Console Application

This article assumes that you have properly installed Qt development environment and Qt Creator.

At this point, you should have a workable executing Qt Console Application that should compile without issues.

Integrate Aspose.Page for C++ API with Qt

copying folders

entries of the project

Create XPS Document in Qt

Now that Aspose.Page for C++ has been integrated with Qt, we are ready to create an XPS document with some text and save it to disc. To do this:

 1    QString text = "Hello World";
 2
 3    // Create new XPS Document
 4
 5    auto doc = System::MakeObject<XpsDocument>();
 6
 7    //Create a brush 
 8
 9    System::SharedPtr<XpsSolidColorBrush> textFill = doc->CreateSolidColorBrush(System::Drawing::Color::get_Black());
10
11    //Add glyph to the document
12
13    System::SharedPtr<XpsGlyphs> glyphs = doc->AddGlyphs(u"Arial", 12.0f, System::Drawing::FontStyle::Regular, 300.f, 450.f, text.toStdU16String().c_str());
14
15    glyphs->set_Fill(textFill);
16
17    // Save resultant XPS document
18
19    doc->Save(outDir() + u"AddText_out.xps");

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.