public void Save(Stream stream, object?item, object?options) { if (item is null) { return; } var ic = options as IImageCache; if (options is null) { return; } IShapeRenderer renderer = new SkiaSharpRendererViewModel(_serviceProvider); renderer.State.DrawShapeState = ShapeStateFlags.Printable; renderer.State.ImageCache = ic; var presenter = new ExportPresenter(); IProjectExporter exporter = new PdfSkiaSharpExporter(renderer, presenter, 72.0f); if (item is PageContainerViewModel page) { var dataFlow = _serviceProvider.GetService <DataFlow>(); var db = (object)page.Properties; var record = (object)page.Record; dataFlow.Bind(page.Template, db, record); dataFlow.Bind(page, db, record); exporter.Save(stream, page); } else if (item is DocumentContainerViewModel document) { var dataFlow = _serviceProvider.GetService <DataFlow>(); dataFlow.Bind(document); exporter.Save(stream, document); } else if (item is ProjectContainerViewModel project) { var dataFlow = _serviceProvider.GetService <DataFlow>(); dataFlow.Bind(project); exporter.Save(stream, project); } }
/// <inheritdoc/> void IFileWriter.Save(string path, object item, object options) { if (string.IsNullOrEmpty(path) || item == null) { return; } var ic = options as IImageCache; if (options == null) { return; } ShapeRenderer renderer = new SkiaSharpRenderer(true, 72.0); renderer.State.DrawShapeState.Flags = ShapeStateFlags.Printable; renderer.State.ImageCache = ic; var presenter = new ExportPresenter(); IProjectExporter exporter = new PdfSkiaSharpExporter(renderer, presenter, 72.0f); if (item is XContainer) { exporter.Save(path, item as XContainer); } else if (item is XDocument) { exporter.Save(path, item as XDocument); } else if (item is XProject) { exporter.Save(path, item as XProject); } }