将 XPS 文档合并为 PDF
用于组合多个 XPS 文件的 C++ API 解决方案
XPS 文件格式允许在单个文件中存储多个文档,并且还可以包含多个页面。 Aspose.Page API Solution for C++ 提供了将多个文件合并为一个的功能,从而生成包含所有原始文件的组合内容的 XPS 或 PDF 文件。
您将在此处找到有关如何使用 API 合并 XPS 文件的代码示例。要探索如何将此功能集成到 Web 解决方案中或用于在线文件合并,您可以尝试跨平台 XPS Merger 工具。
要合并 PS 和 EPS 文件,您需要:
Aspose.Page for C++ API 是一个功能丰富、功能强大且易于使用的 C++ 平台文档操作和转换 API。
您可以直接下载其最新版本,只需打开NuGet包管理器,然后搜索Aspose.Page.Cpp并安装。您还可以从包管理器控制台使用以下命令。
Package Manager Console Command
PM> Install-Package Aspose.Page.Cpp
使用 C++ 将多个 XPS 文件合并为 PDF 的步骤。
- 设置文档目录的路径。
- 初始化 PDF 输出和 XPS 文件输入流。
- 从之前创建的输入流创建 XpsDocument 的实例。
- 通过 PdfSaveOptions 使用输出文件的 TextCompression、ImageCompression、JpegQualityLevel 参数初始化选项对象/) 班级。
- 使用 PdfDevice 类,创建 PDF 格式的渲染设备。
- 合并XPS文件以输出XPS文档。
Used namespaces
using Aspose::Page::XPS;
using Aspose::Page::IO;
using Aspose::Page::Presentation::Pdf;
将 PS 文件合并为 PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
System::String dataDir = RunExamples::GetDataDir_WorkingWithDocumentMerging(); | |
// Load XPS document form the XPS file | |
System::SharedPtr<XpsDocument> document = System::MakeObject<XpsDocument>(dataDir + u"input.xps", System::MakeObject<XpsLoadOptions>()); | |
// Initialize options object with necessary parameters. | |
System::SharedPtr<Aspose::Page::XPS::Presentation::Pdf::PdfSaveOptions> options = System::MakeObject<Aspose::Page::XPS::Presentation::Pdf::PdfSaveOptions>(); | |
options->set_JpegQualityLevel(100); | |
options->set_ImageCompression(Aspose::Page::XPS::Presentation::Pdf::PdfImageCompression::Jpeg); | |
options->set_TextCompression(Aspose::Page::XPS::Presentation::Pdf::PdfTextCompression::Flate); | |
// Create an array of XPS files that will be merged with the first one | |
System::ArrayPtr<System::String> filesToMerge = System::MakeArray<System::String>({dataDir + u"Demo.xps", dataDir + u"sample.xps"}); | |
// Merge XPS files to output PDF file | |
document->MergeToPdf(filesToMerge, dataDir + u"output/" + u"mergedXPSfiles.pdf", options); |
使用 C++ 将多个 XPS 文件合并为一个文件的步骤。
- 从第一个 XPS 文件创建 XpsDocument 的实例。
- 创建将与第一个文件合并的 XPS 文件数组。
- 将XPS文件与创建的文档合并(通过 合并 )并保存。
将 PS 文件合并为 PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
System::String dataDir = RunExamples::GetDataDir_WorkingWithDocumentMerging(); | |
// Load XPS document from XPS file | |
System::SharedPtr<XpsDocument> document = System::MakeObject<XpsDocument>(dataDir + u"input.xps", System::MakeObject<XpsLoadOptions>()); | |
// Create an array of XPS files that will be merged with the first one | |
System::ArrayPtr<System::String> filesToMerge = System::MakeArray<System::String>({dataDir + u"Demo.xps", dataDir + u"sample.xps"}); | |
// Merge XPS files to output XPS document | |
document->Merge(filesToMerge, dataDir + u"output/" + u"mergedXPSfiles.xps"); |
XPS 什么是XPS文件格式
XPS 格式类似于 PDF 格式。两者都是页面描述语言 (PDL) 格式。 EPS 基于 HTML 而不是 PostScript 语言。 .eps 文件能够包含文档结构的标记以及有关文档外观的信息。还添加了有关如何打印和呈现文档的说明。该格式的特点是它修复了文档的描述,这意味着无论谁以及从哪个操作系统打开它,它看起来都是一样的。