乳胶到XPS | C ++的Aspose.TeX

Aspose.TeX支持的另一种目标格式是 xps。一个xps文件实际上是一个zip软件包,其中包含文档的分页内容,以及特定查看者(例如Windows XPS查看器)和打印所需的元数据。软件包中的所有数据均由文件表示。其中一些是二进制的,并且包含图像,字体和ICC配置文件等资源。其他是各种特定模式中的XML文件。后者包括包含文档数据本身的文件。文档数据由一组文件组成 - 每个文件都包含文档单个页面的数据。此类文件由单个页面元素和子元素树组成 - canvaspathglyphscanvas是一个分组元素,可以包含其他帆布路径glyphs。它的任务是控制所有子元素作为一个小组的外观。 路径元素用于定义向量图形路径。 *字形 *元素用于定义文本内容。这三个元素均具有定义外观各个方面的属性。

aspose.page库,该库提供了用于操纵XPS文档的API,并将其转换为PDF和栅格图像格式。

如何将乳胶转换为XPS

转换为XPS与 转换为栅格图像格式一样简单,除了 SaveOptions之外,我们还必须将设备更改为 XPSDEVICE类的实例。

1...
2// Initialize the options for saving in Xps format.
3options->set_SaveOptions(System::MakeObject<XpsSaveOptions>());
4
5System::MakeObject<Aspose::TeX::TeXJob>(u"hello-world.ltx", System::MakeObject<XpsDevice>(), options)->Run();

编写主输出XPS文件的另一种方法

XPSDEVICE类的另一个构造函数使我们可以以替代方式获取所得的XPS文件。

 1    // Create the stream to write the XPS file to.
 2    {
 3        System::SharedPtr<System::IO::Stream> xpsStream = System::IO::File::Open(System::IO::Path::Combine(RunExamples::OutputDirectory, u"any-name.xps"), System::IO::FileMode::Create);
 4        // Clearing resources under 'using' statement
 5        System::Details::DisposeGuard<1> __dispose_guard_0({ xpsStream});
 6        // ------------------------------------------
 7        
 8        try
 9        {
10            // Create conversion options for Object LaTeX format on Object TeX engine extension.
11            System::SharedPtr<TeXOptions> options = TeXOptions::ConsoleAppOptions(TeXConfig::get_ObjectLaTeX());
12            // Specify the file system working directory for the output.
13            options->set_OutputWorkingDirectory(System::MakeObject<OutputFileSystemDirectory>(RunExamples::OutputDirectory));
14            // Initialize the options for saving in XPS format.
15            options->set_SaveOptions(System::MakeObject<XpsSaveOptions>());
16            // Default value.
17            // Run LaTeX to XPS conversion.
18            System::MakeObject<TeXJob>(System::IO::Path::Combine(RunExamples::InputDirectory, u"hello-world.ltx"), System::MakeObject<XpsDevice>(xpsStream), options)->Run();
19        }
20        catch(...)
21        {
22            __dispose_guard_0.SetCurrentException(std::current_exception());
23        }
24    }

效果与我们得到 这里相同。

您也可以检查基于 Aspose.TeX for .NETAPI构建的免费乳胶转换 Web App这里是C ++版本页。

Have any questions about Aspose.TeX?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.