乳胶到XPS | Aspose.TeX for Python
Contents
[
Hide
Show
]另一种目标格式是 xps。 xps文件本质上是一个zip软件包,其中包含文档的分页内容,以及必要的元数据,以通过特定的观看者(例如Windows XPS Viewer)和打印。该软件包由各种文件组成,其中一些是二进制文件,并包含图像,字体和ICC配置文件等资源。其他是特定模式中的XML文件,包括包含文档数据本身的文件。文档数据分为多个文件,每个文件代表文档的单个页面。这些文件由单个页面元素和一个子元素树组成,包括 canvas, path和 glyphs。 canvas元素是一个分组元素,可以包含其他 *帆布 *, 路径 和 glyphs,并且它控制着所有子元素作为一个组的外观。 路径元素用于定义向量图形路径,而glyphs元素用于定义文本内容。这三个元素均具有定义外观各个方面的属性。
存在 aspose.page库,该库提供了用于操纵XPS文档的API,还可以将这些文档转换为PDF和栅格图像格式。
将乳胶转换为XPS
将乳胶转换为XPS的过程同样简单,类似于 转换为栅格图像格式。但是,它需要将 save_options设置为 xpsSaveOptions类的实例(默认情况下或显式),然后将设备更改为 xpsdevice类的实例。
1# Create conversion options instance.
2...
3# Initialize the options for saving in XPS format.
4so = XpsSaveOptions()
5options.save_options = so # Default value. Arbitrary assignment.
6# Run LaTeX to XPS conversion.
7TeXJob(path.join(Util.input_directory, "sample.ltx"), XpsDevice(), options).run()
编写主输出XPS文件的另一种方法
XpsDevice类有一个替代构造函数,它允许以不同的方式获得所得的XPS文件。
1# Create the stream to write the XPS file to.
2with open(path.join(Util.output_directory, "any-name.xps"), "wb") as xps_stream:
3 # Create conversion options for Object LaTeX format upon Object TeX engine extension.
4 options = TeXOptions.console_app_options(TeXConfig.object_latex)
5 # Specify a file system working directory for the output.
6 options.output_working_directory = OutputFileSystemDirectory(Util.output_directory)
7 # Initialize the options for saving in XPS format.
8 options.save_options = XpsSaveOptions() # Default value. Arbitrary assignment.
9 # Run LaTeX to XPS conversion.
10 TeXJob(path.join(Util.input_directory, "hello-world.ltx"), XpsDevice(xps_stream), options).run()
效果与我们得到 这里相同。
您还可以探索免费的 用于 LaTeX 到 XPS 转换的 Web 应用程序,它是使用 Aspose.TeX for .NET API 开发的。