/// <inheritdoc/>
        public void Save(Stream stream, object item, object options)
        {
            if (item == null)
            {
                return;
            }

            var ic = options as IImageCache;

            if (options == null)
            {
                return;
            }

            IShapeRenderer renderer = new SkiaSharpRenderer(_serviceProvider, 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 IPageContainer page)
            {
                var dataFlow = _serviceProvider.GetService <IDataFlow>();
                var db       = (object)page.Data.Properties;
                var record   = (object)page.Data.Record;

                dataFlow.Bind(page.Template, db, record);
                dataFlow.Bind(page, db, record);

                exporter.Save(stream, page);
            }
            else if (item is IDocumentContainer document)
            {
                var dataFlow = _serviceProvider.GetService <IDataFlow>();

                dataFlow.Bind(document);

                exporter.Save(stream, document);
            }
            else if (item is IProjectContainer project)
            {
                var dataFlow = _serviceProvider.GetService <IDataFlow>();

                dataFlow.Bind(project);

                exporter.Save(stream, project);
            }
        }
Beispiel #2
0
        /// <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 PageContainer)
            {
                exporter.Save(path, item as PageContainer);
            }
            else if (item is DocumentContainer)
            {
                exporter.Save(path, item as DocumentContainer);
            }
            else if (item is ProjectContainer)
            {
                exporter.Save(path, item as ProjectContainer);
            }
        }