private void TransformDocxStream(Stream stream, OptimizeDiagnostic diagnostic, ImageOptimizerOptions options, CancellationToken token) { using var document = OpenXmlFactory.OpenWord(stream, true, options.OpenXmlUriAutoRecovery); var transformation = new OptimizerWord(_memoryStreamManager, options); transformation.Transform(document, diagnostic, token); foreach (var part in document.MainDocumentPart.EmbeddedPackageParts) { token.ThrowIfCancellationRequested(); TransformEmbeddedPart(part, diagnostic, options, token); } }
private void TransformPptxStream(Stream stream, OptimizeDiagnostic diagnostic, ImageOptimizerOptions options, CancellationToken token) { using var document = OpenXmlFactory.OpenPowerPoint(stream, true, options.OpenXmlUriAutoRecovery); var transformation = new OptimizerPowerPoint(_memoryStreamManager, options); transformation.Transform(document, diagnostic, token); foreach (var slide in document.PresentationPart.SlideParts) { foreach (var part in slide.EmbeddedPackageParts) { token.ThrowIfCancellationRequested(); TransformEmbeddedPart(part, diagnostic, options, token); } } }
public PowerPointAnalyzer(string fileName) { _fileName = fileName; _fileStream = File.Open(fileName, FileMode.Open); _document = OpenXmlFactory.OpenPowerPoint(_fileStream, false, true); }