Ejemplo n.º 1
0
        private static void SaveAsPdf(XpsDocumentSplicer xpsDocumentSplicer, string outputDirectory)
        {
            string tempXpsSavePath = GetTempXpsSavePath();

            xpsDocumentSplicer.SaveSplicedXpsDocumentTo(tempXpsSavePath);
            ConvertXpsToPdf(tempXpsSavePath, outputDirectory);
            File.Delete(tempXpsSavePath);
        }
Ejemplo n.º 2
0
 private static void Fill <T>(ref XpsDocumentSplicer xpsDocumentSplicer, IEnumerable <T> dataSourceObjectList)
 {
     foreach (T sourceObject in dataSourceObjectList)
     {
         if (IsCancellationRequested())
         {
             break;
         }
         xpsDocumentSplicer.AddXpsDocumentWith(sourceObject);
         ReportProgressFor(dataSourceObjectList);
     }
 }
Ejemplo n.º 3
0
        private static FileStream GetAsPdfFileStream(XpsDocumentSplicer xpsDocumentSplicer)
        {
            string tempXpsSavePath = GetTempXpsSavePath();
            string tempPdfSavePath = GetTempPdfSavePath();

            xpsDocumentSplicer.SaveSplicedXpsDocumentTo(tempXpsSavePath);
            ConvertXpsToPdf(tempXpsSavePath, tempPdfSavePath);
            FileStream pdfFileStream = File.Open(tempPdfSavePath, FileMode.OpenOrCreate);

            File.Delete(tempPdfSavePath);
            File.Delete(tempXpsSavePath);
            return(pdfFileStream);
        }
Ejemplo n.º 4
0
        public static void CreatePdfReportFromObjectList <T>(ReportProperties reportProperties, IEnumerable <T> dataSourceObjectList, CancellationToken cancellationToken = default, IProgress <double> progressReporter = null)
        {
            if (dataSourceObjectList == null)
            {
                throw new ArgumentNullException(nameof(dataSourceObjectList));
            }
            _cancellationToken = cancellationToken;
            _progressReporter  = progressReporter;

            var xpsDocumentSplicer = new XpsDocumentSplicer(reportProperties);

            Fill(ref xpsDocumentSplicer, dataSourceObjectList);
            if (IsCancellationRequested())
            {
                return;
            }

            SaveAsPdf(xpsDocumentSplicer, reportProperties.OutputDirectory);
            FinishProgress();
        }
Ejemplo n.º 5
0
        public static FileStream GetPdfReportFromObjectList <T>(ReportProperties reportProperties, IEnumerable <T> dataSourceObjectList, CancellationToken cancellationToken = default, IProgress <double> progressReporter = null)
        {
            if (dataSourceObjectList == null)
            {
                throw new ArgumentNullException(nameof(dataSourceObjectList));
            }
            _cancellationToken = cancellationToken;
            _progressReporter  = progressReporter;

            var xpsDocumentSplicer = new XpsDocumentSplicer(reportProperties);

            Fill(ref xpsDocumentSplicer, dataSourceObjectList);
            if (IsCancellationRequested())
            {
                return(null);
            }

            FileStream pdfFileStream = GetAsPdfFileStream(xpsDocumentSplicer);

            FinishProgress();
            return(pdfFileStream);
        }