Export Presentations to XAML with Python
Overview
Info
In Aspose.Slides 21.6, we implemented support for XAML export. You can now export your presentations to XAML.XAML is a descriptive programming language that allows you to build or write user interfaces for apps, especially those that use WPF (Windows Presentation Foundation), UWP (Universal Windows Platform), and Xamarin forms.
XAML, which is an XML-based language, is Microsoft’s variant for describing a GUI. You are likely to use a designer to work on XAML files most of the time, but you can still write and edit your GUI.
Export Presentations to XAML with Default Options
This Python code shows you how to export a presentation to XAML with default settings:
import aspose.slides as slides
pres = slides.Presentation("pres.pptx")
pres.save(slides.export.xaml.XamlOptions())
Export Presentations to XAML with Custom Options
You get to select options from the IXamlOptions interface that control the export process and determine how Aspose.Slides exports your presentation to XAML.
For example, if you want Aspose.Slides to add hidden slides from your presentation when exporting it to XAML, you can set the ExportHiddenSlides property to true. See this sample Python code:
import aspose.slides as slides
pres = slides.Presentation("pres.pptx")
opt = slides.export.xaml.XamlOptions()
opt.export_hidden_slides = True
pres.save(opt)
FAQ
How can I ensure predictable fonts if the original font is not available on the machine?
Set default_regular_font in XamlOptions — it is used as a fallback font when the original is missing. This helps avoid unexpected substitutions.
Is the exported XAML intended only for WPF, or can it be used in other XAML stacks as well?
XAML is a general UI markup language used in WPF, UWP, and Xamarin.Forms. The export targets compatibility with Microsoft XAML stacks; the exact behavior and support for specific constructs depend on the target platform. Test the markup in your environment.
Are hidden slides supported, and how can I prevent them from being exported by default?
By default, hidden slides are not included. You can control this behavior via export_hidden_slides in XamlOptions — keep it disabled if you do not need to export them.