示例#1
0
        private static void SaveAsPdf(XpsDocumentSplicer xpsDocumentSplicer, string outputDirectory)
        {
            string tempXpsSavePath = GetTempXpsSavePath();

            xpsDocumentSplicer.SaveSplicedXpsDocumentTo(tempXpsSavePath);
            ConvertXpsToPdf(tempXpsSavePath, outputDirectory);
            File.Delete(tempXpsSavePath);
        }
示例#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);
     }
 }
示例#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);
        }
示例#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();
        }
示例#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);
        }