Skip to main content

Document

Struct Document 

Source
pub struct Document { /* private fields */ }
Expand description

An open presentation.

Implementations§

Source§

impl Document

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Opens a .pptx file with positioned reads.

Source

pub fn from_source(source: Arc<dyn Source>) -> Result<Self>

Opens a deck over any positioned source: a package, or a compound file holding a legacy binary presentation. Encrypted files are refused.

Source

pub fn from_legacy(deck: Arc<LegacyDeck>) -> Self

A document over a parsed legacy deck; slides map onto the same model.

Source

pub fn load(bytes: Vec<u8>) -> Result<Self>

Opens a presentation held in memory.

Source

pub fn from_package(package: Package) -> Result<Self>

Source

pub fn core_properties(&self) -> Result<Option<CoreProperties>>

The Core Properties part (docProps/core.xml), when the package has one.

Source

pub fn app_properties(&self) -> Result<Option<AppProperties>>

The Extended Properties part (docProps/app.xml), when the package has one.

Source

pub fn sections(&self) -> Vec<SlideSection>

The deck’s sections (PowerPoint 2010 p14:sectionLst) with their slides as zero-based indexes; empty when the deck has none.

Source

pub fn comment_authors(&self) -> &[CommentAuthor]

Every comment author the presentation part links to, both flavours; unreadable authors parts count as empty.

Source

pub fn threads(&self) -> usize

The worker limit for Document::map_slides; 0 means every core.

Source

pub fn set_threads(&mut self, threads: usize)

Limits Document::map_slides to threads workers; 0 restores every core for a package and the calling thread for a legacy deck, whose slides are too cheap to spread.

Source

pub fn with_threads(self, threads: usize) -> Self

Builder form of Document::set_threads.

Source

pub fn seed(&self) -> DocumentSeed

A handle that can cross threads.

Source

pub fn from_seed(seed: DocumentSeed) -> Self

A document over the same archive and presentation, with its own caches.

Source

pub fn package(&self) -> Option<&Package>

The package behind a PresentationML deck; None for a legacy binary deck.

Source

pub fn legacy(&self) -> Option<&Arc<LegacyDeck>>

The parsed legacy deck behind a .ppt file; None for a package.

Source

pub fn is_legacy(&self) -> bool

True for a legacy binary presentation.

Source

pub fn presentation(&self) -> &Presentation

Source

pub fn presentation_part(&self) -> &str

The Presentation part name, usually /ppt/presentation.xml.

Source

pub fn defects(&self) -> &DocumentDefects

Source

pub fn slide_refs(&self) -> &[SlideRef]

Slides in presentation order.

Source

pub fn slide_count(&self) -> usize

Source

pub fn slide(&self, index: usize) -> Result<Slide<'_>>

Parses slide index (zero-based, presentation order).

Source

pub fn slides(&self) -> impl Iterator<Item = Result<Slide<'_>>> + '_

Every slide in order; a slide that fails to parse yields its error and iteration continues.

Source

pub fn slide_part(&self, part: &str) -> Result<(SlideContent, SlideReport)>

Reads and parses any slide-family part by name (layouts, masters, notes).

Source

pub fn map_slides<T, F>(&self, f: F) -> Vec<T>
where T: Send, F: Fn(Result<Slide<'_>>) -> T + Sync,

Applies f to every slide, spreading slides across the available cores (see Document::set_threads). Results come back in slide order. Each worker thread builds its own Document from a seed, so nothing is shared but the archive.

Source

pub fn all_slides(&self) -> Vec<usize>

Every slide index, in presentation order.

Source

pub fn map_slides_at<T, F>(&self, indices: &[usize], f: F) -> Vec<T>
where T: Send, F: Fn(Result<Slide<'_>>) -> T + Sync,

Applies f to the slides at indices (zero-based), in the written order, with the same worker spread as Document::map_slides. An index past the last slide reaches f as an error.

Source

pub fn slide_texts(&self, options: &TextOptions) -> (Vec<String>, ExtractReport)

The text of every slide, in order, plus what was left out.

Source

pub fn slide_texts_at( &self, indices: &[usize], options: &TextOptions, ) -> (Vec<String>, ExtractReport)

The text of the slides at indices (zero-based), in the written order, plus what was left out; failures are reported under the real slide number.

Source

pub fn text(&self) -> String

The whole deck as text: slides separated by a blank line.

Source

pub fn text_reporting(&self, options: &TextOptions) -> (String, ExtractReport)

Source§

impl Document

Source

pub fn markdown(&self, options: &MarkdownOptions) -> (String, ExtractReport)

The whole deck as Markdown, slides separated by a rule, with what was skipped.

Source

pub fn markdown_at( &self, indices: &[usize], options: &MarkdownOptions, ) -> (String, ExtractReport)

The slides at indices (zero-based) as Markdown in the written order, separated by a rule, with what was skipped.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.