// << pdfviewer-key-features-propertychanged-handler

        // >> pdfviewer-key-features-source-fixed-method
        private void ImportFixedDocument()
        {
            Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
            Assembly assembly = typeof(KeyFeatures).Assembly;
            string   fileName = assembly.GetManifestResourceNames().FirstOrDefault(n => n.Contains("pdfviewer-overview.pdf"));

            using (Stream stream = assembly.GetManifestResourceStream(fileName))
            {
                RadFixedDocument document = provider.Import(stream);
                this.pdfViewer.Source = document;
            }
        }
示例#2
0
        public CreateClientLetterTelerik(string sourcePath, string saveAsFile, CashFlowInformation information, CashFlowDetail detail)
        {
            this.sourcePath  = sourcePath;
            SaveAsFile       = saveAsFile;
            this.information = information;
            this.detail      = detail;

            FillStrings(detail);
            RadFlowDocument wordDocument = new RadFlowDocument();

            provider = new DocxFormatProvider();

            try
            {
                using (Stream input = File.OpenRead(sourcePath))
                {
                    wordDocument = provider.Import(input);
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Das Word-Template konnte nicht geöffnet werden. {ex.Message}");
            }

            editor = new RadFlowDocumentEditor(wordDocument);
            ReplacePlaceholder(detail);

            int    pos      = saveAsFile.LastIndexOf(".");
            string fileName = saveAsFile.Substring(0, pos) + ".docx";

            using (Stream output = File.OpenWrite(fileName))
            {
                provider.Export(editor.Document, output);
            }



            string pdfFile = fileName.Replace(".docx", ".pdf");

            // cpmversion of a flowdocument to a fixeddocument

            PdfFormatProvider pdfProvider   = new PdfFormatProvider();
            RadFixedDocument  fixedDocument = pdfProvider.ExportToFixedDocument(editor.Document);

            // write the fixeddocuement to file
            Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider fixedProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();


            using (Stream output = File.OpenWrite(pdfFile))
            {
                fixedProvider.Export(fixedDocument, output);
            }
        }