public RadFixedDocument CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage page = document.Pages.AddPage();
            page.Size = new Size(600, 800);
            this.editor = new FixedContentEditor(page);
            this.editor.Position.Translate(40, 50);
            using (Stream stream = FileHelper.GetSampleResourceStream("banner.png"))
            {
                ImageSource imageSource = new ImageSource(stream, ImageQuality.High);
                editor.DrawImage(imageSource, new Size(530, 80));
            }

            editor.Position.Translate(ExampleDocumentSizes.DefaultLeftIndent, 160);
            double maxWidth = page.Size.Width - ExampleDocumentSizes.DefaultLeftIndent * 2;

            this.DrawDescription(maxWidth);

            using (editor.SaveProperties())
            {
                using (editor.SavePosition())
                {
                    this.DrawFunnelFigure();
                }
            }

            return document;
        }
        private RadFixedDocument CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage page = document.Pages.AddPage();
            page.Size = new Size(600, 750);
            FixedContentEditor editor = new FixedContentEditor(page);
            editor.Position.Translate(defaultLeftIndent, 50);
            using (Stream stream = FileHelper.GetSampleResourceStream("pdfProcessingSilverlight.jpg"))
            {
                editor.DrawImage(stream);
            }
            double currentTopOffset = 110;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);
            editor.TextProperties.FontSize = 14;
            double maxWidth = page.Size.Width - defaultLeftIndent * 2;

            this.DrawDescription(editor, maxWidth);

            currentTopOffset += defaultLineHeight * 4;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);
            using (editor.SaveProperties())
            {
                this.DrawFunnelFigure(editor);
            }

            editor.Position.Translate(defaultLeftIndent * 4, page.Size.Height - 100);
            using (Stream stream = FileHelper.GetSampleResourceStream("telerik.jpg"))
            {
                editor.DrawImage(stream);
            }

            this.DrawText(editor, maxWidth);

            return document;
        }
        /// <summary>
        /// Creates a same RadFixedDocument using details text from uploaded content
        /// </summary>
        /// <param name="value">the content to use</param>
        /// <returns>FixedDocument that can be exported asa PDF file</returns>
        private static RadFixedDocument GenerateSampleDocument(MyPdfContent value)
        {
            double defaultLeftIndent = 50;
            double defaultLineHeight = 16;

            var document = new RadFixedDocument();
            var page     = document.Pages.AddPage();

            page.Size = PageSize;

            var editor = new FixedContentEditor(page);

            editor.Position.Translate(defaultLeftIndent, 50);

            double currentTopOffset = 110;

            editor.Position.Translate(defaultLeftIndent, currentTopOffset);
            double maxWidth = page.Size.Width - defaultLeftIndent * 2;

            DocumentHelpers.DrawDescription(editor, maxWidth);

            currentTopOffset += defaultLineHeight * 4;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);

            using (editor.SaveProperties())
            {
                DocumentHelpers.DrawFunnelFigure(editor);
            }

            // use the uploaded text
            DocumentHelpers.DrawText(editor, maxWidth, value);

            return(document);
        }
Exemple #4
0
        private RadFixedDocument CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage     page     = document.Pages.AddPage();

            page.Size = new Size(600, 800);
            FixedContentEditor editor = new FixedContentEditor(page);

            editor.Position.Translate(defaultLeftIndent, 50);
            using (Stream stream = File.OpenRead(sampleDataPath + "pdfProcessingWpf.jpg"))
            {
                editor.DrawImage(stream);
            }

            double currentTopOffset = 110;

            editor.Position.Translate(defaultLeftIndent, currentTopOffset);
            double maxWidth = page.Size.Width - defaultLeftIndent * 2;

            this.DrawDescription(editor, maxWidth);

            currentTopOffset += defaultLineHeight * 4;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);

            using (editor.SaveProperties())
            {
                this.DrawFunnelFigure(editor);
            }

            editor.Position.Translate(defaultLeftIndent * 4, page.Size.Height - 100);
            using (Stream stream = File.OpenRead(sampleDataPath + "telerik.jpg"))
            {
                editor.DrawImage(stream);
            }

            this.DrawText(editor, maxWidth);

            return(document);
        }
Exemple #5
0
        private void OnGeneratePdfFile()
        {
            double height = 0;

            ChartFileName  = Path.Combine(Properties.Settings.Default.RootDirectory, SelectedEmployee.FullName);
            ChartFileName += ".png";

            Size chartSize = new Size(employeeChart.ActualWidth, employeeChart.ActualHeight);


            employeeChart.Measure(Size.Empty);
            employeeChart.Measure(chartSize);
            employeeChart.Arrange(new Rect(chartSize));


            Task.Delay(100);

            using (Stream stream = File.Open(ChartFileName, FileMode.OpenOrCreate))
            {
                Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(employeeChart, stream, new PngBitmapEncoder());
            }

            string             fileName = Properties.Settings.Default.PdfVorlagePortait;
            RadFixedDocument   document = GetDocumentFromTemplate(fileName);
            RadFixedPage       page     = document.Pages[0];
            FixedContentEditor editor   = new FixedContentEditor(page);

            double currentTopOffset = 150;

            editor.Position.Translate(defaultLeftIndent, currentTopOffset);
            double maxWidth = page.Size.Width - defaultLeftIndent * 2;

            using (editor.SaveProperties())
            {
                height            = AddEmployeeNameToPage(editor, maxWidth);
                currentTopOffset += height;
            }

            currentTopOffset += defaultLineHeight * 2;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);

            using (editor.SaveProperties())
            {
                height            = AddEmploymentPeriod(editor, maxWidth);
                currentTopOffset += height;
            }

            currentTopOffset += defaultLineHeight * 2;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);

            using (editor.SaveProperties())
            {
                height            = AddHeadlineToPage(editor, "Gehaltsentwicklung (max. 5 Jahre)", maxWidth);
                currentTopOffset += height;
            }

            currentTopOffset += defaultLineHeight * 2;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);

            currentTopOffset += AddImageToPage(editor, ChartFileName, maxWidth);

            currentTopOffset += defaultLineHeight * 4;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);


            using (editor.SaveProperties())
            {
                height            = AddAnnualOverview(editor, maxWidth);
                currentTopOffset += height;
            }



            string saveFileName = @"C:\Users\franz\OneDrive - Franz Bichlmaier Consulting\QuantCo\Uebersicht " + SelectedEmployee.FullName + ".pdf";

            SaveDocumentAsPdf(document, saveFileName);
            ChartFileName = string.Empty;
        }